add delegatedauthentication to validated server config (#11053)
This commit is contained in:
parent
d5d1ec775c
commit
41dfec20bf
3 changed files with 68 additions and 0 deletions
|
@ -16,6 +16,7 @@ limitations under the License.
|
|||
|
||||
import { AutoDiscovery, AutoDiscoveryAction, ClientConfig } from "matrix-js-sdk/src/autodiscovery";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { M_AUTHENTICATION } from "matrix-js-sdk/src/client";
|
||||
|
||||
import AutoDiscoveryUtils from "../../src/utils/AutoDiscoveryUtils";
|
||||
|
||||
|
@ -186,5 +187,50 @@ describe("AutoDiscoveryUtils", () => {
|
|||
warning: "Homeserver URL does not appear to be a valid Matrix homeserver",
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores delegated auth config when discovery was not successful", () => {
|
||||
const discoveryResult = {
|
||||
...validIsConfig,
|
||||
...validHsConfig,
|
||||
[M_AUTHENTICATION.stable!]: {
|
||||
state: AutoDiscoveryAction.FAIL_ERROR,
|
||||
error: "",
|
||||
},
|
||||
};
|
||||
const syntaxOnly = true;
|
||||
expect(
|
||||
AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, discoveryResult, syntaxOnly),
|
||||
).toEqual({
|
||||
...expectedValidatedConfig,
|
||||
delegatedAuthentication: undefined,
|
||||
warning: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("sets delegated auth config when discovery was successful", () => {
|
||||
const authConfig = {
|
||||
issuer: "https://test.com/",
|
||||
authorizationEndpoint: "https://test.com/auth",
|
||||
registrationEndpoint: "https://test.com/registration",
|
||||
tokenEndpoint: "https://test.com/token",
|
||||
};
|
||||
const discoveryResult = {
|
||||
...validIsConfig,
|
||||
...validHsConfig,
|
||||
[M_AUTHENTICATION.stable!]: {
|
||||
state: AutoDiscoveryAction.SUCCESS,
|
||||
error: null,
|
||||
...authConfig,
|
||||
},
|
||||
};
|
||||
const syntaxOnly = true;
|
||||
expect(
|
||||
AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, discoveryResult, syntaxOnly),
|
||||
).toEqual({
|
||||
...expectedValidatedConfig,
|
||||
delegatedAuthentication: authConfig,
|
||||
warning: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue