mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(api): SSO discovery, channel create and deleted bots (#3390)
This commit is contained in:
1 parent
edc913096a
commit
0967bf3136
17 files changed
+508
-156
No files matched your search
@@ -0,0 +1,56 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {tryDiscoverOidcProviderMetadata} from '@app/api/auth/services/SsoUtils';
|
||||
import {Config} from '@app/api/Config';
|
||||
import {resetSsoRequestUrlPolicyForTesting} from '@app/api/instance/SsoConfigValidation';
|
||||
import {server} from '@app/api/test/msw/server';
|
||||
import {HttpResponse, http} from 'msw';
|
||||
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
||||
|
||||
const PRIVATE_ISSUER = 'http://10.20.30.40:5556/dex';
|
||||
|
||||
describe('tryDiscoverOidcProviderMetadata', () => {
|
||||
const previousAllowPrivateAddresses = Config.auth.ssoAllowPrivateAddresses;
|
||||
let discoveryRequests = 0;
|
||||
|
||||
beforeEach(() => {
|
||||
discoveryRequests = 0;
|
||||
server.use(
|
||||
http.get(`${PRIVATE_ISSUER}/.well-known/openid-configuration`, () => {
|
||||
discoveryRequests++;
|
||||
return HttpResponse.json({
|
||||
issuer: PRIVATE_ISSUER,
|
||||
authorization_endpoint: `${PRIVATE_ISSUER}/auth`,
|
||||
token_endpoint: `${PRIVATE_ISSUER}/token`,
|
||||
userinfo_endpoint: `${PRIVATE_ISSUER}/userinfo`,
|
||||
jwks_uri: `${PRIVATE_ISSUER}/keys`,
|
||||
});
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
Config.auth.ssoAllowPrivateAddresses = previousAllowPrivateAddresses;
|
||||
resetSsoRequestUrlPolicyForTesting();
|
||||
});
|
||||
|
||||
it('discovers endpoints on a private issuer when private addresses are allowed', async () => {
|
||||
Config.auth.ssoAllowPrivateAddresses = true;
|
||||
resetSsoRequestUrlPolicyForTesting();
|
||||
await expect(tryDiscoverOidcProviderMetadata(PRIVATE_ISSUER)).resolves.toEqual({
|
||||
issuer: PRIVATE_ISSUER,
|
||||
authorization_endpoint: `${PRIVATE_ISSUER}/auth`,
|
||||
token_endpoint: `${PRIVATE_ISSUER}/token`,
|
||||
userinfo_endpoint: `${PRIVATE_ISSUER}/userinfo`,
|
||||
jwks_uri: `${PRIVATE_ISSUER}/keys`,
|
||||
});
|
||||
expect(discoveryRequests).toBe(1);
|
||||
});
|
||||
|
||||
it('refuses a private issuer when private addresses are not allowed', async () => {
|
||||
Config.auth.ssoAllowPrivateAddresses = false;
|
||||
resetSsoRequestUrlPolicyForTesting();
|
||||
await expect(tryDiscoverOidcProviderMetadata(PRIVATE_ISSUER)).resolves.toBeNull();
|
||||
expect(discoveryRequests).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user