diff --git a/ui/core/app/routes/scopes.js b/ui/core/app/routes/scopes.js index 337b319c9..4f53d4955 100644 --- a/ui/core/app/routes/scopes.js +++ b/ui/core/app/routes/scopes.js @@ -5,14 +5,13 @@ export default class ScopesRoute extends Route { // =methods /** - * Attempt to load the specified scope from the API. This is allowed + * Attempt to load all scopes from the API. This is allowed * to fail, since in some cases the user may not have permission to read a * scope directly, but may have permission to read resources under it. - * If the scope fails to load, we still proceed using a temporary scope object - * consisting of only the specified ID. + * If scopes fails to load, we still proceed using an empty array. * @param {object} params * @param {string} params.scope_id - * @return {Promise{ScopeModel}} + * @return {Promise{[ScopeModel]}} */ model() { // NOTE: In the absence of a `scope_id` query parameter, this endpoint is diff --git a/ui/core/tests/acceptance/authentication-test.js b/ui/core/tests/acceptance/authentication-test.js index 3481337bb..f16a531bb 100644 --- a/ui/core/tests/acceptance/authentication-test.js +++ b/ui/core/tests/acceptance/authentication-test.js @@ -2,6 +2,7 @@ import { module, test } from 'qunit'; import { visit, currentURL, fillIn, click, find } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { Response } from 'miragejs'; import a11yAudit from 'ember-a11y-testing/test-support/audit'; import { currentSession, @@ -56,6 +57,26 @@ module('Acceptance | authentication', function (hooks) { assert.equal(currentURL(), authMethodAuthenticateURL); }); + test('visiting auth method when the scope cannot be loaded is still allowed', async function (assert) { + assert.expect(1); + orgScope.destroy(); + this.server.get('/scopes', ({ scopes }, { queryParams: { scope_id } }) => { + // Default parent scope is global + if (!scope_id) scope_id = 'global'; + const results = scopes.where(scope => { + return scope.scope ? scope.scope.id === scope_id : false + }); + if (!results.length) { + return new Response(404); + } else { + return results; + } + }); + await visit(authMethodAuthenticateURL); + await a11yAudit(); + assert.equal(currentURL(), authMethodAuthenticateURL); + }); + test('visiting any authentication parent route while unauthenticated redirects to first authenticate method', async function (assert) { assert.expect(3); await visit(indexURL);