From 36c07be889ca80e08436523b67314bacd070c58c Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Tue, 13 Feb 2024 09:11:50 +0000
Subject: [PATCH] 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>
---
src/stores/oidc/OidcClientStore.ts | 4 +++-
test/components/structures/MatrixChat-test.tsx | 2 ++
.../views/settings/tabs/user/SessionManagerTab-test.tsx | 5 ++---
test/test-utils/client.ts | 1 +
test/test-utils/test-utils.ts | 1 +
5 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/stores/oidc/OidcClientStore.ts b/src/stores/oidc/OidcClientStore.ts
index 3739d1a5bc..aafbbc6276 100644
--- a/src/stores/oidc/OidcClientStore.ts
+++ b/src/stores/oidc/OidcClientStore.ts
@@ -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);
+ });
}
}
diff --git a/test/components/structures/MatrixChat-test.tsx b/test/components/structures/MatrixChat-test.tsx
index 797777767c..441de19df9 100644
--- a/test/components/structures/MatrixChat-test.tsx
+++ b/test/components/structures/MatrixChat-test.tsx
@@ -38,6 +38,7 @@ import {
filterConsole,
flushPromises,
getMockClientWithEventEmitter,
+ mockClientMethodsServer,
mockClientMethodsUser,
MockClientWithEventEmitter,
mockPlatformPeg,
@@ -73,6 +74,7 @@ describe("", () => {
// 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(),
diff --git a/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx b/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx
index f1fcb88dee..9beceb95ef 100644
--- a/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx
+++ b/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx
@@ -42,6 +42,7 @@ import {
flushPromises,
getMockClientWithEventEmitter,
mkPusher,
+ mockClientMethodsServer,
mockClientMethodsUser,
mockPlatformPeg,
} from "../../../../../test-utils";
@@ -167,6 +168,7 @@ describe("", () => {
beforeEach(async () => {
mockClient = getMockClientWithEventEmitter({
...mockClientMethodsUser(aliceId),
+ ...mockClientMethodsServer(),
getCrypto: jest.fn().mockReturnValue(mockCrypto),
getDevices: jest.fn(),
getStoredDevice: jest.fn(),
@@ -180,9 +182,6 @@ describe("", () => {
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();
diff --git a/test/test-utils/client.ts b/test/test-utils/client.ts
index 9c00b22c3e..0a2e0cd617 100644
--- a/test/test-utils/client.ts
+++ b/test/test-utils/client.ts
@@ -130,6 +130,7 @@ export const mockClientMethodsServer = (): Partial