mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
test(test): add wellknown integration test (#1694)
add wellknown api integration test
This commit is contained in:
parent
a850694070
commit
c76a0b8430
5 changed files with 55 additions and 1 deletions
|
@ -7,5 +7,6 @@ export * from './session';
|
|||
export * from './logs';
|
||||
export * from './dashboard';
|
||||
export * from './me';
|
||||
export * from './wellknown';
|
||||
|
||||
export { default as api, authedAdminApi } from './api';
|
||||
|
|
12
packages/integration-tests/src/api/wellknown.ts
Normal file
12
packages/integration-tests/src/api/wellknown.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { SignInExperience } from '@logto/schemas';
|
||||
|
||||
import api from './api';
|
||||
|
||||
export const getWellKnownSignInExperience = (interactionCookie: string) =>
|
||||
api
|
||||
.get('.well-known/sign-in-exp', {
|
||||
headers: {
|
||||
cookie: interactionCookie,
|
||||
},
|
||||
})
|
||||
.json<SignInExperience>();
|
|
@ -22,7 +22,7 @@ export default class MockClient {
|
|||
private readonly storage: MemoryStorage;
|
||||
private readonly logto: LogtoClient;
|
||||
|
||||
constructor(config?: LogtoConfig) {
|
||||
constructor(config?: Partial<LogtoConfig>) {
|
||||
this.storage = new MemoryStorage();
|
||||
|
||||
this.logto = new LogtoClient(
|
||||
|
|
|
@ -6,3 +6,4 @@ export const logtoUrl = getEnv('LOGTO_URL');
|
|||
export const discoveryUrl = `${logtoUrl}/oidc/.well-known/openid-configuration`;
|
||||
|
||||
export const demoAppRedirectUri = `${logtoUrl}/${demoAppApplicationId}`;
|
||||
export const adminConsoleRedirectUri = `${logtoUrl}/console/callback`;
|
||||
|
|
40
packages/integration-tests/tests/wellknown.test.ts
Normal file
40
packages/integration-tests/tests/wellknown.test.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { adminConsoleApplicationId } from '@logto/schemas/lib/seeds';
|
||||
import { assert } from '@silverhand/essentials';
|
||||
|
||||
import { getWellKnownSignInExperience } from '@/api';
|
||||
import MockClient from '@/client';
|
||||
import { adminConsoleRedirectUri } from '@/constants';
|
||||
|
||||
describe('wellknown api', () => {
|
||||
it('get /.well-known/sign-in-exp for AC', async () => {
|
||||
const client = new MockClient({ appId: adminConsoleApplicationId });
|
||||
await client.initSession(adminConsoleRedirectUri);
|
||||
|
||||
assert(client.interactionCookie, new Error('Session not found'));
|
||||
|
||||
const response = await getWellKnownSignInExperience(client.interactionCookie);
|
||||
|
||||
expect(response).toMatchObject({
|
||||
signInMethods: {
|
||||
username: 'primary',
|
||||
email: 'disabled',
|
||||
sms: 'disabled',
|
||||
social: 'disabled',
|
||||
},
|
||||
signInMode: 'SignIn',
|
||||
});
|
||||
});
|
||||
|
||||
it('get /.well-known/sign-in-exp for general app', async () => {
|
||||
const client = new MockClient();
|
||||
|
||||
await client.initSession();
|
||||
|
||||
assert(client.interactionCookie, new Error('Session not found'));
|
||||
|
||||
const response = await getWellKnownSignInExperience(client.interactionCookie);
|
||||
|
||||
// Should support sign-in and register
|
||||
expect(response).toMatchObject({ signInMode: 'SignInAndRegister' });
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue