master-zapier-plan-draft/vendor/zapier-platform/example-apps/basic-auth/test/authentication.test.js
George Lambert b4150c8250 Milestone 0: import zappier billing, Verae middleware, and Zapier research
Compose-ready workspace: packages/zappier (rate card, portal, Stripe),
packages/verae-zapier-middleware (timestamp + NATS), packages/verae-zapier
(CLI app), vendor/zapier-platform, and research/zapier vendor corpus.

Gate 0 structure checks pass. Product code and research are not yet wired.
2026-09-09 02:37:36 -04:00

43 lines
1,013 B
JavaScript

/* globals describe, it, expect */
const zapier = require('zapier-platform-core');
const App = require('../index');
const appTester = zapier.createAppTester(App);
describe('basic auth', () => {
it('automatically has Authorize Header add', async () => {
const bundle = {
authData: {
username: 'user',
password: 'secret',
},
};
const response = await appTester(App.authentication.test, bundle);
expect(response.status).toBe(200);
expect(response.request.headers.Authorization).toBe(
'Basic dXNlcjpzZWNyZXQ=',
);
});
it('fails on bad auth', async () => {
const bundle = {
authData: {
username: 'user',
password: 'badpwd',
},
};
try {
await appTester(App.authentication.test, bundle);
} catch (err) {
expect(err.message).toContain(
'The username and/or password you supplied is incorrect',
);
return;
}
throw new Error('appTester should have thrown');
});
});