Fix OIDC delegated auth account url check (#12242)

* Fix OIDC delegated auth account url check

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Update tests

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/28217/head
Michael Telatynski 2024-02-13 09:11:50 +00:00 committed by GitHub
parent 5f8a390f2e
commit 36c07be889
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 4 deletions

View File

@ -37,7 +37,9 @@ export class OidcClientStore {
if (this.authenticatedIssuer) {
this.getOidcClient();
} else {
this._accountManagementEndpoint = getDelegatedAuthAccountUrl(matrixClient);
matrixClient.waitForClientWellKnown().then((wellKnown) => {
this._accountManagementEndpoint = getDelegatedAuthAccountUrl(wellKnown);
});
}
}

View File

@ -38,6 +38,7 @@ import {
filterConsole,
flushPromises,
getMockClientWithEventEmitter,
mockClientMethodsServer,
mockClientMethodsUser,
MockClientWithEventEmitter,
mockPlatformPeg,
@ -73,6 +74,7 @@ describe("<MatrixChat />", () => {
// reused in createClient mock below
const getMockClientMethods = () => ({
...mockClientMethodsUser(userId),
...mockClientMethodsServer(),
getVersions: jest.fn().mockResolvedValue({ versions: SERVER_SUPPORTED_MATRIX_VERSIONS }),
startClient: jest.fn(),
stopClient: jest.fn(),

View File

@ -42,6 +42,7 @@ import {
flushPromises,
getMockClientWithEventEmitter,
mkPusher,
mockClientMethodsServer,
mockClientMethodsUser,
mockPlatformPeg,
} from "../../../../../test-utils";
@ -167,6 +168,7 @@ describe("<SessionManagerTab />", () => {
beforeEach(async () => {
mockClient = getMockClientWithEventEmitter({
...mockClientMethodsUser(aliceId),
...mockClientMethodsServer(),
getCrypto: jest.fn().mockReturnValue(mockCrypto),
getDevices: jest.fn(),
getStoredDevice: jest.fn(),
@ -180,9 +182,6 @@ describe("<SessionManagerTab />", () => {
getPushers: jest.fn(),
setPusher: jest.fn(),
setLocalNotificationSettings: jest.fn(),
getVersions: jest.fn().mockResolvedValue({}),
getCapabilities: jest.fn().mockResolvedValue({}),
getClientWellKnown: jest.fn().mockReturnValue({}),
});
jest.clearAllMocks();
jest.spyOn(logger, "error").mockRestore();

View File

@ -130,6 +130,7 @@ export const mockClientMethodsServer = (): Partial<Record<MethodLikeKeys<MatrixC
getHomeserverUrl: jest.fn(),
getCapabilities: jest.fn().mockReturnValue({}),
getClientWellKnown: jest.fn().mockReturnValue({}),
waitForClientWellKnown: jest.fn().mockResolvedValue({}),
doesServerSupportUnstableFeature: jest.fn().mockResolvedValue(false),
isVersionSupported: jest.fn().mockResolvedValue(false),
getVersions: jest.fn().mockResolvedValue({}),

View File

@ -160,6 +160,7 @@ export function createTestClient(): MatrixClient {
getProfileInfo: jest.fn().mockResolvedValue({}),
getThirdpartyProtocols: jest.fn().mockResolvedValue({}),
getClientWellKnown: jest.fn().mockReturnValue(null),
waitForClientWellKnown: jest.fn().mockResolvedValue({}),
supportsVoip: jest.fn().mockReturnValue(true),
getTurnServers: jest.fn().mockReturnValue([]),
getTurnServersExpiry: jest.fn().mockReturnValue(2 ^ 32),