Skip to content

Commit f66eebf

Browse files
author
Kerry Archibald
committed
test invalid authentication config on wk
1 parent 7e3d13f commit f66eebf

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

spec/unit/autodiscovery.spec.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,50 @@ describe("AutoDiscovery", function () {
450450
]);
451451
});
452452

453+
it("should return SUCCESS with authentication error when authentication config is invalid", function () {
454+
const httpBackend = getHttpBackend();
455+
httpBackend
456+
.when("GET", "/_matrix/client/versions")
457+
.check((req) => {
458+
expect(req.path).toEqual("https://chat.example.org/_matrix/client/versions");
459+
})
460+
.respond(200, {
461+
versions: ["r0.0.1"],
462+
});
463+
httpBackend.when("GET", "/.well-known/matrix/client").respond(200, {
464+
"m.homeserver": {
465+
// Note: we also expect this test to trim the trailing slash
466+
base_url: "https://chat.example.org/",
467+
},
468+
"m.authentication": {
469+
invalid: true,
470+
},
471+
});
472+
return Promise.all([
473+
httpBackend.flushAllExpected(),
474+
AutoDiscovery.findClientConfig("example.org").then((conf) => {
475+
const expected = {
476+
"m.homeserver": {
477+
state: "SUCCESS",
478+
error: null,
479+
base_url: "https://chat.example.org",
480+
},
481+
"m.identity_server": {
482+
state: "PROMPT",
483+
error: null,
484+
base_url: null,
485+
},
486+
"m.authentication": {
487+
state: "FAIL_ERROR",
488+
error: OidcDiscoveryError.Misconfigured,
489+
},
490+
};
491+
492+
expect(conf).toEqual(expected);
493+
}),
494+
]);
495+
});
496+
453497
it(
454498
"should return SUCCESS / FAIL_PROMPT when the identity server configuration " + "is wrong (missing base_url)",
455499
function () {

0 commit comments

Comments
 (0)