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.
This commit is contained in:
commit
b4150c8250
1364 changed files with 6814366 additions and 0 deletions
66
vendor/zapier-platform/example-apps/openai/test/authentication.test.js
vendored
Normal file
66
vendor/zapier-platform/example-apps/openai/test/authentication.test.js
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/* globals describe, it, expect */
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
const App = require('../index');
|
||||
|
||||
describe('custom auth', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('passes authentication and returns json', async () => {
|
||||
const bundle = {
|
||||
authData: {
|
||||
api_key: 'secret',
|
||||
},
|
||||
};
|
||||
|
||||
// Mock successful response
|
||||
const mockResponse = {
|
||||
status: 200,
|
||||
data: {
|
||||
email: 'test@example.com',
|
||||
},
|
||||
};
|
||||
|
||||
// Mock the request client
|
||||
const mockRequest = jest.fn().mockResolvedValue(mockResponse);
|
||||
const z = {
|
||||
request: mockRequest,
|
||||
};
|
||||
|
||||
const response = await App.authentication.test(z, bundle);
|
||||
|
||||
expect(mockRequest).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequest).toHaveBeenCalledWith({
|
||||
url: expect.stringContaining('/me'),
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.data).toHaveProperty('email', 'test@example.com');
|
||||
});
|
||||
|
||||
it('fails on bad auth', async () => {
|
||||
const bundle = {
|
||||
authData: {
|
||||
api_key: 'bad',
|
||||
},
|
||||
};
|
||||
|
||||
// Mock failed response
|
||||
const mockRequest = jest
|
||||
.fn()
|
||||
.mockRejectedValue(new Error('Incorrect API key provided'));
|
||||
const z = {
|
||||
request: mockRequest,
|
||||
};
|
||||
|
||||
try {
|
||||
await App.authentication.test(z, bundle);
|
||||
} catch (error) {
|
||||
expect(mockRequest).toHaveBeenCalledTimes(1);
|
||||
expect(error.message).toContain('Incorrect API key provided');
|
||||
return;
|
||||
}
|
||||
throw new Error('appTester should have thrown');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue