0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

refactor(core): update sign-in-settings api path (#1339)

update sign-in-settings api path
This commit is contained in:
simeng-li 2022-07-01 17:14:38 +08:00 committed by GitHub
parent 75636e2397
commit 084a2bcd03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 13 deletions

View file

@ -15,9 +15,9 @@ import sessionRoutes from '@/routes/session/session';
import sessionSocialRoutes from '@/routes/session/social';
import settingRoutes from '@/routes/setting';
import signInExperiencesRoutes from '@/routes/sign-in-experience';
import signInSettingsRoutes from '@/routes/sign-in-settings';
import statusRoutes from '@/routes/status';
import swaggerRoutes from '@/routes/swagger';
import wellKnownRoutes from '@/routes/well-known';
import adminUserRoutes from './admin-user';
import logRoutes from './log';
@ -49,7 +49,7 @@ const createRouters = (provider: Provider) => {
meRoutes(meRouter);
const anonymousRouter: AnonymousRouter = new Router();
signInSettingsRoutes(anonymousRouter, provider);
wellKnownRoutes(anonymousRouter, provider);
statusRoutes(anonymousRouter);
// The swagger.json should contain all API routers.
swaggerRoutes(anonymousRouter, [sessionRouter, managementRouter, meRouter, anonymousRouter]);

View file

@ -15,7 +15,7 @@ import {
import { getConnectorInstanceById } from '@/connectors';
import RequestError from '@/errors/RequestError';
import * as signInExperienceQueries from '@/queries/sign-in-experience';
import signInSettingsRoutes from '@/routes/sign-in-settings';
import wellKnownRoutes from '@/routes/well-known';
import { createRequester } from '@/utils/test-utils';
const getConnectorInstances = jest.fn(async () => [
@ -58,13 +58,13 @@ jest.mock('oidc-provider', () => ({
})),
}));
describe('GET /sign-in-settings', () => {
describe('GET /.well-known/sign-in-exp', () => {
afterEach(() => {
jest.clearAllMocks();
});
const sessionRequest = createRequester({
anonymousRoutes: signInSettingsRoutes,
anonymousRoutes: wellKnownRoutes,
provider: new Provider(''),
middlewares: [
async (ctx, next) => {
@ -81,7 +81,7 @@ describe('GET /sign-in-settings', () => {
.mockResolvedValue(mockSignInExperience);
it('should return github and facebook connector instances', async () => {
const response = await sessionRequest.get('/sign-in-settings');
const response = await sessionRequest.get('/.well-known/sign-in-exp');
expect(signInExperienceQuerySpyOn).toHaveBeenCalledTimes(1);
expect(response.status).toEqual(200);
expect(response.body).toMatchObject(
@ -111,7 +111,7 @@ describe('GET /sign-in-settings', () => {
it('should return admin console settings', async () => {
interactionDetails.mockResolvedValue({ params: { client_id: adminConsoleApplicationId } });
const response = await sessionRequest.get('/sign-in-settings');
const response = await sessionRequest.get('/.well-known/sign-in-exp');
expect(signInExperienceQuerySpyOn).toHaveBeenCalledTimes(1);
expect(response.status).toEqual(200);

View file

@ -15,12 +15,9 @@ import { hasActiveUsers } from '@/queries/user';
import { AnonymousRouter } from './types';
export default function signInSettingsRoutes<T extends AnonymousRouter>(
router: T,
provider: Provider
) {
export default function wellKnownRoutes<T extends AnonymousRouter>(router: T, provider: Provider) {
router.get(
'/sign-in-settings',
'/.well-known/sign-in-exp',
async (ctx, next) => {
const [signInExperience, connectorInstances, interaction] = await Promise.all([
findDefaultSignInExperience(),

View file

@ -7,5 +7,5 @@ import { SignInExperience } from '@logto/schemas';
import ky from 'ky';
export const getSignInExperience = async <T extends SignInExperience>(): Promise<T> => {
return ky.get('/api/sign-in-settings').json<T>();
return ky.get('/api/.well-known/sign-in-exp').json<T>();
};