2022-07-29 04:48:23 -05:00
|
|
|
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({
|
2022-11-03 05:23:12 -05:00
|
|
|
signUp: {
|
|
|
|
identifier: 'username',
|
|
|
|
password: true,
|
|
|
|
verify: false,
|
|
|
|
},
|
|
|
|
signIn: {
|
|
|
|
methods: [
|
|
|
|
{
|
|
|
|
identifier: 'username',
|
|
|
|
password: true,
|
|
|
|
verificationCode: false,
|
|
|
|
isPasswordPrimary: true,
|
|
|
|
},
|
|
|
|
],
|
2022-07-29 04:48:23 -05:00
|
|
|
},
|
|
|
|
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' });
|
|
|
|
});
|
|
|
|
});
|