6 files changed
+73
-33
No files matched your search
@@ -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
|
||||
|
||||
@@ -14,7 +14,7 @@ export default class ApplicationSessionStore extends LocalStorageSessionStore {
|
||||
*/
|
||||
persist(sessionData) {
|
||||
this.addTokenToAuthorization(sessionData);
|
||||
this.addScopeToSession(sessionData);
|
||||
//this.addScopeToSession(sessionData);
|
||||
return super.persist(...arguments);
|
||||
}
|
||||
|
||||
@@ -32,14 +32,6 @@ export default class ApplicationSessionStore extends LocalStorageSessionStore {
|
||||
if (token) adapter.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} sessionData
|
||||
*/
|
||||
addScopeToSession(sessionData) {
|
||||
const scope = get(this, 'scope');
|
||||
const authenticated = get(sessionData, 'authenticated');
|
||||
if (scope && authenticated) authenticated.scope = scope;
|
||||
}
|
||||
}
|
||||
|
||||
// import CookieSessionStore from 'auth/session-stores/cookie';
|
||||
|
||||
@@ -1 +1,22 @@
|
||||
{{outlet}}
|
||||
{{outlet}}
|
||||
|
||||
{{#unless @model}}
|
||||
<Rose::Layout::Sidebar as |sidebarLayout|>
|
||||
|
||||
<sidebarLayout.body>
|
||||
<main>
|
||||
<Rose::Layout::Centered>
|
||||
<Rose::Message
|
||||
@title={{t "auth.titles.no-scopes"}}
|
||||
@icon="alert-circle-outline"
|
||||
as |message|>
|
||||
<message.description>
|
||||
{{t "auth.descriptions.no-scopes"}}
|
||||
</message.description>
|
||||
</Rose::Message>
|
||||
</Rose::Layout::Centered>
|
||||
</main>
|
||||
</sidebarLayout.body>
|
||||
|
||||
</Rose::Layout::Sidebar>
|
||||
{{/unless}}
|
||||
@@ -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,
|
||||
@@ -49,6 +50,16 @@ module('Acceptance | authentication', function (hooks) {
|
||||
projectsURL = `/scopes/${orgScopeID}/projects`;
|
||||
});
|
||||
|
||||
|
||||
test('visiting scopes when there are none shows a message', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.server.get('/scopes', () => new Response(404));
|
||||
await visit(scopesURL);
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), scopesURL);
|
||||
assert.ok(find('.rose-message'));
|
||||
});
|
||||
|
||||
test('visiting auth methods authenticate route redirects to first auth method', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(authenticateURL);
|
||||
@@ -56,6 +67,35 @@ module('Acceptance | authentication', function (hooks) {
|
||||
assert.equal(currentURL(), authMethodAuthenticateURL);
|
||||
});
|
||||
|
||||
test('visiting auth methods authenticate route when there no methods shows a message', async function (assert) {
|
||||
assert.expect(2);
|
||||
authMethod.destroy()
|
||||
await visit(authenticateURL);
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), authenticateURL);
|
||||
assert.ok(find('.rose-message'));
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
-12
@@ -38,16 +38,4 @@ module('Unit | Session Store | application', function (hooks) {
|
||||
assert.equal(applicationAdapter.headers.foo, 'bar');
|
||||
assert.equal(applicationAdapter.headers.Authorization, 'Bearer token1234');
|
||||
});
|
||||
|
||||
test('it adds an org_id to the session data if authenticating within a scope', async function (assert) {
|
||||
assert.expect(2);
|
||||
let sessionData = {};
|
||||
sessionStore.set('scope', {});
|
||||
sessionStore.persist(sessionData);
|
||||
assert.notOk(sessionData.authenticated, 'There is no authenticated key');
|
||||
sessionData = { authenticated: {} };
|
||||
sessionStore.set('scope', { org: { id: 1 } });
|
||||
sessionStore.persist(sessionData);
|
||||
assert.equal(sessionData.authenticated.org_id, 1);
|
||||
});
|
||||
});
|
||||
@@ -6,16 +6,16 @@ actions:
|
||||
help: Need help?
|
||||
authenticate: Authenticate
|
||||
deauthenticate: Deauthenticate
|
||||
choose-org: Choose Org
|
||||
choose-different-org: Choose a Different Org
|
||||
choose-org: Choose Scope
|
||||
choose-different-org: Choose a Different Scope
|
||||
auth:
|
||||
titles:
|
||||
no-orgs: No Organizations Available
|
||||
no-scopes: No Scopes Available
|
||||
no-methods: No Authentication Method
|
||||
descriptions:
|
||||
no-orgs: No organizations were found. To authenticate, ask your administrator to create an organization and grant you access.
|
||||
no-methods: No authentication methods were found for this organization. Switch organizations and try again.
|
||||
choose-org: Choose an organization to authenticate.
|
||||
no-scopes: No scopes were found. To authenticate, ask your administrator to create an scope and grant you access.
|
||||
no-methods: No authentication methods were found for this scope. Switch scopes and try again.
|
||||
choose-org: Choose a scope to authenticate.
|
||||
authenticating-with-org: "You're authenticating with {name}."
|
||||
method-types:
|
||||
password: Password
|
||||
@@ -84,7 +84,7 @@ notify:
|
||||
save-success: Saved succesfully.
|
||||
delete-success: Deleted successfully.
|
||||
dev:
|
||||
default-org: Default Org
|
||||
default-org: Default Scope
|
||||
menu-item: Menu item
|
||||
button-menu-item: Button menu item
|
||||
section: Section
|
||||
|
||||
Reference in new issue
Block a user