Add authentication optional api url parameter (#5803)

This commit is contained in:
martmull
2024-06-11 12:08:21 +02:00
committed by GitHub
parent af8c637355
commit 9307d206c5
4 changed files with 47 additions and 5 deletions

View File

@ -37,6 +37,35 @@ describe('custom auth', () => {
expect(response.data.currentWorkspace).toHaveProperty('displayName');
});
it('passes authentication with api url and returns json', async () => {
const bundle = getBundle();
const bundleWithApiUrl = {
...bundle,
authData: { ...bundle.authData, apiUrl: 'http://localhost:3000' },
};
const response = await appTester(App.authentication.test, bundleWithApiUrl);
expect(response.data).toHaveProperty('currentWorkspace');
expect(response.data.currentWorkspace).toHaveProperty('displayName');
});
it('fail authentication with bad api url', async () => {
const bundle = getBundle();
const bundleWithApiUrl = {
...bundle,
authData: { ...bundle.authData, apiUrl: 'http://invalid' },
};
try {
const response = await appTester(
App.authentication.test,
bundleWithApiUrl,
);
expect(response.data).toHaveProperty('currentWorkspace');
expect(response.data.currentWorkspace).toHaveProperty('displayName');
} catch (error: any) {
expect(error.message).toContain('ENOTFOUND');
}
});
it('fails on bad auth token format', async () => {
const bundle = getBundle();
bundle.authData.apiKey = 'bad';
@ -44,7 +73,7 @@ describe('custom auth', () => {
try {
await appTester(App.authentication.test, bundle);
} catch (error: any) {
expect(error.message).toContain('Unauthenticated');
expect(error.message).toContain('UNAUTHENTICATED');
return;
}
throw new Error('appTester should have thrown');
@ -71,7 +100,7 @@ describe('custom auth', () => {
try {
await appTester(App.authentication.test, bundleWithExpiredApiKey);
} catch (error: any) {
expect(error.message).toContain('Unauthenticated');
expect(error.message).toContain('UNAUTHENTICATED');
return;
}
throw new Error('appTester should have thrown');