0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(core): fix applications APIs status guard (#6845)

This commit is contained in:
Darcy Ye 2024-12-03 01:25:39 -08:00 committed by GitHub
parent 14b4254d1e
commit 352f4d1a5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -256,7 +256,7 @@ export default function applicationRoutes<T extends ManagementApiRouter>(
})
),
response: Applications.guard,
status: [200, 404, 422, 500],
status: [200, 400, 404, 422, 500],
}),
async (ctx, next) => {
const {
@ -341,7 +341,7 @@ export default function applicationRoutes<T extends ManagementApiRouter>(
koaGuard({
params: object({ id: string().min(1) }),
response: z.undefined(),
status: [204, 404, 422],
status: [204, 400, 404, 422],
}),
async (ctx, next) => {
const { id } = ctx.guard.params;

View file

@ -1,6 +1,6 @@
import { ApplicationType, BindingType } from '@logto/schemas';
import { createApplication, deleteApplication } from '#src/api/application.js';
import { createApplication, deleteApplication, updateApplication } from '#src/api/application.js';
import {
createSamlApplication,
deleteSamlApplication,
@ -123,6 +123,14 @@ describe('SAML application secrets/certificate/metadata', () => {
// @ts-expect-error - Make sure the `privateKey` is not exposed
expect(createdSecret.privateKey).toBeUndefined();
await expectRejects(updateApplication(id, { name: 'updated' }), {
code: 'application.saml.use_saml_app_api',
status: 400,
});
await expectRejects(deleteApplication(id), {
code: 'application.saml.use_saml_app_api',
status: 400,
});
await deleteSamlApplication(id);
});