From d38da836568420eb8f2b0b18b160f696aa73edaf Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 4 Jun 2019 23:39:31 -0600 Subject: [PATCH 1/2] Provide the discovered URLs when a liveliness error occurs See https://github.com/vector-im/riot-web/issues/9828 --- src/autodiscovery.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/autodiscovery.js b/src/autodiscovery.js index 10f714d24..e031173fe 100644 --- a/src/autodiscovery.js +++ b/src/autodiscovery.js @@ -256,6 +256,11 @@ export class AutoDiscovery { if (!hsVersions || !hsVersions.raw["versions"]) { logger.error("Invalid /versions response"); clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_INVALID_HOMESERVER; + + // Supply the base_url to the caller because they may be ignoring liveliness + // errors, like this one. + clientConfig["m.homeserver"].base_url = hsUrl; + return Promise.resolve(clientConfig); } @@ -311,6 +316,11 @@ export class AutoDiscovery { logger.error("Invalid /api/v1 response"); failingClientConfig["m.identity_server"].error = AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER; + + // Supply the base_url to the caller because they may be ignoring + // liveliness errors, like this one. + clientConfig["m.identity_server"].base_url = isUrl; + return Promise.resolve(failingClientConfig); } } From 26c1c6db3bac8a7f791f29217f58638377495158 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 4 Jun 2019 23:51:41 -0600 Subject: [PATCH 2/2] Fix tests and populate the right IS validation object --- spec/unit/autodiscovery.spec.js | 10 +++++----- src/autodiscovery.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/unit/autodiscovery.spec.js b/spec/unit/autodiscovery.spec.js index f6cb486a1..6d4e5a3e9 100644 --- a/spec/unit/autodiscovery.spec.js +++ b/spec/unit/autodiscovery.spec.js @@ -275,7 +275,7 @@ describe("AutoDiscovery", function() { "m.homeserver": { state: "FAIL_ERROR", error: AutoDiscovery.ERROR_INVALID_HOMESERVER, - base_url: null, + base_url: "https://example.org", }, "m.identity_server": { state: "PROMPT", @@ -304,7 +304,7 @@ describe("AutoDiscovery", function() { "m.homeserver": { state: "FAIL_ERROR", error: AutoDiscovery.ERROR_INVALID_HOMESERVER, - base_url: null, + base_url: "https://example.org", }, "m.identity_server": { state: "PROMPT", @@ -335,7 +335,7 @@ describe("AutoDiscovery", function() { "m.homeserver": { state: "FAIL_ERROR", error: AutoDiscovery.ERROR_INVALID_HOMESERVER, - base_url: null, + base_url: "https://example.org", }, "m.identity_server": { state: "PROMPT", @@ -528,7 +528,7 @@ describe("AutoDiscovery", function() { "m.identity_server": { state: "FAIL_ERROR", error: AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER, - base_url: null, + base_url: "https://identity.example.org", }, }; @@ -569,7 +569,7 @@ describe("AutoDiscovery", function() { "m.identity_server": { state: "FAIL_ERROR", error: AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER, - base_url: null, + base_url: "https://identity.example.org", }, }; diff --git a/src/autodiscovery.js b/src/autodiscovery.js index e031173fe..900c01663 100644 --- a/src/autodiscovery.js +++ b/src/autodiscovery.js @@ -319,7 +319,7 @@ export class AutoDiscovery { // Supply the base_url to the caller because they may be ignoring // liveliness errors, like this one. - clientConfig["m.identity_server"].base_url = isUrl; + failingClientConfig["m.identity_server"].base_url = isUrl; return Promise.resolve(failingClientConfig); }