diff --git a/addons/api/mirage/factories/scope.js b/addons/api/mirage/factories/scope.js index 76e647e52..14f7b6b75 100644 --- a/addons/api/mirage/factories/scope.js +++ b/addons/api/mirage/factories/scope.js @@ -8,6 +8,7 @@ import { trait } from 'miragejs'; import permissions from '../helpers/permissions'; import generateId from '../helpers/id'; import { faker } from '@faker-js/faker'; +import { TYPE_AUTH_METHOD_PASSWORD } from 'api/models/auth-method'; export default factory.extend({ type: 'global', @@ -108,4 +109,21 @@ export default factory.extend({ } }, }), + + withGlobalAuth: trait({ + afterCreate(record, server) { + if (record.type === 'global') { + const authMethod = server.create('auth-method', { + type: TYPE_AUTH_METHOD_PASSWORD, + scope: record, + }); + server.create('account', { + type: TYPE_AUTH_METHOD_PASSWORD, + full_name: 'admin', + scope: record, + authMethod, + }); + } + }, + }), }); diff --git a/addons/api/mirage/route-handlers/auth.js b/addons/api/mirage/route-handlers/auth.js index 56a66dc4a..83d2a0c85 100644 --- a/addons/api/mirage/route-handlers/auth.js +++ b/addons/api/mirage/route-handlers/auth.js @@ -13,7 +13,7 @@ const oidcRequiredAttempts = 3; const commandHandlers = { password: { - login: (payload, scopeAttrs) => { + login: (payload, auth_method_id, account_id, scopeAttrs) => { if (payload.attributes.login_name === 'error') { return new Response(400); } else { @@ -25,9 +25,9 @@ const commandHandlers = { scope: scopeAttrs, id: 'token123', token: 'thetokenstring', - account_id: 'authenticatedaccount', + account_id: account_id || 'authenticatedaccount', user_id: 'authenticateduser', - auth_method_id: 'authmethod123', + auth_method_id: auth_method_id || 'authmethod123', created_time: '', updated_time: '', last_used_time: '', @@ -61,7 +61,7 @@ const commandHandlers = { }, }, ), - token: (_, scopeAttrs) => { + token: (_, auth_method_id, account_id, scopeAttrs) => { oidcAttemptCounter++; if (oidcAttemptCounter < oidcRequiredAttempts) { return new Response(202); @@ -74,9 +74,9 @@ const commandHandlers = { scope: scopeAttrs, id: 'token123', token: 'thetokenstring', - account_id: '1', + account_id: account_id || '1', user_id: 'authenticateduser', - auth_method_id: 'authmethod123', + auth_method_id: auth_method_id || 'authmethod123', created_time: '', updated_time: '', last_used_time: '', @@ -90,7 +90,7 @@ const commandHandlers = { }; // Handles all custom methods on /auth-methods/:id route -export function authHandler({ scopes, authMethods }, request) { +export function authHandler({ scopes, authMethods, accounts }, request) { const [, id, method] = request.params.id_method.match( /(?.[^:]*):(?(.*))/, ); @@ -100,8 +100,14 @@ export function authHandler({ scopes, authMethods }, request) { const payload = JSON.parse(request.requestBody); const { command } = payload; const scope = scopes.find(authMethod.scopeId); + const account = accounts.where({ authMethodId: authMethod.id })?.models[0]; const scopeAttrs = this.serialize(scopes.find(scope.id)); - return commandHandlers[authMethod.type][command](payload, scopeAttrs); + return commandHandlers[authMethod.type][command]( + payload, + authMethod.id, + account?.id, + scopeAttrs, + ); } // TODO: this handler doesn't really belong here, but we already route diff --git a/addons/auth/addon/authenticators/base.js b/addons/auth/addon/authenticators/base.js index a48aaaeac..4d3771df4 100644 --- a/addons/auth/addon/authenticators/base.js +++ b/addons/auth/addon/authenticators/base.js @@ -101,7 +101,7 @@ export default class BaseAuthenticator extends SimpleAuthBaseAuthenticator { * @param {string} username * @return {object} */ - normalizeData(data, username) { + normalizeData(data) { // Pull fields up from `data.attributes` for easier access in JavaScript. // The `attributes` field exists on the Go side for its convenience but is // unnecessary here. @@ -109,7 +109,6 @@ export default class BaseAuthenticator extends SimpleAuthBaseAuthenticator { // Add booleans indicated the scope type data.isGlobal = data?.scope?.type === 'global'; data.isOrg = data?.scope?.type === 'org'; - if (username) data.username = username; return data; } diff --git a/addons/auth/addon/authenticators/password.js b/addons/auth/addon/authenticators/password.js index c584185d0..7cbf6b310 100644 --- a/addons/auth/addon/authenticators/password.js +++ b/addons/auth/addon/authenticators/password.js @@ -72,8 +72,6 @@ export default class PasswordAuthenticator extends BaseAuthenticator { fetch(authEndpointURL, { method: 'post', body }), ); const json = await response.json(); - return response.status < 400 - ? resolve(this.normalizeData(json, login_name)) - : reject(); + return response.status < 400 ? resolve(this.normalizeData(json)) : reject(); } } diff --git a/addons/core/translations/en-us.yaml b/addons/core/translations/en-us.yaml index 861961573..a60074f45 100644 --- a/addons/core/translations/en-us.yaml +++ b/addons/core/translations/en-us.yaml @@ -49,6 +49,7 @@ titles: project-actions: Project Actions user-menu: User Menu back-link: 'Back to {scope}' + authenticated: Signed in as descriptions: empty-set: There are no items to display yet. You may be able to add items or try back later. cluster-url-initialization: To get started, please enter your cluster URL diff --git a/e2e-tests/admin/tests/auth-method-oidc-vault.spec.js b/e2e-tests/admin/tests/auth-method-oidc-vault.spec.js index 0b43c90be..0fa2f3cc6 100644 --- a/e2e-tests/admin/tests/auth-method-oidc-vault.spec.js +++ b/e2e-tests/admin/tests/auth-method-oidc-vault.spec.js @@ -133,9 +133,7 @@ test( ).toBeVisible(); // Log back in as an admin - await page.getByRole('button', { name: 'User Menu' }).click(); - await page.getByRole('button', { name: 'Sign Out' }).click(); - await expect(page.getByRole('button', { name: 'Sign In' })).toBeVisible(); + await loginPage.logout(email); await loginPage.login(adminLoginName, adminPassword); await expect( page.getByRole('navigation', { name: 'breadcrumbs' }).getByText('Orgs'), diff --git a/ui/admin/app/routes/application.js b/ui/admin/app/routes/application.js index 73db9b6c6..1feddf8dc 100644 --- a/ui/admin/app/routes/application.js +++ b/ui/admin/app/routes/application.js @@ -75,6 +75,8 @@ export default class ApplicationRoute extends Route { if (userId && hostUrl) { await this.sqlite.setup(formatDbName(userId, hostUrl)); } + + await this.session.loadAuthenticatedAccount(); } } diff --git a/ui/admin/app/services/session.js b/ui/admin/app/services/session.js index 38f20429e..6f9967f40 100644 --- a/ui/admin/app/services/session.js +++ b/ui/admin/app/services/session.js @@ -5,11 +5,15 @@ import BaseSessionService from 'ember-simple-auth/services/session'; import { service } from '@ember/service'; +import { tracked } from '@glimmer/tracking'; import { formatDbName } from 'api/services/sqlite'; export default class SessionService extends BaseSessionService { @service sqlite; @service('browser/window') window; + @service store; + + @tracked username; /** * Extend ember simple auth's handleAuthentication method @@ -22,8 +26,31 @@ export default class SessionService extends BaseSessionService { await this.sqlite.setup(formatDbName(userId, hostUrl)); } + await this.loadAuthenticatedAccount(); + // We let ember-simple-auth handle transitioning back to the index after authentication. // This route can be configured in our environment config. super.handleAuthentication(...arguments); } + + /** + * Loads account used to authenticate so that it can be used to display + * the authenticated username. + */ + async loadAuthenticatedAccount() { + if (this.data?.authenticated?.account_id) { + try { + const account = await this.store.findRecord( + 'account', + this.data.authenticated.account_id, + ); + this.username = account.accountName; + } catch (e) { + // We are purposefully ignoring errors since loading the + // authenticated account should not block a user because + // account information is for populating a username. + console.error(e); + } + } + } } diff --git a/ui/admin/app/styles/app.scss b/ui/admin/app/styles/app.scss index d3b50eba9..af02e4632 100644 --- a/ui/admin/app/styles/app.scss +++ b/ui/admin/app/styles/app.scss @@ -1025,3 +1025,18 @@ .injected-app-credential-alert { margin-bottom: 1rem; } + +// User menu dropdown in global side nav +.user-menu-dropdown { + max-width: 125px; + + &__toggle-button { + width: 100%; + + .hds-dropdown-toggle-button__text { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + } +} diff --git a/ui/admin/app/templates/application.hbs b/ui/admin/app/templates/application.hbs index ca787e70d..a371f54e1 100644 --- a/ui/admin/app/templates/application.hbs +++ b/ui/admin/app/templates/application.hbs @@ -71,41 +71,73 @@ {{/if}} - - {{#if this.session.data.authenticated.username}} + {{#if this.session.username}} + - {{else}} + + + + + {{t + 'actions.change-password' + }} + + + {{t + 'actions.deauthenticate' + }} + + + + {{#each this.themes as |theme|}} + + {{t (concat 'themes.' theme.label)}} + + {{/each}} + + {{else}} + - {{/if}} + {{t + 'actions.change-password' + }} + - {{t - 'actions.change-password' - }} - + {{t + 'actions.deauthenticate' + }} + - {{t - 'actions.deauthenticate' - }} - - - - {{#each this.themes as |theme|}} - - {{t (concat 'themes.' theme.label)}} - - {{/each}} - + + {{#each this.themes as |theme|}} + + {{t (concat 'themes.' theme.label)}} + + {{/each}} + + {{/if}} diff --git a/ui/admin/tests/acceptance/accounts/change-password-test.js b/ui/admin/tests/acceptance/accounts/change-password-test.js index 80e54301c..ae3b35261 100644 --- a/ui/admin/tests/acceptance/accounts/change-password-test.js +++ b/ui/admin/tests/acceptance/accounts/change-password-test.js @@ -6,25 +6,19 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { - authenticateSession, - invalidateSession, -} from 'ember-simple-auth/test-support'; +import { invalidateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | accounts | change password', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, }, account: null, @@ -35,7 +29,6 @@ module('Acceptance | accounts | change password', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -46,10 +39,7 @@ module('Acceptance | accounts | change password', function (hooks) { instances.account = this.server.create('account', { scope: instances.scopes.org, }); - await authenticateSession({ - account_id: instances.account.id, - username: 'admin', - }); + // Generate route URLs for resources urls.orgScope = `/scopes/${instances.scopes.org.id}`; urls.changePassword = `/account/change-password`; diff --git a/ui/admin/tests/acceptance/accounts/create-test.js b/ui/admin/tests/acceptance/accounts/create-test.js index 7377d4261..41cd2cc2b 100644 --- a/ui/admin/tests/acceptance/accounts/create-test.js +++ b/ui/admin/tests/acceptance/accounts/create-test.js @@ -6,20 +6,16 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, find, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | accounts | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { - global: null, org: null, }, authMethods: null, @@ -36,13 +32,12 @@ module('Acceptance | accounts | create', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, }); instances.authMethod = this.server.create('auth-method', { + type: 'password', scope: instances.scopes.org, }); instances.account = this.server.create('account', { diff --git a/ui/admin/tests/acceptance/accounts/delete-test.js b/ui/admin/tests/acceptance/accounts/delete-test.js index 3bb142497..b06981cf6 100644 --- a/ui/admin/tests/acceptance/accounts/delete-test.js +++ b/ui/admin/tests/acceptance/accounts/delete-test.js @@ -6,20 +6,16 @@ import { module, test } from 'qunit'; import { visit, click, find } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | accounts | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -34,8 +30,6 @@ module('Acceptance | accounts | delete', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/accounts/list-test.js b/ui/admin/tests/acceptance/accounts/list-test.js index bda43162d..1d8013a1a 100644 --- a/ui/admin/tests/acceptance/accounts/list-test.js +++ b/ui/admin/tests/acceptance/accounts/list-test.js @@ -6,19 +6,15 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | accounts | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -33,8 +29,6 @@ module('Acceptance | accounts | list', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/accounts/read-test.js b/ui/admin/tests/acceptance/accounts/read-test.js index 6a5cdfdbc..44ccf07d6 100644 --- a/ui/admin/tests/acceptance/accounts/read-test.js +++ b/ui/admin/tests/acceptance/accounts/read-test.js @@ -6,18 +6,14 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | accounts | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -31,8 +27,6 @@ module('Acceptance | accounts | read', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/accounts/set-password-test.js b/ui/admin/tests/acceptance/accounts/set-password-test.js index 63cd1ab90..b605e1983 100644 --- a/ui/admin/tests/acceptance/accounts/set-password-test.js +++ b/ui/admin/tests/acceptance/accounts/set-password-test.js @@ -6,19 +6,15 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | accounts | set password', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -32,16 +28,16 @@ module('Acceptance | accounts | set password', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, }); instances.authMethod = this.server.create('auth-method', { + type: 'password', scope: instances.scopes.org, }); instances.account = this.server.create('account', { + type: 'password', scope: instances.scopes.org, authMethod: instances.authMethod, }); diff --git a/ui/admin/tests/acceptance/accounts/update-test.js b/ui/admin/tests/acceptance/accounts/update-test.js index 2ec182af2..f99bdeb5c 100644 --- a/ui/admin/tests/acceptance/accounts/update-test.js +++ b/ui/admin/tests/acceptance/accounts/update-test.js @@ -6,19 +6,15 @@ import { module, test } from 'qunit'; import { visit, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | accounts | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -32,8 +28,6 @@ module('Acceptance | accounts | update', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -69,7 +63,7 @@ module('Acceptance | accounts | update', function (hooks) { await click(commonSelectors.SAVE_BTN); assert.strictEqual( - this.server.schema.accounts.all().models[0].name, + this.server.schema.accounts.find(instances.account.id).name, commonSelectors.FIELD_NAME_VALUE, ); }); @@ -95,11 +89,11 @@ module('Acceptance | accounts | update', function (hooks) { await click(commonSelectors.SAVE_BTN); assert.strictEqual( - this.server.schema.accounts.all().models[0].name, + this.server.schema.accounts.find(instances.account.id).name, commonSelectors.FIELD_NAME_VALUE, ); assert.strictEqual( - this.server.schema.accounts.all().models[0].description, + this.server.schema.accounts.find(instances.account.id).description, commonSelectors.FIELD_DESCRIPTION_VALUE, ); }); diff --git a/ui/admin/tests/acceptance/aliases/create-test.js b/ui/admin/tests/acceptance/aliases/create-test.js index 89c33dd7f..45107eb27 100644 --- a/ui/admin/tests/acceptance/aliases/create-test.js +++ b/ui/admin/tests/acceptance/aliases/create-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { click, currentURL, fillIn, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; @@ -16,7 +14,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | aliases | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let features; @@ -35,14 +32,13 @@ module('Acceptance | aliases | create', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); urls.globalScope = `/scopes/global`; urls.aliases = `${urls.globalScope}/aliases`; urls.newAlias = `${urls.aliases}/new`; getAliasCount = () => this.server.schema.aliases.all().models.length; features = this.owner.lookup('service:features'); features.enable('ssh-session-recording'); - await authenticateSession({ username: 'admin' }); }); test('users can create a new alias with host and target info', async function (assert) { diff --git a/ui/admin/tests/acceptance/aliases/delete-test.js b/ui/admin/tests/acceptance/aliases/delete-test.js index 14b1976b3..cfe12bd03 100644 --- a/ui/admin/tests/acceptance/aliases/delete-test.js +++ b/ui/admin/tests/acceptance/aliases/delete-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { click, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | aliases | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let aliasCount; @@ -36,8 +33,7 @@ module('Acceptance | aliases | delete', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/aliases/list-test.js b/ui/admin/tests/acceptance/aliases/list-test.js index 311672f0e..9481db7a8 100644 --- a/ui/admin/tests/acceptance/aliases/list-test.js +++ b/ui/admin/tests/acceptance/aliases/list-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, click, currentURL, waitFor, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { faker } from '@faker-js/faker'; @@ -16,7 +14,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | aliases | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let intl; @@ -41,7 +38,7 @@ module('Acceptance | aliases | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -66,8 +63,6 @@ module('Acceptance | aliases | list', function (hooks) { urls.alias = `${urls.aliases}/${instances.alias.id}`; urls.aliasWithTarget = `${urls.aliases}/${instances.aliasWithTarget.id}`; intl = this.owner.lookup('service:intl'); - - await authenticateSession({}); }); test('users can navigate to aliases with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/aliases/read-test.js b/ui/admin/tests/acceptance/aliases/read-test.js index 55ce9ec9e..ec124ad6e 100644 --- a/ui/admin/tests/acceptance/aliases/read-test.js +++ b/ui/admin/tests/acceptance/aliases/read-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { click, currentURL, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | aliases | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { @@ -33,7 +30,7 @@ module('Acceptance | aliases | read', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -45,8 +42,6 @@ module('Acceptance | aliases | read', function (hooks) { urls.aliases = `${urls.globalScope}/aliases`; urls.alias = `${urls.aliases}/${instances.alias.id}`; urls.unknownAlias = `${urls.aliases}/foo`; - - await authenticateSession({ username: 'admin' }); }); test('visiting an alias', async function (assert) { diff --git a/ui/admin/tests/acceptance/aliases/update-test.js b/ui/admin/tests/acceptance/aliases/update-test.js index 1f4a96ad5..3fc6bafbb 100644 --- a/ui/admin/tests/acceptance/aliases/update-test.js +++ b/ui/admin/tests/acceptance/aliases/update-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { click, fillIn, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | aliases | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let aliasCount; @@ -37,7 +34,7 @@ module('Acceptance | aliases | update', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -53,11 +50,9 @@ module('Acceptance | aliases | update', function (hooks) { urls.aliases = `${urls.globalScope}/aliases`; urls.alias = `${urls.aliases}/${instances.alias.id}`; aliasCount = () => this.server.schema.aliases.all().models.length; - - await authenticateSession({}); }); - test('users can update an exisiting alias', async function (assert) { + test('users can update an existing alias', async function (assert) { setRunOptions({ rules: { 'color-contrast': { diff --git a/ui/admin/tests/acceptance/auth-methods/create-test.js b/ui/admin/tests/acceptance/auth-methods/create-test.js index 9eae7412b..ba75f6391 100644 --- a/ui/admin/tests/acceptance/auth-methods/create-test.js +++ b/ui/admin/tests/acceptance/auth-methods/create-test.js @@ -6,17 +6,14 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn, select } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | auth-methods | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getAuthMethodsCount; @@ -24,7 +21,6 @@ module('Acceptance | auth-methods | create', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -41,7 +37,6 @@ module('Acceptance | auth-methods | create', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); instances.orgScope = this.server.create( 'scope', { diff --git a/ui/admin/tests/acceptance/auth-methods/delete-test.js b/ui/admin/tests/acceptance/auth-methods/delete-test.js index e20a65167..438a9b3f5 100644 --- a/ui/admin/tests/acceptance/auth-methods/delete-test.js +++ b/ui/admin/tests/acceptance/auth-methods/delete-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_AUTH_METHOD_LDAP } from 'api/models/auth-method'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; @@ -17,7 +15,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | auth-methods | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -25,7 +22,6 @@ module('Acceptance | auth-methods | delete', function (hooks) { const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -40,8 +36,6 @@ module('Acceptance | auth-methods | delete', function (hooks) { hooks.beforeEach(async function () { // Setup Mirage mock resources for this test - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/auth-methods/list-test.js b/ui/admin/tests/acceptance/auth-methods/list-test.js index 5d4bc3554..fcdc0c8ed 100644 --- a/ui/admin/tests/acceptance/auth-methods/list-test.js +++ b/ui/admin/tests/acceptance/auth-methods/list-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, click, waitFor, fillIn, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { faker } from '@faker-js/faker'; import { TYPE_AUTH_METHOD_PASSWORD, @@ -20,12 +18,10 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | auth-methods | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, }, passwordAuthMethod: null, @@ -41,7 +37,6 @@ module('Acceptance | auth-methods | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create( 'scope', { @@ -63,8 +58,6 @@ module('Acceptance | auth-methods | list', function (hooks) { urls.authMethods = `/scopes/${instances.scopes.org.id}/auth-methods`; urls.passwordAuthMethod = `${urls.authMethods}/${instances.passwordAuthMethod.id}`; urls.oidcAuthMethod = `${urls.authMethods}/${instances.oidcAuthMethod.id}`; - - await authenticateSession({}); }); test('users can navigate to auth methods with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/auth-methods/oidc-test.js b/ui/admin/tests/acceptance/auth-methods/oidc-test.js index fe3edbb14..294157af3 100644 --- a/ui/admin/tests/acceptance/auth-methods/oidc-test.js +++ b/ui/admin/tests/acceptance/auth-methods/oidc-test.js @@ -6,19 +6,15 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; module('Acceptance | auth-methods | oidc', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -30,8 +26,6 @@ module('Acceptance | auth-methods | oidc', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/auth-methods/read-test.js b/ui/admin/tests/acceptance/auth-methods/read-test.js index 34fe34550..1ef0d3eec 100644 --- a/ui/admin/tests/acceptance/auth-methods/read-test.js +++ b/ui/admin/tests/acceptance/auth-methods/read-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_AUTH_METHOD_LDAP, TYPE_AUTH_METHOD_OIDC, @@ -20,7 +18,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | auth-methods | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { @@ -44,8 +41,7 @@ module('Acceptance | auth-methods | read', function (hooks) { hooks.beforeEach(async function () { // Setup Mirage mock resources for this test - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/auth-methods/update-test.js b/ui/admin/tests/acceptance/auth-methods/update-test.js index be390fc04..4b263294b 100644 --- a/ui/admin/tests/acceptance/auth-methods/update-test.js +++ b/ui/admin/tests/acceptance/auth-methods/update-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { visit, click, fillIn, select, findAll } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_AUTH_METHOD_OIDC, TYPE_AUTH_METHOD_LDAP, @@ -20,14 +18,12 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | auth-methods | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -43,8 +39,6 @@ module('Acceptance | auth-methods | update', function (hooks) { hooks.beforeEach(async function () { // Setup Mirage mock resources for this test - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -89,7 +83,7 @@ module('Acceptance | auth-methods | update', function (hooks) { await click(commonSelectors.SAVE_BTN); assert.strictEqual( - this.server.schema.authMethods.first().name, + this.server.schema.authMethods.find(instances.authMethod.id).name, commonSelectors.FIELD_NAME_VALUE, ); }); diff --git a/ui/admin/tests/acceptance/authentication-test.js b/ui/admin/tests/acceptance/authentication-test.js index 6aa921374..c72ae3e46 100644 --- a/ui/admin/tests/acceptance/authentication-test.js +++ b/ui/admin/tests/acceptance/authentication-test.js @@ -12,7 +12,6 @@ import { getRootElement, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { setupIntl } from 'ember-intl/test-support'; import { Response } from 'miragejs'; @@ -30,7 +29,6 @@ import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | authentication', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); setupIntl(hooks, 'en-us'); @@ -43,8 +41,10 @@ module('Acceptance | authentication', function (hooks) { let orgScopeURL; let scope; let globalAuthMethod; + let globalAccount; let globalAuthMethodID; let authMethod; + let account; let authMethodID; let authMethodOIDC; let authMethodOIDCID; @@ -69,7 +69,9 @@ module('Acceptance | authentication', function (hooks) { hooks.beforeEach(async function () { await invalidateSession(); indexURL = '/'; - globalScope = this.server.create('scope', { id: 'global' }); + globalScope = this.server.schema.scopes.find('global'); + globalAuthMethod = this.server.schema.authMethods.first(); + globalAccount = this.server.schema.accounts.first(); orgScope1 = this.server.create( 'scope', { @@ -96,18 +98,22 @@ module('Acceptance | authentication', function (hooks) { 'withChildren', ); scope = { id: orgScope1.id, type: orgScope1.type }; - globalAuthMethod = this.server.create('auth-method', { - scope: globalScope, - type: TYPE_AUTH_METHOD_PASSWORD, - }); authMethod = this.server.create('auth-method', { scope: orgScope1, type: TYPE_AUTH_METHOD_PASSWORD, }); + account = this.server.create('account', { + scope: orgScope1, + authMethod, + }); authMethodOIDC = this.server.create('auth-method', { scope: orgScope2, type: TYPE_AUTH_METHOD_OIDC, }); + this.server.create('account', { + scope: orgScope2, + authMethod: authMethodOIDC, + }); orgScopeID = orgScope1.id; globalAuthMethodID = globalAuthMethod.id; authMethodID = authMethod.id; @@ -250,7 +256,7 @@ module('Acceptance | authentication', function (hooks) { }); test('visiting any authentication parent route while already authenticated with an org redirects to projects', async function (assert) { - await authenticateSession({ scope }); + await authenticateSession({ scope, account_id: account.id }); await visit(indexURL); assert.strictEqual(currentURL(), projectsURL); @@ -276,6 +282,7 @@ module('Acceptance | authentication', function (hooks) { test('visiting index or scopes routes while already authenticated with global redirects to orgs', async function (assert) { await authenticateSession({ scope: { id: globalScope.id, type: globalScope.type }, + account_id: globalAccount.id, }); await visit(indexURL); @@ -340,6 +347,7 @@ module('Acceptance | authentication', function (hooks) { test('401 responses result in deauthentication', async function (assert) { await authenticateSession({ scope: { id: globalScope.id, type: globalScope.type }, + account_id: globalAccount.id, }); await visit(orgsURL); @@ -360,6 +368,7 @@ module('Acceptance | authentication', function (hooks) { test('color theme is applied from session data', async function (assert) { await authenticateSession({ scope: { id: globalScope.id, type: globalScope.type }, + account_id: globalAccount.id, }); currentSession().set('data.theme', 'light'); await visit(orgsURL); diff --git a/ui/admin/tests/acceptance/credential-library/create-test.js b/ui/admin/tests/acceptance/credential-library/create-test.js index 3851eec3f..5bb56fa55 100644 --- a/ui/admin/tests/acceptance/credential-library/create-test.js +++ b/ui/admin/tests/acceptance/credential-library/create-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, click, fillIn, currentURL, select } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import { TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE, @@ -21,7 +19,6 @@ import { TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN } from 'api/models/credential' module('Acceptance | credential-libraries | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -30,7 +27,6 @@ module('Acceptance | credential-libraries | create', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -49,7 +45,6 @@ module('Acceptance | credential-libraries | create', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -83,7 +78,6 @@ module('Acceptance | credential-libraries | create', function (hooks) { credentialType: TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN, }).length; }; - await authenticateSession({ username: 'admin' }); featuresService = this.owner.lookup('service:features'); }); diff --git a/ui/admin/tests/acceptance/credential-library/delete-test.js b/ui/admin/tests/acceptance/credential-library/delete-test.js index 90e98b4c4..52b824777 100644 --- a/ui/admin/tests/acceptance/credential-library/delete-test.js +++ b/ui/admin/tests/acceptance/credential-library/delete-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import { resolve, reject } from 'rsvp'; import sinon from 'sinon'; @@ -23,7 +21,6 @@ import { TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN } from 'api/models/credential' module('Acceptance | credential-libraries | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getCredentialLibraryCount; @@ -32,7 +29,6 @@ module('Acceptance | credential-libraries | delete', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -51,7 +47,6 @@ module('Acceptance | credential-libraries | delete', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -106,7 +101,6 @@ module('Acceptance | credential-libraries | delete', function (hooks) { type: TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP, }).length; }; - await authenticateSession({}); }); test('can delete resource', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-library/list-test.js b/ui/admin/tests/acceptance/credential-library/list-test.js index c7ae5ece1..127333bf7 100644 --- a/ui/admin/tests/acceptance/credential-library/list-test.js +++ b/ui/admin/tests/acceptance/credential-library/list-test.js @@ -6,22 +6,18 @@ import { module, test } from 'qunit'; import { visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP } from 'api/models/credential-library'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | credential-libraries | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; const instances = { scopes: { - global: null, org: null, project: null, }, @@ -35,7 +31,6 @@ module('Acceptance | credential-libraries | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -64,7 +59,6 @@ module('Acceptance | credential-libraries | list', function (hooks) { urls.credentialStore = `${urls.credentialStores}/${instances.credentialStore.id}`; urls.credentialLibraries = `${urls.credentialStore}/credential-libraries`; urls.vaultLDAPCredentialLibrary = `${urls.credentialLibraries}/${instances.vaultLDAPCredentialLibrary.id}`; - await authenticateSession({}); featuresService = this.owner.lookup('service:features'); }); diff --git a/ui/admin/tests/acceptance/credential-library/read-test.js b/ui/admin/tests/acceptance/credential-library/read-test.js index 37ede3445..b15308f6e 100644 --- a/ui/admin/tests/acceptance/credential-library/read-test.js +++ b/ui/admin/tests/acceptance/credential-library/read-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE, TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC, @@ -20,12 +18,10 @@ import { TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN } from 'api/models/credential' module('Acceptance | credential-libraries | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -46,7 +42,6 @@ module('Acceptance | credential-libraries | read', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -72,7 +67,6 @@ module('Acceptance | credential-libraries | read', function (hooks) { urls.credentialLibrary = `${urls.credentialLibraries}/${instances.credentialLibrary.id}`; urls.newCredentialLibrary = `${urls.credentialLibraries}/new`; urls.unknownCredentialLibrary = `${urls.credentialLibraries}/foo`; - await authenticateSession({ username: 'admin' }); }); test('can navigate to resource', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-library/update-test.js b/ui/admin/tests/acceptance/credential-library/update-test.js index 58bf2d9dd..8366c7939 100644 --- a/ui/admin/tests/acceptance/credential-library/update-test.js +++ b/ui/admin/tests/acceptance/credential-library/update-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, click, fillIn, currentURL, select } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import { TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE, @@ -22,12 +20,10 @@ import { TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN } from 'api/models/credential' module('Acceptance | credential-libraries | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -48,7 +44,6 @@ module('Acceptance | credential-libraries | update', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -93,7 +88,6 @@ module('Acceptance | credential-libraries | update', function (hooks) { urls.unknownCredentialLibrary = `${urls.credentialLibraries}/foo`; urls.usernamePasswordDomainCredentialLibrary = `${urls.credentialLibraries}/${instances.usernamePasswordDomainCredentialLibrary.id}`; urls.vaultLDAPCredentialLibrary = `${urls.credentialLibraries}/${instances.vaultLDAPCredentialLibrary.id}`; - await authenticateSession({}); }); test('cannot update resource without proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-store/create-test.js b/ui/admin/tests/acceptance/credential-store/create-test.js index f00648522..eae5932cc 100644 --- a/ui/admin/tests/acceptance/credential-store/create-test.js +++ b/ui/admin/tests/acceptance/credential-store/create-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; @@ -16,7 +14,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | credential-stores | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -26,7 +23,6 @@ module('Acceptance | credential-stores | create', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -39,7 +35,6 @@ module('Acceptance | credential-stores | create', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -63,7 +58,6 @@ module('Acceptance | credential-stores | create', function (hooks) { return this.server.schema.credentialStores.where({ type: 'vault' }).models .length; }; - await authenticateSession({}); featuresService = this.owner.lookup('service:features'); }); diff --git a/ui/admin/tests/acceptance/credential-store/credentials/create-test.js b/ui/admin/tests/acceptance/credential-store/credentials/create-test.js index 4a12c150b..fc33c0ae0 100644 --- a/ui/admin/tests/acceptance/credential-store/credentials/create-test.js +++ b/ui/admin/tests/acceptance/credential-store/credentials/create-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; @@ -18,7 +16,6 @@ module( 'Acceptance | credential-stores | credentials | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getCredentialsCount; @@ -86,7 +83,6 @@ module( type: 'username_password_domain', }).length; }; - await authenticateSession({}); }); test('users can create a new username & password credential', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-store/credentials/delete-test.js b/ui/admin/tests/acceptance/credential-store/credentials/delete-test.js index 108f01546..edb7369a4 100644 --- a/ui/admin/tests/acceptance/credential-store/credentials/delete-test.js +++ b/ui/admin/tests/acceptance/credential-store/credentials/delete-test.js @@ -5,9 +5,7 @@ import { module, test } from 'qunit'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { click, currentURL, visit } from '@ember/test-helpers'; import { Response } from 'miragejs'; import * as selectors from './selectors'; @@ -23,7 +21,6 @@ module( 'Acceptance | credential-stores | credentials | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getUsernamePasswordCredentialCount; @@ -127,7 +124,6 @@ module( type: TYPE_CREDENTIAL_USERNAME_PASSWORD_DOMAIN, }).length; }; - await authenticateSession({}); }); test('can delete username & password credential', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-store/credentials/list-test.js b/ui/admin/tests/acceptance/credential-store/credentials/list-test.js index 7d519e621..97d5c7f53 100644 --- a/ui/admin/tests/acceptance/credential-store/credentials/list-test.js +++ b/ui/admin/tests/acceptance/credential-store/credentials/list-test.js @@ -6,16 +6,13 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as credentialStoreSelectors from '../selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | credential-stores | credentials | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { @@ -72,7 +69,6 @@ module('Acceptance | credential-stores | credentials | list', function (hooks) { urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`; urls.credentials = `${urls.staticCredentialStore}/credentials`; urls.newCredential = `${urls.staticCredentialStore}/credentials/new`; - await authenticateSession({}); }); test('Users can navigate to credentials with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-store/credentials/read-test.js b/ui/admin/tests/acceptance/credential-store/credentials/read-test.js index 716893152..1ef30fdae 100644 --- a/ui/admin/tests/acceptance/credential-store/credentials/read-test.js +++ b/ui/admin/tests/acceptance/credential-store/credentials/read-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, currentURL, find, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | credential-stores | credentials | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -91,7 +88,6 @@ module('Acceptance | credential-stores | credentials | read', function (hooks) { urls.jsonCredential = `${urls.credentials}/${instances.jsonCredential.id}`; urls.usernamePasswordDomainCredential = `${urls.credentials}/${instances.usernamePasswordDomainCredential.id}`; urls.unknownCredential = `${urls.credentials}/foo`; - await authenticateSession({ username: 'admin' }); featuresService = this.owner.lookup('service:features'); }); diff --git a/ui/admin/tests/acceptance/credential-store/credentials/update-test.js b/ui/admin/tests/acceptance/credential-store/credentials/update-test.js index 6bd1076df..2f3f1a4cf 100644 --- a/ui/admin/tests/acceptance/credential-store/credentials/update-test.js +++ b/ui/admin/tests/acceptance/credential-store/credentials/update-test.js @@ -13,10 +13,8 @@ import { waitUntil, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; @@ -25,14 +23,12 @@ module( 'Acceptance | credential-stores | credentials | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; const instances = { scopes: { - global: null, org: null, project: null, }, @@ -78,7 +74,6 @@ module( hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -126,7 +121,6 @@ module( urls.usernamePasswordDomainCredential = `${urls.credentials}/${instances.usernamePasswordDomainCredential.id}`; featuresService = this.owner.lookup('service:features'); - await authenticateSession({}); }); test('can save changes to existing username & password credential', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-store/delete-test.js b/ui/admin/tests/acceptance/credential-store/delete-test.js index dae5cd88c..c045634da 100644 --- a/ui/admin/tests/acceptance/credential-store/delete-test.js +++ b/ui/admin/tests/acceptance/credential-store/delete-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import { resolve, reject } from 'rsvp'; import sinon from 'sinon'; @@ -18,7 +16,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | credential-stores | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getStaticCredentialStoresCount; @@ -26,7 +23,6 @@ module('Acceptance | credential-stores | delete', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -40,7 +36,6 @@ module('Acceptance | credential-stores | delete', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -70,7 +65,6 @@ module('Acceptance | credential-stores | delete', function (hooks) { return this.server.schema.credentialStores.where({ type: 'vault' }).models .length; }; - await authenticateSession({}); }); test('can delete credential store of type vault', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-store/list-test.js b/ui/admin/tests/acceptance/credential-store/list-test.js index 00b8da655..3ffa030e3 100644 --- a/ui/admin/tests/acceptance/credential-store/list-test.js +++ b/ui/admin/tests/acceptance/credential-store/list-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { click, currentURL, fillIn, visit, waitFor } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { faker } from '@faker-js/faker'; import { TYPE_CREDENTIAL_STORE_STATIC, @@ -20,12 +18,10 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | credential-stores | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -42,7 +38,6 @@ module('Acceptance | credential-stores | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -67,7 +62,6 @@ module('Acceptance | credential-stores | list', function (hooks) { const featuresService = this.owner.lookup('service:features'); featuresService.enable('static-credentials'); - await authenticateSession({}); }); test('users can navigate to credential-stores with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-store/read-test.js b/ui/admin/tests/acceptance/credential-store/read-test.js index 61792c5fe..e60dfd4c3 100644 --- a/ui/admin/tests/acceptance/credential-store/read-test.js +++ b/ui/admin/tests/acceptance/credential-store/read-test.js @@ -6,22 +6,18 @@ import { module, test } from 'qunit'; import { click, currentURL, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | credential-stores | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; const instances = { scopes: { - global: null, org: null, project: null, }, @@ -39,7 +35,6 @@ module('Acceptance | credential-stores | read', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -63,7 +58,6 @@ module('Acceptance | credential-stores | read', function (hooks) { urls.vaultCredentialStore = `${urls.credentialStores}/${instances.vaultCredentialStore.id}`; urls.unknownCredentialStore = `${urls.credentialStores}/foo`; - await authenticateSession({ username: 'admin' }); featuresService = this.owner.lookup('service:features'); }); diff --git a/ui/admin/tests/acceptance/credential-store/update-test.js b/ui/admin/tests/acceptance/credential-store/update-test.js index dcc61ed9c..0d711ea9d 100644 --- a/ui/admin/tests/acceptance/credential-store/update-test.js +++ b/ui/admin/tests/acceptance/credential-store/update-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; @@ -16,12 +14,10 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | credential-stores | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -36,7 +32,6 @@ module('Acceptance | credential-stores | update', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -60,7 +55,6 @@ module('Acceptance | credential-stores | update', function (hooks) { urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`; urls.workerFilter = `${urls.credentialStores}/${instances.vaultCredentialStore.id}/worker-filter`; urls.editWorkerFilter = `${urls.credentialStores}/${instances.vaultCredentialStore.id}/edit-worker-filter`; - await authenticateSession({}); // Enable feature flag const featuresService = this.owner.lookup('service:features'); diff --git a/ui/admin/tests/acceptance/develop-test.js b/ui/admin/tests/acceptance/develop-test.js index 5c3ff3f58..0116329e1 100644 --- a/ui/admin/tests/acceptance/develop-test.js +++ b/ui/admin/tests/acceptance/develop-test.js @@ -6,13 +6,10 @@ import { module, test } from 'qunit'; import { visit, getContext } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; module('Acceptance | develop', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -21,12 +18,10 @@ module('Acceptance | develop', function (hooks) { hooks.beforeEach(async function () { const { owner } = getContext(); featuresService = owner.lookup('service:features'); - this.server.create('scope', { id: 'global' }); this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, }); - await authenticateSession({}); }); test('edition toggle is hidden when `dev-edition-toggle` is false', async function (assert) { diff --git a/ui/admin/tests/acceptance/groups/create-test.js b/ui/admin/tests/acceptance/groups/create-test.js index 17bf3f4c2..a06f1067a 100644 --- a/ui/admin/tests/acceptance/groups/create-test.js +++ b/ui/admin/tests/acceptance/groups/create-test.js @@ -6,16 +6,13 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | groups | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let groupsCount; @@ -33,7 +30,6 @@ module('Acceptance | groups | create', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); instances.scopes.org = this.server.create( 'scope', { diff --git a/ui/admin/tests/acceptance/groups/delete-test.js b/ui/admin/tests/acceptance/groups/delete-test.js index 99deca0a8..7151e733c 100644 --- a/ui/admin/tests/acceptance/groups/delete-test.js +++ b/ui/admin/tests/acceptance/groups/delete-test.js @@ -6,22 +6,18 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | groups | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); let getGroupsCount; const instances = { scopes: { - global: null, org: null, }, group: null, @@ -34,8 +30,6 @@ module('Acceptance | groups | delete', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/groups/list-test.js b/ui/admin/tests/acceptance/groups/list-test.js index fd63fc117..677dd2c96 100644 --- a/ui/admin/tests/acceptance/groups/list-test.js +++ b/ui/admin/tests/acceptance/groups/list-test.js @@ -13,15 +13,12 @@ import { currentURL, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { faker } from '@faker-js/faker'; module('Acceptance | groups | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const SEARCH_INPUT_SELECTOR = '.search-filtering [type="search"]'; @@ -29,7 +26,6 @@ module('Acceptance | groups | list', function (hooks) { const instances = { scopes: { - global: null, org: null, }, group1: null, @@ -44,7 +40,6 @@ module('Acceptance | groups | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create( 'scope', { @@ -64,7 +59,6 @@ module('Acceptance | groups | list', function (hooks) { urls.groups = `/scopes/${instances.scopes.org.id}/groups`; urls.group1 = `${urls.groups}/${instances.group1.id}`; urls.group2 = `${urls.groups}/${instances.group2.id}`; - await authenticateSession({}); }); test('can navigate to groups with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/groups/members-test.js b/ui/admin/tests/acceptance/groups/members-test.js index 7b90b9632..b2c355731 100644 --- a/ui/admin/tests/acceptance/groups/members-test.js +++ b/ui/admin/tests/acceptance/groups/members-test.js @@ -6,22 +6,18 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | groups | members', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, }, group: null, @@ -36,8 +32,6 @@ module('Acceptance | groups | members', function (hooks) { let membersCount; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/groups/read-test.js b/ui/admin/tests/acceptance/groups/read-test.js index 6b1627617..11a250a9d 100644 --- a/ui/admin/tests/acceptance/groups/read-test.js +++ b/ui/admin/tests/acceptance/groups/read-test.js @@ -6,20 +6,16 @@ import { module, test } from 'qunit'; import { visit, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | groups | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, }, group: null, @@ -32,8 +28,6 @@ module('Acceptance | groups | read', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/groups/update-test.js b/ui/admin/tests/acceptance/groups/update-test.js index 1484e734a..0a9875e35 100644 --- a/ui/admin/tests/acceptance/groups/update-test.js +++ b/ui/admin/tests/acceptance/groups/update-test.js @@ -6,14 +6,11 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | groups | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { @@ -30,8 +27,6 @@ module('Acceptance | groups | update', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/host-catalogs/create-test.js b/ui/admin/tests/acceptance/host-catalogs/create-test.js index c51819a43..9de37e301 100644 --- a/ui/admin/tests/acceptance/host-catalogs/create-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/create-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; @@ -16,7 +14,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -25,7 +22,6 @@ module('Acceptance | host-catalogs | create', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -46,7 +42,6 @@ module('Acceptance | host-catalogs | create', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.orgScope = this.server.create( 'scope', { @@ -85,8 +80,6 @@ module('Acceptance | host-catalogs | create', function (hooks) { // Generate resource counter getHostCatalogCount = () => this.server.schema.hostCatalogs.all().models.length; - - await authenticateSession({}); }); test('Users can create new static host catalogs', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/delete-test.js b/ui/admin/tests/acceptance/host-catalogs/delete-test.js index e03e4f05b..862d6292d 100644 --- a/ui/admin/tests/acceptance/host-catalogs/delete-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/delete-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { @@ -20,14 +18,12 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getHostCatalogCount; const instances = { scopes: { - global: null, org: null, project: null, }, @@ -45,7 +41,6 @@ module('Acceptance | host-catalogs | delete', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -74,7 +69,6 @@ module('Acceptance | host-catalogs | delete', function (hooks) { // Generate resource counter getHostCatalogCount = () => this.server.schema.hostCatalogs.all().models.length; - await authenticateSession({}); }); test('can delete host catalog', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js index f462c048c..cd97cf32a 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js @@ -6,17 +6,14 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | host sets | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getHostSetCount; @@ -44,7 +41,6 @@ module('Acceptance | host-catalogs | host sets | create', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -72,7 +68,6 @@ module('Acceptance | host-catalogs | host sets | create', function (hooks) { urls.newHostSet = `${urls.hostSets}/new`; // Generate resource counter getHostSetCount = () => this.server.schema.hostSets.all().models.length; - await authenticateSession({}); }); test('can create new host sets', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/delete-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/delete-test.js index 1e3a5aed2..984710328 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/delete-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/delete-test.js @@ -6,26 +6,22 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; import { resolve, reject } from 'rsvp'; import sinon from 'sinon'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | host sets | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getHostSetCount; const instances = { scopes: { - global: null, org: null, project: null, hostCatalog: null, @@ -46,7 +42,6 @@ module('Acceptance | host-catalogs | host sets | delete', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -72,9 +67,8 @@ module('Acceptance | host-catalogs | host sets | delete', function (hooks) { urls.hostSet = `${urls.hostSets}/${instances.hostSet.id}`; urls.unknownHostSet = `${urls.hostSets}/foo`; urls.newHostSet = `${urls.hostSets}/new`; - // Generate resource couner + // Generate resource counter getHostSetCount = () => this.server.schema.hostSets.all().models.length; - await authenticateSession({}); }); test('can delete host', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/hosts-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/hosts-test.js index 95f632f88..d596d0a71 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/hosts-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/hosts-test.js @@ -6,24 +6,20 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getHostSetHostCount; const instances = { scopes: { - global: null, org: null, project: null, hostCatalog: null, @@ -45,7 +41,6 @@ module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -76,7 +71,6 @@ module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) { // Generate resource counter getHostSetHostCount = () => this.server.schema.hostSets.all().models[0].hosts.length; - await authenticateSession({ username: 'admin' }); }); test('visiting host set hosts', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/list-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/list-test.js index aa143d4b8..ff408a251 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/list-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/list-test.js @@ -6,19 +6,15 @@ import { module, test } from 'qunit'; import { visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | host-catalogs | host sets | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, hostCatalog: null, @@ -38,7 +34,6 @@ module('Acceptance | host-catalogs | host sets | list', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -63,7 +58,6 @@ module('Acceptance | host-catalogs | host sets | list', function (hooks) { urls.hostSets = `${urls.hostCatalog}/host-sets`; urls.hostSet = `${urls.hostSets}/${instances.hostSet.id}`; urls.newHostSet = `${urls.hostSets}/new`; - await authenticateSession({}); }); test('Users can navigate to host-sets with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/read-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/read-test.js index 2f3d01549..9eb374312 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/read-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/read-test.js @@ -6,20 +6,16 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | host-sets | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -40,7 +36,6 @@ module('Acceptance | host-catalogs | host-sets | read', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -65,8 +60,6 @@ module('Acceptance | host-catalogs | host-sets | read', function (hooks) { urls.hostSets = `${urls.hostCatalog}/host-sets`; urls.hostSet = `${urls.hostSets}/${instances.hostSet.id}`; urls.unknownHostSet = `${urls.hostSets}/foo`; - - await authenticateSession({ username: 'admin' }); }); test('visiting host sets', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/update-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/update-test.js index 6933f353b..ab241f1e9 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/update-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/update-test.js @@ -13,22 +13,18 @@ import { fillIn, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | host sets | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, hostCatalog: null, @@ -55,7 +51,6 @@ module('Acceptance | host-catalogs | host sets | update', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -109,8 +104,6 @@ module('Acceptance | host-catalogs | host sets | update', function (hooks) { urls.newHostSet = `${urls.hostSets}/new`; urls.awshostSet = `${urls.hostCatalogs}/${instances.awsHostCatalog.id}/host-sets/${instances.awsHostSet.id}`; urls.azureHostSet = `${urls.hostCatalogs}/${instances.azureHostCatalog.id}/host-sets/${instances.azureHostSet.id}`; - // Generate resource couner - await authenticateSession({}); }); test('saving a new host set with invalid fields displays error messages', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/hosts/create-test.js b/ui/admin/tests/acceptance/host-catalogs/hosts/create-test.js index 7892d6341..a094ca655 100644 --- a/ui/admin/tests/acceptance/host-catalogs/hosts/create-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/hosts/create-test.js @@ -6,24 +6,20 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | hosts | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getHostCount; const instances = { scopes: { - global: null, org: null, project: null, hostCatalog: null, @@ -44,7 +40,6 @@ module('Acceptance | host-catalogs | hosts | create', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -71,9 +66,8 @@ module('Acceptance | host-catalogs | hosts | create', function (hooks) { urls.host = `${urls.hosts}/${instances.host.id}`; urls.unknownHost = `${urls.hosts}/foo`; urls.newHost = `${urls.hosts}/new`; - // Generate resource couner + // Generate resource counter getHostCount = () => this.server.schema.hosts.all().models.length; - await authenticateSession({}); }); test('can create new host', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/hosts/delete-test.js b/ui/admin/tests/acceptance/host-catalogs/hosts/delete-test.js index 51235c51c..b58f3f149 100644 --- a/ui/admin/tests/acceptance/host-catalogs/hosts/delete-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/hosts/delete-test.js @@ -6,26 +6,22 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; import { resolve, reject } from 'rsvp'; import sinon from 'sinon'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | hosts | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getHostCount; const instances = { scopes: { - global: null, org: null, project: null, hostCatalog: null, @@ -46,7 +42,6 @@ module('Acceptance | host-catalogs | hosts | delete', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -72,9 +67,8 @@ module('Acceptance | host-catalogs | hosts | delete', function (hooks) { urls.host = `${urls.hosts}/${instances.host.id}`; urls.unknownHost = `${urls.hosts}/foo`; urls.newHost = `${urls.hosts}/new`; - // Generate resource couner + // Generate resource counter getHostCount = () => this.server.schema.hosts.all().models.length; - await authenticateSession({}); }); test('can delete host', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/hosts/list-test.js b/ui/admin/tests/acceptance/host-catalogs/hosts/list-test.js index 32d01dd55..8f9892b40 100644 --- a/ui/admin/tests/acceptance/host-catalogs/hosts/list-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/hosts/list-test.js @@ -6,21 +6,17 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | hosts | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, hostCatalog: null, @@ -41,7 +37,6 @@ module('Acceptance | host-catalogs | hosts | list', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -67,7 +62,6 @@ module('Acceptance | host-catalogs | hosts | list', function (hooks) { urls.host = `${urls.hosts}/${instances.host.id}`; urls.unknownHost = `${urls.hosts}/foo`; urls.newHost = `${urls.hosts}/new`; - await authenticateSession({}); }); test('Users can navigate to hosts with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/hosts/read-test.js b/ui/admin/tests/acceptance/host-catalogs/hosts/read-test.js index 1eac0f652..956c6890a 100644 --- a/ui/admin/tests/acceptance/host-catalogs/hosts/read-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/hosts/read-test.js @@ -6,20 +6,16 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | hosts | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -40,7 +36,6 @@ module('Acceptance | host-catalogs | hosts | read', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -65,8 +60,6 @@ module('Acceptance | host-catalogs | hosts | read', function (hooks) { urls.hosts = `${urls.hostCatalog}/hosts`; urls.host = `${urls.hosts}/${instances.host.id}`; urls.unknownHost = `${urls.hosts}/foo`; - - await authenticateSession({ username: 'admin' }); }); test('visiting hosts', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/hosts/update-test.js b/ui/admin/tests/acceptance/host-catalogs/hosts/update-test.js index ecaeffe00..51a2dcdcd 100644 --- a/ui/admin/tests/acceptance/host-catalogs/hosts/update-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/hosts/update-test.js @@ -6,22 +6,18 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | hosts | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, hostCatalog: null, @@ -42,7 +38,6 @@ module('Acceptance | host-catalogs | hosts | update', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -68,8 +63,6 @@ module('Acceptance | host-catalogs | hosts | update', function (hooks) { urls.host = `${urls.hosts}/${instances.host.id}`; urls.unknownHost = `${urls.hosts}/foo`; urls.newHost = `${urls.hosts}/new`; - // Generate resource couner - await authenticateSession({}); }); test('can save changes to existing host', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/list-test.js b/ui/admin/tests/acceptance/host-catalogs/list-test.js index 687f740df..c50d0ab2e 100644 --- a/ui/admin/tests/acceptance/host-catalogs/list-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/list-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { click, currentURL, fillIn, visit, waitFor } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_HOST_CATALOG_DYNAMIC, TYPE_HOST_CATALOG_PLUGIN_AWS, @@ -23,12 +21,10 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -48,7 +44,6 @@ module('Acceptance | host-catalogs | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -85,8 +80,6 @@ module('Acceptance | host-catalogs | list', function (hooks) { urls.awsHostCatalog = `${urls.hostCatalogs}/${instances.awsHostCatalog.id}`; urls.azureHostCatalog = `${urls.hostCatalogs}/${instances.azureHostCatalog.id}`; urls.gcpHostCatalog = `${urls.hostCatalogs}/${instances.gcpHostCatalog.id}`; - - await authenticateSession({}); }); test('user can navigate to host catalogs with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/read-test.js b/ui/admin/tests/acceptance/host-catalogs/read-test.js index cec6e6559..13f8149a0 100644 --- a/ui/admin/tests/acceptance/host-catalogs/read-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/read-test.js @@ -6,20 +6,16 @@ import { module, test } from 'qunit'; import { click, currentURL, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -36,7 +32,6 @@ module('Acceptance | host-catalogs | read', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -55,8 +50,6 @@ module('Acceptance | host-catalogs | read', function (hooks) { urls.hostCatalogs = `${urls.projectScope}/host-catalogs`; urls.hostCatalog = `${urls.hostCatalogs}/${instances.hostCatalog.id}`; urls.unknownHostCatalog = `${urls.hostCatalogs}/foo`; - - await authenticateSession({ username: 'admin' }); }); test('visiting host catalogs', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/update-test.js b/ui/admin/tests/acceptance/host-catalogs/update-test.js index ac98cf01d..e7154a0c1 100644 --- a/ui/admin/tests/acceptance/host-catalogs/update-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/update-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { TYPE_HOST_CATALOG_DYNAMIC, @@ -21,12 +19,10 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | host-catalogs | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -45,7 +41,6 @@ module('Acceptance | host-catalogs | update', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -80,7 +75,6 @@ module('Acceptance | host-catalogs | update', function (hooks) { urls.hostCatalog = `${urls.hostCatalogs}/${instances.hostCatalog.id}`; urls.AWSHostCatalogWithStaticCredential = `${urls.hostCatalogs}/${instances.AWSHostCatalogWithStaticCredential.id}`; urls.GCPHostCatalog = `${urls.hostCatalogs}/${instances.GCPHostCatalog.id}`; - await authenticateSession({}); }); test('can update static AWS credentials to Dynamic AWS credentials', async function (assert) { diff --git a/ui/admin/tests/acceptance/managed-groups/create-test.js b/ui/admin/tests/acceptance/managed-groups/create-test.js index b34a8d814..6153b6cdf 100644 --- a/ui/admin/tests/acceptance/managed-groups/create-test.js +++ b/ui/admin/tests/acceptance/managed-groups/create-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import { TYPE_AUTH_METHOD_OIDC, @@ -20,7 +18,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | managed-groups | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getManagedGroupCount; @@ -28,7 +25,6 @@ module('Acceptance | managed-groups | create', function (hooks) { const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -45,8 +41,6 @@ module('Acceptance | managed-groups | create', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/managed-groups/delete-test.js b/ui/admin/tests/acceptance/managed-groups/delete-test.js index c99f05b27..1451aed5d 100644 --- a/ui/admin/tests/acceptance/managed-groups/delete-test.js +++ b/ui/admin/tests/acceptance/managed-groups/delete-test.js @@ -6,8 +6,6 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import { TYPE_AUTH_METHOD_OIDC, @@ -19,13 +17,11 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | managed-groups | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); let getManagedGroupCount; const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -45,8 +41,6 @@ module('Acceptance | managed-groups | delete', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/managed-groups/list-test.js b/ui/admin/tests/acceptance/managed-groups/list-test.js index c173ced11..a4c940154 100644 --- a/ui/admin/tests/acceptance/managed-groups/list-test.js +++ b/ui/admin/tests/acceptance/managed-groups/list-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_AUTH_METHOD_OIDC, TYPE_AUTH_METHOD_LDAP, @@ -19,7 +17,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | managed-groups | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -44,8 +41,6 @@ module('Acceptance | managed-groups | list', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/managed-groups/members-test.js b/ui/admin/tests/acceptance/managed-groups/members-test.js index 815faee18..bbe2acd4e 100644 --- a/ui/admin/tests/acceptance/managed-groups/members-test.js +++ b/ui/admin/tests/acceptance/managed-groups/members-test.js @@ -6,18 +6,14 @@ import { module, test } from 'qunit'; import { visit, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | managed-groups | members', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -33,8 +29,6 @@ module('Acceptance | managed-groups | members', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/managed-groups/read-test.js b/ui/admin/tests/acceptance/managed-groups/read-test.js index bfd05292f..39034d044 100644 --- a/ui/admin/tests/acceptance/managed-groups/read-test.js +++ b/ui/admin/tests/acceptance/managed-groups/read-test.js @@ -6,8 +6,6 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_AUTH_METHOD_OIDC, TYPE_AUTH_METHOD_LDAP, @@ -17,11 +15,9 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | managed-groups | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { - global: null, org: null, }, authMethod: null, @@ -41,8 +37,6 @@ module('Acceptance | managed-groups | read', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/onboarding/onboarding-test.js b/ui/admin/tests/acceptance/onboarding/onboarding-test.js index 9d109a1a3..3ba353fa0 100644 --- a/ui/admin/tests/acceptance/onboarding/onboarding-test.js +++ b/ui/admin/tests/acceptance/onboarding/onboarding-test.js @@ -5,9 +5,7 @@ import { module, test } from 'qunit'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { visit, fillIn, click, currentURL } from '@ember/test-helpers'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; @@ -15,7 +13,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | onboarding', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const urls = { @@ -24,10 +21,6 @@ module('Acceptance | onboarding', function (hooks) { orgs: '/scopes/global/scopes', }; - hooks.beforeEach(async function () { - await authenticateSession({}); - }); - test('show targetAddress and targetPort fields', async function (assert) { setRunOptions({ rules: { diff --git a/ui/admin/tests/acceptance/onboarding/success-test.js b/ui/admin/tests/acceptance/onboarding/success-test.js index 1fe6ddcfd..bfe4c9a5a 100644 --- a/ui/admin/tests/acceptance/onboarding/success-test.js +++ b/ui/admin/tests/acceptance/onboarding/success-test.js @@ -6,22 +6,15 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | onboarding | success', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); - hooks.beforeEach(async function () { - await authenticateSession({}); - }); - const urls = { onboarding: '/onboarding', success: '/onboarding/success', diff --git a/ui/admin/tests/acceptance/policy/create-test.js b/ui/admin/tests/acceptance/policy/create-test.js index a6f160421..d7331cbdf 100644 --- a/ui/admin/tests/acceptance/policy/create-test.js +++ b/ui/admin/tests/acceptance/policy/create-test.js @@ -6,16 +6,13 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn, select } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | policies | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); let features; let getPolicyCount; @@ -34,7 +31,7 @@ module('Acceptance | policies | create', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -45,7 +42,6 @@ module('Acceptance | policies | create', function (hooks) { getPolicyCount = () => this.server.schema.policies.all().models.length; features = this.owner.lookup('service:features'); features.enable('ssh-session-recording'); - await authenticateSession({ username: 'admin' }); }); test('users can create a new policy with global scope', async function (assert) { diff --git a/ui/admin/tests/acceptance/policy/delete-test.js b/ui/admin/tests/acceptance/policy/delete-test.js index 8b552e9e9..b5c9cfe35 100644 --- a/ui/admin/tests/acceptance/policy/delete-test.js +++ b/ui/admin/tests/acceptance/policy/delete-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | policies | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -35,8 +32,7 @@ module('Acceptance | policies | delete', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/policy/list-test.js b/ui/admin/tests/acceptance/policy/list-test.js index e3945197d..b9a234c64 100644 --- a/ui/admin/tests/acceptance/policy/list-test.js +++ b/ui/admin/tests/acceptance/policy/list-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | policies | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -35,7 +32,7 @@ module('Acceptance | policies | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -45,7 +42,6 @@ module('Acceptance | policies | list', function (hooks) { intl = this.owner.lookup('service:intl'); - await authenticateSession({}); featuresService = this.owner.lookup('service:features'); }); diff --git a/ui/admin/tests/acceptance/policy/read-test.js b/ui/admin/tests/acceptance/policy/read-test.js index 9d8310dca..49ee2fa49 100644 --- a/ui/admin/tests/acceptance/policy/read-test.js +++ b/ui/admin/tests/acceptance/policy/read-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | policies | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let features; @@ -35,7 +32,7 @@ module('Acceptance | policies | read', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -50,7 +47,6 @@ module('Acceptance | policies | read', function (hooks) { features = this.owner.lookup('service:features'); features.enable('ssh-session-recording'); - await authenticateSession({ username: 'admin' }); }); test('visiting a policy', async function (assert) { diff --git a/ui/admin/tests/acceptance/policy/update-test.js b/ui/admin/tests/acceptance/policy/update-test.js index ddfe66fb2..3b482a1e0 100644 --- a/ui/admin/tests/acceptance/policy/update-test.js +++ b/ui/admin/tests/acceptance/policy/update-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, click, fillIn, select } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | policies | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); let features; @@ -33,7 +30,7 @@ module('Acceptance | policies | update', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.policy = this.server.create('policy', { scope: instances.scopes.global, @@ -45,7 +42,6 @@ module('Acceptance | policies | update', function (hooks) { features = this.owner.lookup('service:features'); features.enable('ssh-session-recording'); - await authenticateSession({}); }); test('users can update forever select option to a custom input', async function (assert) { diff --git a/ui/admin/tests/acceptance/roles/create-test.js b/ui/admin/tests/acceptance/roles/create-test.js index a9c12e4e1..c35cb4da0 100644 --- a/ui/admin/tests/acceptance/roles/create-test.js +++ b/ui/admin/tests/acceptance/roles/create-test.js @@ -6,23 +6,19 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | roles | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getRolesCount; const instances = { scopes: { - global: null, org: null, project: null, }, @@ -35,7 +31,6 @@ module('Acceptance | roles | create', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); instances.scopes.org = this.server.create( 'scope', { diff --git a/ui/admin/tests/acceptance/roles/delete-test.js b/ui/admin/tests/acceptance/roles/delete-test.js index 7f2ee4fef..a4d0f16c4 100644 --- a/ui/admin/tests/acceptance/roles/delete-test.js +++ b/ui/admin/tests/acceptance/roles/delete-test.js @@ -6,22 +6,18 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | roles | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -34,8 +30,6 @@ module('Acceptance | roles | delete', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/roles/global-scope-test.js b/ui/admin/tests/acceptance/roles/global-scope-test.js index 93b6d43f5..d4e02458a 100644 --- a/ui/admin/tests/acceptance/roles/global-scope-test.js +++ b/ui/admin/tests/acceptance/roles/global-scope-test.js @@ -14,9 +14,7 @@ import { waitFor, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { GRANT_SCOPE_THIS, GRANT_SCOPE_CHILDREN, @@ -29,7 +27,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | roles | global-scope', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let confirmService; @@ -52,10 +49,9 @@ module('Acceptance | roles | global-scope', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); confirmService = this.owner.lookup('service:confirm'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/roles/grants-test.js b/ui/admin/tests/acceptance/roles/grants-test.js index 66dee9096..7d270ceec 100644 --- a/ui/admin/tests/acceptance/roles/grants-test.js +++ b/ui/admin/tests/acceptance/roles/grants-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | roles | grants', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); // This is unique to permissions tests and only used once here const FIELD_GRANT_DISABLED = 'input[disabled]'; @@ -23,7 +20,6 @@ module('Acceptance | roles | grants', function (hooks) { const instances = { scopes: { - global: null, org: null, }, role: null, @@ -35,8 +31,6 @@ module('Acceptance | roles | grants', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/roles/list-test.js b/ui/admin/tests/acceptance/roles/list-test.js index d2d17914f..44d6ba6a6 100644 --- a/ui/admin/tests/acceptance/roles/list-test.js +++ b/ui/admin/tests/acceptance/roles/list-test.js @@ -14,9 +14,7 @@ import { currentURL, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { GRANT_SCOPE_THIS } from 'api/models/role'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; @@ -25,12 +23,10 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | roles | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, }, role1: null, @@ -46,7 +42,6 @@ module('Acceptance | roles | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -62,7 +57,6 @@ module('Acceptance | roles | list', function (hooks) { urls.roles = `/scopes/${instances.scopes.org.id}/roles`; urls.role1 = `${urls.roles}/${instances.role1.id}`; urls.role2 = `${urls.roles}/${instances.role2.id}`; - await authenticateSession({}); }); test('users can navigate to roles with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/roles/org-scope-test.js b/ui/admin/tests/acceptance/roles/org-scope-test.js index 1aa6eee84..96c8a7f28 100644 --- a/ui/admin/tests/acceptance/roles/org-scope-test.js +++ b/ui/admin/tests/acceptance/roles/org-scope-test.js @@ -13,9 +13,7 @@ import { waitUntil, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { @@ -27,14 +25,12 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | roles | org-scope', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let confirmService; const instances = { scopes: { - global: null, org: null, project: null, }, @@ -50,10 +46,8 @@ module('Acceptance | roles | org-scope', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); confirmService = this.owner.lookup('service:confirm'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/roles/principals-test.js b/ui/admin/tests/acceptance/roles/principals-test.js index 72e2d9690..ae3dc168e 100644 --- a/ui/admin/tests/acceptance/roles/principals-test.js +++ b/ui/admin/tests/acceptance/roles/principals-test.js @@ -6,22 +6,18 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, findAll } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | roles | principals', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, }, role: null, @@ -35,8 +31,6 @@ module('Acceptance | roles | principals', function (hooks) { let principalsCount; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/roles/project-scope-test.js b/ui/admin/tests/acceptance/roles/project-scope-test.js index e05be84e2..5a6e856f2 100644 --- a/ui/admin/tests/acceptance/roles/project-scope-test.js +++ b/ui/admin/tests/acceptance/roles/project-scope-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { GRANT_SCOPE_THIS } from 'api/models/role'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; @@ -16,12 +14,10 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | roles | project-scope', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -34,8 +30,6 @@ module('Acceptance | roles | project-scope', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/roles/read-test.js b/ui/admin/tests/acceptance/roles/read-test.js index 2d37706b4..4f203604b 100644 --- a/ui/admin/tests/acceptance/roles/read-test.js +++ b/ui/admin/tests/acceptance/roles/read-test.js @@ -6,19 +6,15 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | roles | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -32,8 +28,6 @@ module('Acceptance | roles | read', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/roles/update-test.js b/ui/admin/tests/acceptance/roles/update-test.js index b3dd7a9ab..b426d2959 100644 --- a/ui/admin/tests/acceptance/roles/update-test.js +++ b/ui/admin/tests/acceptance/roles/update-test.js @@ -6,20 +6,16 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | roles | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, project: null, }, @@ -32,8 +28,6 @@ module('Acceptance | roles | update', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/acceptance/scopes-test.js b/ui/admin/tests/acceptance/scopes-test.js index 16c7c1452..ca33501d9 100644 --- a/ui/admin/tests/acceptance/scopes-test.js +++ b/ui/admin/tests/acceptance/scopes-test.js @@ -6,23 +6,19 @@ import { module, test } from 'qunit'; import { click, currentURL, fillIn, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | scopes', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getScopeCount; const instances = { scopes: { - global: null, org: null, org2: null, project: null, @@ -47,7 +43,6 @@ module('Acceptance | scopes', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -80,7 +75,6 @@ module('Acceptance | scopes', function (hooks) { urls.project2Targets = `${urls.project2Scope}/targets`; // Generate resource counter getScopeCount = (type) => this.server.schema.scopes.where({ type }).length; - await authenticateSession({ isGlobal: true, username: 'admin' }); }); test('visiting global scope', async function (assert) { diff --git a/ui/admin/tests/acceptance/scopes/add-storage-policy-test.js b/ui/admin/tests/acceptance/scopes/add-storage-policy-test.js index 7c4b4a758..8866b0d87 100644 --- a/ui/admin/tests/acceptance/scopes/add-storage-policy-test.js +++ b/ui/admin/tests/acceptance/scopes/add-storage-policy-test.js @@ -6,16 +6,13 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import select from '@ember/test-helpers/dom/select'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; -module('Acceptance | scope | add storage policy', function (hooks) { +module('Acceptance | scopes | add storage policy', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); let featuresService; let policyOne; @@ -24,7 +21,6 @@ module('Acceptance | scope | add storage policy', function (hooks) { // Instances const instances = { scopes: { - global: null, org: null, }, sessionRecording: null, @@ -44,7 +40,6 @@ module('Acceptance | scope | add storage policy', function (hooks) { hooks.beforeEach(async function () { featuresService = this.owner.lookup('service:features'); // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -65,7 +60,6 @@ module('Acceptance | scope | add storage policy', function (hooks) { urls.policy = `${urls.policies}/${policyOne.id}`; urls.addStoragePolicy = `${urls.orgScope}/add-storage-policy`; urls.newPolicy = `${urls.addStoragePolicy}/create`; - await authenticateSession({ username: 'admin' }); }); test('cannot attach policy on a scope without proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/scopes/delete-test.js b/ui/admin/tests/acceptance/scopes/delete-test.js index f0ebe4c26..44b37569d 100644 --- a/ui/admin/tests/acceptance/scopes/delete-test.js +++ b/ui/admin/tests/acceptance/scopes/delete-test.js @@ -6,17 +6,14 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | scopes | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getScopeCount; @@ -24,7 +21,6 @@ module('Acceptance | scopes | delete', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -39,7 +35,6 @@ module('Acceptance | scopes | delete', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -56,7 +51,6 @@ module('Acceptance | scopes | delete', function (hooks) { // Generate resource counter getScopeCount = (type) => this.server.schema.scopes.where({ type }).length; confirmService = this.owner.lookup('service:confirm'); - await authenticateSession({ isGlobal: true }); }); test('can delete scope', async function (assert) { diff --git a/ui/admin/tests/acceptance/scopes/list-test.js b/ui/admin/tests/acceptance/scopes/list-test.js index d872ea5f7..932294f7b 100644 --- a/ui/admin/tests/acceptance/scopes/list-test.js +++ b/ui/admin/tests/acceptance/scopes/list-test.js @@ -6,21 +6,17 @@ import { module, test } from 'qunit'; import { currentURL, visit, fillIn, waitFor, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { faker } from '@faker-js/faker'; module('Acceptance | scopes | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org1: null, org2: null, project1: null, @@ -35,7 +31,6 @@ module('Acceptance | scopes | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org1 = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -56,7 +51,6 @@ module('Acceptance | scopes | list', function (hooks) { urls.scopes = '/scopes'; urls.globalScope = '/scopes/global/scopes'; urls.orgScope = `/scopes/${instances.scopes.org1.id}/scopes`; - await authenticateSession({}); }); test('user gets redirected to scopes list view', async function (assert) { diff --git a/ui/admin/tests/acceptance/scopes/read-test.js b/ui/admin/tests/acceptance/scopes/read-test.js index d957e1854..8d4b6cdde 100644 --- a/ui/admin/tests/acceptance/scopes/read-test.js +++ b/ui/admin/tests/acceptance/scopes/read-test.js @@ -6,16 +6,13 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | scopes | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let features; @@ -23,7 +20,6 @@ module('Acceptance | scopes | read', function (hooks) { const instances = { scopes: { - global: null, org: null, }, }; @@ -36,7 +32,6 @@ module('Acceptance | scopes | read', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -48,7 +43,6 @@ module('Acceptance | scopes | read', function (hooks) { urls.orgScopeEdit = `/scopes/${instances.scopes.org.id}/edit`; features = this.owner.lookup('service:features'); featureEdition = this.owner.lookup('service:featureEdition'); - await authenticateSession({ isGlobal: true, username: 'admin' }); }); test('visiting org scope edit', async function (assert) { diff --git a/ui/admin/tests/acceptance/scopes/update-test.js b/ui/admin/tests/acceptance/scopes/update-test.js index bb058349f..58fcc4bb9 100644 --- a/ui/admin/tests/acceptance/scopes/update-test.js +++ b/ui/admin/tests/acceptance/scopes/update-test.js @@ -6,22 +6,18 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | scopes | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let confirmService; const instances = { scopes: { - global: null, org: null, project: null, }, @@ -35,7 +31,6 @@ module('Acceptance | scopes | update', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -54,8 +49,6 @@ module('Acceptance | scopes | update', function (hooks) { urls.orgScopeEdit = `/scopes/${instances.scopes.org.id}/edit`; urls.projectScope = `/scopes/${instances.scopes.project.id}`; confirmService = this.owner.lookup('service:confirm'); - - await authenticateSession({ isGlobal: true }); }); test('can save changes to existing scope', async function (assert) { diff --git a/ui/admin/tests/acceptance/session-recordings/list-test.js b/ui/admin/tests/acceptance/session-recordings/list-test.js index 2b5993a9b..62a65c001 100644 --- a/ui/admin/tests/acceptance/session-recordings/list-test.js +++ b/ui/admin/tests/acceptance/session-recordings/list-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn, waitFor } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupIntl } from 'ember-intl/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { faker } from '@faker-js/faker'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; @@ -20,9 +18,8 @@ import { } from 'api/models/session-recording'; import { setRunOptions } from 'ember-a11y-testing/test-support'; -module('Acceptance | session recordings | list', function (hooks) { +module('Acceptance | session-recordings | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); setupIntl(hooks, 'en-us'); @@ -62,7 +59,7 @@ module('Acceptance | session recordings | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -122,8 +119,6 @@ module('Acceptance | session recordings | list', function (hooks) { featuresService = this.owner.lookup('service:features'); featuresService.enable('ssh-session-recording'); - - await authenticateSession({}); }); test('users can navigate to session-recordings with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/session-recordings/read-test.js b/ui/admin/tests/acceptance/session-recordings/read-test.js index 433623997..3861a7d97 100644 --- a/ui/admin/tests/acceptance/session-recordings/read-test.js +++ b/ui/admin/tests/acceptance/session-recordings/read-test.js @@ -6,8 +6,6 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { setupIntl } from 'ember-intl/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import * as commonSelectors from 'admin/tests/helpers/selectors'; @@ -16,7 +14,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | session-recordings | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); setupIntl(hooks, 'en-us'); @@ -41,7 +38,7 @@ module('Acceptance | session-recordings | read', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -67,7 +64,6 @@ module('Acceptance | session-recordings | read', function (hooks) { urls.sessionRecordings = `${urls.globalScope}/session-recordings`; urls.sessionRecording = `${urls.sessionRecordings}/${instances.sessionRecording.id}/channels-by-connection`; urls.channelRecording = `${urls.sessionRecording}/${instances.channelRecording.id}`; - await authenticateSession({ username: 'admin' }); featuresService = this.owner.lookup('service:features'); }); diff --git a/ui/admin/tests/acceptance/session-recordings/session-recording/channels-by-connection/channel-test.js b/ui/admin/tests/acceptance/session-recordings/session-recording/channels-by-connection/channel-test.js index 2a6d534ed..2afe0b8c7 100644 --- a/ui/admin/tests/acceptance/session-recordings/session-recording/channels-by-connection/channel-test.js +++ b/ui/admin/tests/acceptance/session-recordings/session-recording/channels-by-connection/channel-test.js @@ -6,8 +6,6 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { Response } from 'miragejs'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { setupIntl } from 'ember-intl/test-support'; @@ -19,7 +17,6 @@ module( 'Acceptance | session-recordings | session-recording | channels-by-connection | channel', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); setupIntl(hooks, 'en-us'); @@ -48,7 +45,7 @@ module( }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -81,7 +78,6 @@ module( this.server.schema.sessionRecordings.all().models.length; featuresService = this.owner.lookup('service:features'); - await authenticateSession({}); }); test('user can navigate to a channel', async function (assert) { diff --git a/ui/admin/tests/acceptance/sessions/list-test.js b/ui/admin/tests/acceptance/sessions/list-test.js index 3dae2ba8f..1bb8deed6 100644 --- a/ui/admin/tests/acceptance/sessions/list-test.js +++ b/ui/admin/tests/acceptance/sessions/list-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { click, currentURL, fillIn, visit, waitFor } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { faker } from '@faker-js/faker'; import { TYPE_TARGET_SSH, TYPE_TARGET_TCP } from 'api/models/target'; import { @@ -24,7 +22,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | sessions | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const CREATED_TIME_VALUES_ARRAY = [ @@ -63,7 +60,7 @@ module('Acceptance | sessions | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.admin = this.server.create('user', { scopeId: 'global', name: 'admin', @@ -108,8 +105,6 @@ module('Acceptance | sessions | list', function (hooks) { urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`; urls.projectScope = `/scopes/${instances.scopes.project.id}`; urls.sessions = `${urls.projectScope}/sessions`; - - await authenticateSession({ username: 'admin' }); }); test('visiting sessions', async function (assert) { diff --git a/ui/admin/tests/acceptance/storage-buckets/create-test.js b/ui/admin/tests/acceptance/storage-buckets/create-test.js index 4223c9dc9..570ef3b77 100644 --- a/ui/admin/tests/acceptance/storage-buckets/create-test.js +++ b/ui/admin/tests/acceptance/storage-buckets/create-test.js @@ -6,17 +6,14 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn, select } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | storage-buckets | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let features; @@ -36,7 +33,7 @@ module('Acceptance | storage-buckets | create', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -49,7 +46,6 @@ module('Acceptance | storage-buckets | create', function (hooks) { features = this.owner.lookup('service:features'); features.enable('ssh-session-recording'); - await authenticateSession({ username: 'admin' }); }); test('users can create a new storage bucket aws plugin type with global scope', async function (assert) { diff --git a/ui/admin/tests/acceptance/storage-buckets/delete-test.js b/ui/admin/tests/acceptance/storage-buckets/delete-test.js index 3aad13fb0..a265ef9d5 100644 --- a/ui/admin/tests/acceptance/storage-buckets/delete-test.js +++ b/ui/admin/tests/acceptance/storage-buckets/delete-test.js @@ -5,16 +5,13 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | storage-buckets | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let intl; @@ -39,7 +36,7 @@ module('Acceptance | storage-buckets | delete', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -52,7 +49,6 @@ module('Acceptance | storage-buckets | delete', function (hooks) { getStorageBucketCount = () => this.server.schema.storageBuckets.all().models.length; - await authenticateSession({}); intl = this.owner.lookup('service:intl'); features = this.owner.lookup('service:features'); features.enable('ssh-session-recording'); diff --git a/ui/admin/tests/acceptance/storage-buckets/list-test.js b/ui/admin/tests/acceptance/storage-buckets/list-test.js index 2ea95111a..1d9a3d5eb 100644 --- a/ui/admin/tests/acceptance/storage-buckets/list-test.js +++ b/ui/admin/tests/acceptance/storage-buckets/list-test.js @@ -6,16 +6,13 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as selectors from './selectors'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | storage-buckets | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -36,7 +33,7 @@ module('Acceptance | storage-buckets | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -46,7 +43,6 @@ module('Acceptance | storage-buckets | list', function (hooks) { intl = this.owner.lookup('service:intl'); - await authenticateSession({}); featuresService = this.owner.lookup('service:features'); }); diff --git a/ui/admin/tests/acceptance/storage-buckets/read-test.js b/ui/admin/tests/acceptance/storage-buckets/read-test.js index 7a97d05ad..2a9a0fa40 100644 --- a/ui/admin/tests/acceptance/storage-buckets/read-test.js +++ b/ui/admin/tests/acceptance/storage-buckets/read-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | storage-buckets | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let features; @@ -35,7 +32,7 @@ module('Acceptance | storage-buckets | read', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -50,7 +47,6 @@ module('Acceptance | storage-buckets | read', function (hooks) { features = this.owner.lookup('service:features'); features.enable('ssh-session-recording'); - await authenticateSession({ username: 'admin' }); }); test('visiting a storage bucket', async function (assert) { diff --git a/ui/admin/tests/acceptance/storage-buckets/update-test.js b/ui/admin/tests/acceptance/storage-buckets/update-test.js index 876bb8bac..a3432f662 100644 --- a/ui/admin/tests/acceptance/storage-buckets/update-test.js +++ b/ui/admin/tests/acceptance/storage-buckets/update-test.js @@ -6,7 +6,6 @@ import { module, test } from 'qunit'; import { visit, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; import * as selectors from './selectors'; @@ -15,7 +14,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | storage-buckets | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let features; @@ -35,7 +33,7 @@ module('Acceptance | storage-buckets | update', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.storageBucket = this.server.create('storage-bucket', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/acceptance/targets/brokered-credential-sources-test.js b/ui/admin/tests/acceptance/targets/brokered-credential-sources-test.js index c6b1f31ef..5c083daea 100644 --- a/ui/admin/tests/acceptance/targets/brokered-credential-sources-test.js +++ b/ui/admin/tests/acceptance/targets/brokered-credential-sources-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; @@ -27,7 +25,6 @@ import { TYPE_TARGET_RDP, TYPE_TARGET_TCP } from 'api/models/target'; module('Acceptance | targets | brokered credential sources', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getCredentialLibraryCount; @@ -39,7 +36,6 @@ module('Acceptance | targets | brokered credential sources', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -70,7 +66,6 @@ module('Acceptance | targets | brokered credential sources', function (hooks) { hooks.beforeEach(async function () { featuresService = this.owner.lookup('service:features'); // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -146,8 +141,6 @@ module('Acceptance | targets | brokered credential sources', function (hooks) { getCredentialCount = () => this.server.schema.credentials.all().models.length; credentialSourceCount = getCredentialLibraryCount() + getCredentialCount(); - - await authenticateSession({ username: 'admin' }); }); test.each( diff --git a/ui/admin/tests/acceptance/targets/create-alias-test.js b/ui/admin/tests/acceptance/targets/create-alias-test.js index e834b1ba6..df9c30a01 100644 --- a/ui/admin/tests/acceptance/targets/create-alias-test.js +++ b/ui/admin/tests/acceptance/targets/create-alias-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { click, fillIn, getContext, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { setupIntl } from 'ember-intl/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; @@ -18,7 +16,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | targets | create-alias', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); setupIntl(hooks, 'en-us'); @@ -46,7 +43,7 @@ module('Acceptance | targets | create-alias', function (hooks) { hooks.beforeEach(async function () { const { owner } = getContext(); featuresService = owner.lookup('service:features'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -69,8 +66,6 @@ module('Acceptance | targets | create-alias', function (hooks) { urls.target = `${urls.targets}/${instances.target.id}`; getAliasCount = () => this.server.schema.aliases.all().models.length; - - await authenticateSession({ username: 'admin' }); }); test('users can create a new alias for a target of TCP type', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/create-test.js b/ui/admin/tests/acceptance/targets/create-test.js index 7b6ed9fed..febd069e2 100644 --- a/ui/admin/tests/acceptance/targets/create-test.js +++ b/ui/admin/tests/acceptance/targets/create-test.js @@ -13,9 +13,7 @@ import { blur, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { TYPE_TARGET_TCP, @@ -29,7 +27,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | targets | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); setupIntl(hooks, 'en-us'); @@ -60,7 +57,7 @@ module('Acceptance | targets | create', function (hooks) { hooks.beforeEach(async function () { const { owner } = getContext(); featuresService = owner.lookup('service:features'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -88,7 +85,6 @@ module('Acceptance | targets | create', function (hooks) { this.server.schema.targets.where({ type: TYPE_TARGET_TCP }).models.length; getRDPTargetCount = () => this.server.schema.targets.where({ type: TYPE_TARGET_RDP }).models.length; - await authenticateSession({}); }); test('defaults to type `tcp` when no query param provided', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/delete-test.js b/ui/admin/tests/acceptance/targets/delete-test.js index 203b40b3c..278342a99 100644 --- a/ui/admin/tests/acceptance/targets/delete-test.js +++ b/ui/admin/tests/acceptance/targets/delete-test.js @@ -6,11 +6,9 @@ import { module, test } from 'qunit'; import { click, currentURL, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { setupIntl } from 'ember-intl/test-support'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; @@ -18,7 +16,6 @@ import { TYPE_TARGET_RDP } from 'api/models/target'; module('Acceptance | targets | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); setupIntl(hooks, 'en-us'); @@ -28,7 +25,6 @@ module('Acceptance | targets | delete', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -46,7 +42,6 @@ module('Acceptance | targets | delete', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -75,8 +70,6 @@ module('Acceptance | targets | delete', function (hooks) { this.server.schema.targets.where({ type: TYPE_TARGET_RDP }).models.length; featuresService = this.owner.lookup('service:features'); - - await authenticateSession({}); }); test('can delete target', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/enable-session-recording-test.js b/ui/admin/tests/acceptance/targets/enable-session-recording-test.js index 27c3ac5c7..1cce30d1e 100644 --- a/ui/admin/tests/acceptance/targets/enable-session-recording-test.js +++ b/ui/admin/tests/acceptance/targets/enable-session-recording-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, find, click, currentURL, select } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { TYPE_TARGET_SSH } from 'api/models/target'; @@ -16,7 +14,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | targets | enable session recording', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -48,7 +45,7 @@ module('Acceptance | targets | enable session recording', function (hooks) { hooks.beforeEach(async function () { featuresService = this.owner.lookup('service:features'); // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -80,8 +77,6 @@ module('Acceptance | targets | enable session recording', function (hooks) { urls.storageBuckets = `${urls.globalScope}/storage-buckets`; urls.newStorageBucket = `${urls.enableSessionRecording}/create-storage-bucket`; urls.storageBucket = `${urls.storageBuckets}/${storageBucketOne.id}`; - - await authenticateSession({ username: 'admin' }); }); test('cannot enable session recording for a target without proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/enable-session-recording/create-storage-bucket-test.js b/ui/admin/tests/acceptance/targets/enable-session-recording/create-storage-bucket-test.js index 56ec081b1..aba643c29 100644 --- a/ui/admin/tests/acceptance/targets/enable-session-recording/create-storage-bucket-test.js +++ b/ui/admin/tests/acceptance/targets/enable-session-recording/create-storage-bucket-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_TARGET_SSH } from 'api/models/target'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; @@ -18,7 +16,6 @@ module( 'Acceptance | targets | enable session recording | create storage bucket', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let features; @@ -32,7 +29,6 @@ module( const instances = { scopes: { - global: null, org: null, }, }; @@ -45,7 +41,6 @@ module( }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -69,7 +64,6 @@ module( features = this.owner.lookup('service:features'); features.enable('ssh-session-recording'); - await authenticateSession({ username: 'admin' }); }); test('users can create a new storage bucket with global scope', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/enable-session-recording/index-test.js b/ui/admin/tests/acceptance/targets/enable-session-recording/index-test.js index f9a6fe032..de100a0ac 100644 --- a/ui/admin/tests/acceptance/targets/enable-session-recording/index-test.js +++ b/ui/admin/tests/acceptance/targets/enable-session-recording/index-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, find, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_TARGET_SSH } from 'api/models/target'; import select from '@ember/test-helpers/dom/select'; import * as commonSelectors from 'admin/tests/helpers/selectors'; @@ -19,7 +17,6 @@ module( 'Acceptance | targets | enable session recording | index', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let intl; @@ -57,7 +54,7 @@ module( hooks.beforeEach(async function () { featuresService = this.owner.lookup('service:features'); // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -88,8 +85,6 @@ module( urls.storageBucket = `${urls.storageBuckets}/${storageBucketOne.id}`; intl = this.owner.lookup('service:intl'); - - await authenticateSession({ username: 'admin' }); }); test('cannot enable session recording for a target without proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/host-sources-test.js b/ui/admin/tests/acceptance/targets/host-sources-test.js index f5ec16e6b..cac39fd04 100644 --- a/ui/admin/tests/acceptance/targets/host-sources-test.js +++ b/ui/admin/tests/acceptance/targets/host-sources-test.js @@ -6,24 +6,20 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | targets | host-sources', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getTargetHostSetCount; const instances = { scopes: { - global: null, org: null, project: null, }, @@ -42,7 +38,6 @@ module('Acceptance | targets | host-sources', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -82,7 +77,6 @@ module('Acceptance | targets | host-sources', function (hooks) { // Generate resource counter getTargetHostSetCount = () => this.server.schema.targets.first().hostSets.models.length; - await authenticateSession({ username: 'admin' }); }); test('visiting target host sources', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/injected-application-credential-sources-test.js b/ui/admin/tests/acceptance/targets/injected-application-credential-sources-test.js index 6b7834a59..c0789177f 100644 --- a/ui/admin/tests/acceptance/targets/injected-application-credential-sources-test.js +++ b/ui/admin/tests/acceptance/targets/injected-application-credential-sources-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_TARGET_SSH, TYPE_TARGET_RDP } from 'api/models/target'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; @@ -30,7 +28,6 @@ module( 'Acceptance | targets | injected application credential sources', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getCredentialLibraryCount; @@ -46,7 +43,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -80,7 +76,6 @@ module( hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -232,7 +227,6 @@ module( credentialSourceForRDPCount = getCredentialLibraryForRDPCount() + getCredentialForRDPCount(); - await authenticateSession({ username: 'admin' }); }); test.each( diff --git a/ui/admin/tests/acceptance/targets/list-test.js b/ui/admin/tests/acceptance/targets/list-test.js index a045e798c..b56c675f0 100644 --- a/ui/admin/tests/acceptance/targets/list-test.js +++ b/ui/admin/tests/acceptance/targets/list-test.js @@ -13,9 +13,7 @@ import { currentURL, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_TARGET_TCP, TYPE_TARGET_SSH, @@ -32,7 +30,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | targets | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -48,7 +45,6 @@ module('Acceptance | targets | list', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -69,7 +65,6 @@ module('Acceptance | targets | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -107,8 +102,6 @@ module('Acceptance | targets | list', function (hooks) { featuresService = this.owner.lookup('service:features'); featuresService.enable('ssh-target'); featuresService.enable('rdp-target'); - - await authenticateSession({}); }); test('can navigate to targets with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/manage-alias-test.js b/ui/admin/tests/acceptance/targets/manage-alias-test.js index be06973b7..a784508b1 100644 --- a/ui/admin/tests/acceptance/targets/manage-alias-test.js +++ b/ui/admin/tests/acceptance/targets/manage-alias-test.js @@ -6,9 +6,7 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_TARGET_TCP, TYPE_TARGET_SSH } from 'api/models/target'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; @@ -16,7 +14,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | targets | manage-alias', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let aliasResourceTwo, aliasResourceOne, getAliasCount; @@ -43,7 +40,7 @@ module('Acceptance | targets | manage-alias', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -82,8 +79,6 @@ module('Acceptance | targets | manage-alias', function (hooks) { urls.tcpAlias = `${urls.tcpTarget}/${aliasResourceOne.id}`; getAliasCount = () => this.server.schema.aliases.all().models.length; - - await authenticateSession({ username: 'admin' }); }); test('clicking on manage should take you to manage page', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/read-test.js b/ui/admin/tests/acceptance/targets/read-test.js index e7ed9dd9f..d274300f4 100644 --- a/ui/admin/tests/acceptance/targets/read-test.js +++ b/ui/admin/tests/acceptance/targets/read-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { click, currentURL, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { setupIntl } from 'ember-intl/test-support'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_TARGET_TCP, TYPE_TARGET_SSH, @@ -21,7 +19,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | targets | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); setupIntl(hooks, 'en-us'); @@ -54,7 +51,7 @@ module('Acceptance | targets | read', function (hooks) { hooks.beforeEach(async function () { featuresService = this.owner.lookup('service:features'); // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -94,8 +91,6 @@ module('Acceptance | targets | read', function (hooks) { urls.aliases = `${urls.globalScope}/aliases`; urls.alias = `${urls.tcpTarget}/${aliasResource.id}`; urls.rdpTarget = `${urls.targets}/${instances.rdpTarget.id}`; - - await authenticateSession({ username: 'admin' }); }); test('visiting ssh target', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/update-test.js b/ui/admin/tests/acceptance/targets/update-test.js index d115f73d3..e8f512b4a 100644 --- a/ui/admin/tests/acceptance/targets/update-test.js +++ b/ui/admin/tests/acceptance/targets/update-test.js @@ -6,11 +6,9 @@ import { module, test } from 'qunit'; import { click, currentURL, fillIn, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { setupIntl } from 'ember-intl/test-support'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; @@ -18,7 +16,6 @@ import { TYPE_TARGET_RDP, TYPE_TARGET_SSH } from 'api/models/target'; module('Acceptance | targets | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); setupIntl(hooks, 'en-us'); @@ -26,7 +23,6 @@ module('Acceptance | targets | update', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -45,7 +41,6 @@ module('Acceptance | targets | update', function (hooks) { hooks.beforeEach(async function () { featuresService = this.owner.lookup('service:features'); // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -73,8 +68,6 @@ module('Acceptance | targets | update', function (hooks) { urls.target = `${urls.targets}/${instances.target.id}`; urls.rdpTarget = `${urls.targets}/${instances.rdpTarget.id}`; urls.sshTarget = `${urls.targets}/${instances.sshTarget.id}`; - - await authenticateSession({}); }); test('can save changes to existing target', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/workers-test.js b/ui/admin/tests/acceptance/targets/workers-test.js index b0705437f..f4ca686f9 100644 --- a/ui/admin/tests/acceptance/targets/workers-test.js +++ b/ui/admin/tests/acceptance/targets/workers-test.js @@ -6,16 +6,13 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | targets | workers', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let intl; @@ -27,7 +24,6 @@ module('Acceptance | targets | workers', function (hooks) { const instances = { scopes: { - global: null, org: null, project: null, }, @@ -48,7 +44,6 @@ module('Acceptance | targets | workers', function (hooks) { featuresService = this.owner.lookup('service:features'); featureEdition = this.owner.lookup('service:featureEdition'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -69,8 +64,6 @@ module('Acceptance | targets | workers', function (hooks) { urls.targetWorkers = `${urls.target}/workers`; urls.targetEditEgressFilter = `${urls.target}/edit-egress-worker-filter`; urls.targetEditIngressFilter = `${urls.target}/edit-ingress-worker-filter`; - - await authenticateSession({ username: 'admin' }); }); test('visiting target workers', async function (assert) { diff --git a/ui/admin/tests/acceptance/users/accounts-test.js b/ui/admin/tests/acceptance/users/accounts-test.js index 18f151668..4c8aeea13 100644 --- a/ui/admin/tests/acceptance/users/accounts-test.js +++ b/ui/admin/tests/acceptance/users/accounts-test.js @@ -6,10 +6,8 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_AUTH_METHOD_PASSWORD, TYPE_AUTH_METHOD_LDAP, @@ -21,7 +19,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | users | accounts', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let accountsCount; @@ -29,7 +26,6 @@ module('Acceptance | users | accounts', function (hooks) { const instances = { scopes: { - global: null, org: null, }, user: null, @@ -43,8 +39,6 @@ module('Acceptance | users | accounts', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -298,8 +292,8 @@ module('Acceptance | users | accounts', function (hooks) { authMethod, }); const accountsAvailableCount = - this.server.schema.accounts.all().length - - instances.user.accountIds.length; + this.server.schema.accounts.where({ scopeId: instances.scopes.org.id }) + .length - instances.user.accountIds.length; await visit(urls.user); await click(commonSelectors.HREF(urls.accounts)); @@ -332,8 +326,8 @@ module('Acceptance | users | accounts', function (hooks) { authMethod, }); const accountsAvailableCount = - this.server.schema.accounts.all().length - - instances.user.accountIds.length; + this.server.schema.accounts.where({ scopeId: instances.scopes.org.id }) + .length - instances.user.accountIds.length; await visit(urls.user); await click(commonSelectors.HREF(urls.accounts)); @@ -470,9 +464,7 @@ module('Acceptance | users | accounts', function (hooks) { }, }); - this.server.schema.authMethods.all().destroy(); this.server.schema.users.all().destroy(); - this.server.schema.accounts.all().destroy(); const authMethod = this.server.create( 'auth-method', @@ -508,9 +500,7 @@ module('Acceptance | users | accounts', function (hooks) { }, }); - this.server.schema.authMethods.all().destroy(); this.server.schema.users.all().destroy(); - this.server.schema.accounts.all().destroy(); const authMethod = this.server.create( 'auth-method', diff --git a/ui/admin/tests/acceptance/users/create-test.js b/ui/admin/tests/acceptance/users/create-test.js index 0c1c5223c..f27bcaea1 100644 --- a/ui/admin/tests/acceptance/users/create-test.js +++ b/ui/admin/tests/acceptance/users/create-test.js @@ -6,23 +6,19 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | users | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getUsersCount; const instances = { scopes: { - global: null, org: null, }, user: null, @@ -36,7 +32,6 @@ module('Acceptance | users | create', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -51,7 +46,6 @@ module('Acceptance | users | create', function (hooks) { getUsersCount = () => { return this.server.schema.users.all().models.length; }; - await authenticateSession({}); }); test('can create new users', async function (assert) { diff --git a/ui/admin/tests/acceptance/users/delete-test.js b/ui/admin/tests/acceptance/users/delete-test.js index f689ec7b8..c02d49cc8 100644 --- a/ui/admin/tests/acceptance/users/delete-test.js +++ b/ui/admin/tests/acceptance/users/delete-test.js @@ -6,17 +6,14 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | users | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let getUsersCount, confirmService; @@ -36,7 +33,6 @@ module('Acceptance | users | delete', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -49,8 +45,6 @@ module('Acceptance | users | delete', function (hooks) { urls.user = `${urls.users}/${instances.user.id}`; getUsersCount = () => this.server.schema.users.all().models.length; confirmService = this.owner.lookup('service:confirm'); - - await authenticateSession({}); }); test('can delete a user', async function (assert) { diff --git a/ui/admin/tests/acceptance/users/list-test.js b/ui/admin/tests/acceptance/users/list-test.js index 8c8f0d1e4..3576326dd 100644 --- a/ui/admin/tests/acceptance/users/list-test.js +++ b/ui/admin/tests/acceptance/users/list-test.js @@ -13,9 +13,7 @@ import { currentURL, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { faker } from '@faker-js/faker'; @@ -23,12 +21,10 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | users | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const instances = { scopes: { - global: null, org: null, }, user1: null, @@ -44,7 +40,6 @@ module('Acceptance | users | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -60,7 +55,6 @@ module('Acceptance | users | list', function (hooks) { urls.users = `${urls.orgScope}/users`; urls.user1 = `${urls.users}/${instances.user1.id}`; urls.user2 = `${urls.users}/${instances.user2.id}`; - await authenticateSession({}); }); test('users can navigate to users with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/users/read-test.js b/ui/admin/tests/acceptance/users/read-test.js index 28f405cbc..92140c2e5 100644 --- a/ui/admin/tests/acceptance/users/read-test.js +++ b/ui/admin/tests/acceptance/users/read-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | users | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); const urls = { @@ -25,14 +22,12 @@ module('Acceptance | users | read', function (hooks) { const instances = { scopes: { - global: null, org: null, }, user: null, }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -43,7 +38,6 @@ module('Acceptance | users | read', function (hooks) { urls.orgScope = `/scopes/${instances.scopes.org.id}`; urls.users = `${urls.orgScope}/users`; urls.user = `${urls.users}/${instances.user.id}`; - await authenticateSession({ username: 'admin' }); }); test('visiting users', async function (assert) { diff --git a/ui/admin/tests/acceptance/users/update-test.js b/ui/admin/tests/acceptance/users/update-test.js index 8c82f4175..53ac47395 100644 --- a/ui/admin/tests/acceptance/users/update-test.js +++ b/ui/admin/tests/acceptance/users/update-test.js @@ -6,16 +6,13 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | users | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let confirmService; @@ -28,14 +25,12 @@ module('Acceptance | users | update', function (hooks) { const instances = { scopes: { - global: null, org: null, }, user: null, }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -47,8 +42,6 @@ module('Acceptance | users | update', function (hooks) { urls.users = `${urls.orgScope}/users`; urls.user = `${urls.users}/${instances.user.id}`; confirmService = this.owner.lookup('service:confirm'); - - await authenticateSession({}); }); test('can save changes to an existing user', async function (assert) { diff --git a/ui/admin/tests/acceptance/workers/create-tags-test.js b/ui/admin/tests/acceptance/workers/create-tags-test.js index 547d251ef..fa40318dd 100644 --- a/ui/admin/tests/acceptance/workers/create-tags-test.js +++ b/ui/admin/tests/acceptance/workers/create-tags-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, currentURL, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | workers | worker | create-tags', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); let confirmService; @@ -33,7 +30,7 @@ module('Acceptance | workers | worker | create-tags', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.worker = this.server.create('worker', { scope: instances.scopes.global, }); @@ -42,8 +39,6 @@ module('Acceptance | workers | worker | create-tags', function (hooks) { urls.tags = `${urls.worker}/tags`; urls.createTags = `${urls.worker}/create-tags`; confirmService = this.owner.lookup('service:confirm'); - - await authenticateSession({ username: 'admin' }); }); test('visiting worker create tags', async function (assert) { diff --git a/ui/admin/tests/acceptance/workers/create-test.js b/ui/admin/tests/acceptance/workers/create-test.js index df9d535ba..7534285c9 100644 --- a/ui/admin/tests/acceptance/workers/create-test.js +++ b/ui/admin/tests/acceptance/workers/create-test.js @@ -6,16 +6,13 @@ import { module, test } from 'qunit'; import { visit, fillIn, click, findAll, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | workers | create', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); let globalScope; let workersURL; @@ -24,14 +21,12 @@ module('Acceptance | workers | create', function (hooks) { let featuresService; hooks.beforeEach(async function () { - globalScope = this.server.create('scope', { id: 'global' }); + globalScope = this.server.schema.scopes.find('global'); workersURL = `/scopes/global/workers`; newWorkerURL = `${workersURL}/new`; getWorkersCount = () => this.server.schema.workers.all().length; featuresService = this.owner.lookup('service:features'); - - await authenticateSession({}); }); test('can create new workers', async function (assert) { diff --git a/ui/admin/tests/acceptance/workers/delete-test.js b/ui/admin/tests/acceptance/workers/delete-test.js index b58e025c2..96577b772 100644 --- a/ui/admin/tests/acceptance/workers/delete-test.js +++ b/ui/admin/tests/acceptance/workers/delete-test.js @@ -6,18 +6,15 @@ import { module, test } from 'qunit'; import { visit, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; import { resolve, reject } from 'rsvp'; import sinon from 'sinon'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | workers | delete', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); let getWorkerCount, confirmService; @@ -35,7 +32,7 @@ module('Acceptance | workers | delete', function (hooks) { hooks.beforeEach(async function () { // Generate resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.worker = this.server.create('worker', { scope: instances.scopes.global, }); @@ -46,8 +43,6 @@ module('Acceptance | workers | delete', function (hooks) { getWorkerCount = () => this.server.schema.workers.all().models.length; confirmService = this.owner.lookup('service:confirm'); - - await authenticateSession({}); }); test('can delete a worker', async function (assert) { diff --git a/ui/admin/tests/acceptance/workers/list-test.js b/ui/admin/tests/acceptance/workers/list-test.js index 31b4f5953..a43416523 100644 --- a/ui/admin/tests/acceptance/workers/list-test.js +++ b/ui/admin/tests/acceptance/workers/list-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, click, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | workers | list', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); let featuresService; @@ -34,7 +31,7 @@ module('Acceptance | workers | list', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.worker = this.server.create('worker', { scope: instances.scopes.global, }); @@ -45,7 +42,6 @@ module('Acceptance | workers | list', function (hooks) { urls.workers = `/scopes/global/workers`; urls.worker = `${urls.workers}/${instances.worker.id}`; urls.workerTags = `${urls.worker}/tags`; - await authenticateSession({}); featuresService = this.owner.lookup('service:features'); }); diff --git a/ui/admin/tests/acceptance/workers/read-test.js b/ui/admin/tests/acceptance/workers/read-test.js index d5aa0d7b5..843ff86f9 100644 --- a/ui/admin/tests/acceptance/workers/read-test.js +++ b/ui/admin/tests/acceptance/workers/read-test.js @@ -6,15 +6,12 @@ import { module, test } from 'qunit'; import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | workers | read', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupSqlite(hooks); let featuresService; @@ -35,7 +32,7 @@ module('Acceptance | workers | read', function (hooks) { hooks.beforeEach(async function () { //Generate the resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -50,7 +47,6 @@ module('Acceptance | workers | read', function (hooks) { featuresService = this.owner.lookup('service:features'); featuresService.enable('byow'); - await authenticateSession({ username: 'admin' }); }); test('visiting worker', async function (assert) { diff --git a/ui/admin/tests/acceptance/workers/tags-test.js b/ui/admin/tests/acceptance/workers/tags-test.js index 55a7e0fad..22d232ae6 100644 --- a/ui/admin/tests/acceptance/workers/tags-test.js +++ b/ui/admin/tests/acceptance/workers/tags-test.js @@ -13,8 +13,6 @@ import { find, } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import { HCP_MANAGED_KEY } from 'api/models/worker'; import * as commonSelectors from 'admin/tests/helpers/selectors'; import * as selectors from './selectors'; @@ -22,7 +20,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | workers | worker | tags', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { @@ -38,7 +35,7 @@ module('Acceptance | workers | worker | tags', function (hooks) { }; hooks.beforeEach(async function () { - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.worker = this.server.create('worker', { scope: instances.scopes.global, }); @@ -46,7 +43,6 @@ module('Acceptance | workers | worker | tags', function (hooks) { urls.worker = `${urls.workers}/${instances.worker.id}`; urls.tags = `${urls.worker}/tags`; urls.createTags = `${urls.worker}/create-tags`; - await authenticateSession({ username: 'admin' }); }); test('visiting worker tags', async function (assert) { diff --git a/ui/admin/tests/acceptance/workers/update-test.js b/ui/admin/tests/acceptance/workers/update-test.js index 305e320ff..ad58cbae3 100644 --- a/ui/admin/tests/acceptance/workers/update-test.js +++ b/ui/admin/tests/acceptance/workers/update-test.js @@ -6,14 +6,11 @@ import { module, test } from 'qunit'; import { visit, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'admin/tests/helpers'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { Response } from 'miragejs'; -import { authenticateSession } from 'ember-simple-auth/test-support'; import * as commonSelectors from 'admin/tests/helpers/selectors'; module('Acceptance | workers | update', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); const instances = { scopes: { @@ -29,15 +26,14 @@ module('Acceptance | workers | update', function (hooks) { hooks.beforeEach(async function () { //Generate the resources - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); instances.worker = this.server.create('worker', { scope: instances.scopes.global, }); // Generate route URLs for resources urls.globalScope = '/scopes/global'; urls.workers = `${urls.globalScope}/workers`; - (urls.worker = `${urls.workers}/${instances.worker.id}`), - await authenticateSession({}); + urls.worker = `${urls.workers}/${instances.worker.id}`; }); test('can save changes to an existing worker', async function (assert) { diff --git a/ui/admin/tests/helpers/index.js b/ui/admin/tests/helpers/index.js index 2d6c53909..31e6d0d34 100644 --- a/ui/admin/tests/helpers/index.js +++ b/ui/admin/tests/helpers/index.js @@ -9,6 +9,7 @@ import { setupTest as upstreamSetupTest, } from 'ember-qunit'; import { authenticateSession } from 'ember-simple-auth/test-support'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; // This file exists to provide wrappers around ember-qunit's // test setup functions. This way, you can easily extend the setup that is @@ -18,19 +19,19 @@ function setupApplicationTest(hooks, options) { upstreamSetupApplicationTest(hooks, options); // Additional setup for application tests can be done here. - // - // For example, if you need an authenticated session for each - // application test, you could do: - // + + setupMirage(hooks); + hooks.beforeEach(async function () { - await authenticateSession(); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + const account_id = this.server.schema.accounts.first().id; + await authenticateSession({ isGlobal: true, account_id }); }); // // This is also a good place to call test setup functions coming // from other addons: // // setupIntl(hooks, 'en-us'); // ember-intl - // setupMirage(hooks); // ember-cli-mirage } function setupRenderingTest(hooks, options) { diff --git a/ui/admin/tests/unit/controllers/account/change-password-test.js b/ui/admin/tests/unit/controllers/account/change-password-test.js index c144130c1..20369c7e4 100644 --- a/ui/admin/tests/unit/controllers/account/change-password-test.js +++ b/ui/admin/tests/unit/controllers/account/change-password-test.js @@ -9,7 +9,6 @@ import { visit } from '@ember/test-helpers'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupSqlite } from 'api/test-support/helpers/sqlite'; import { authenticateSession } from 'ember-simple-auth/test-support'; -import { TYPE_AUTH_METHOD_PASSWORD } from 'api/models/auth-method'; module('Unit | Controller | account/change-password', function (hooks) { setupTest(hooks); @@ -34,23 +33,21 @@ module('Unit | Controller | account/change-password', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + instances.authMethod = this.server.schema.authMethods.first(); + instances.account = this.server.schema.accounts.first(); + await authenticateSession({ + isGlobal: true, + account_id: instances.account.id, + }); + controller = this.owner.lookup('controller:account/change-password'); store = this.owner.lookup('service:store'); - instances.scopes.global = this.server.create('scope', { - id: 'global', - type: 'global', - }); - instances.authMethod = this.server.create('auth-method', { - scope: instances.scopes.global, - type: TYPE_AUTH_METHOD_PASSWORD, - }); - instances.account = this.server.create('account', { - scope: instances.scopes.global, - authMethod: instances.authMethod, - }); - urls.globalScope = `/scopes/global`; }); diff --git a/ui/admin/tests/unit/controllers/onboarding/index-test.js b/ui/admin/tests/unit/controllers/onboarding/index-test.js index 69359d029..bc9670b15 100644 --- a/ui/admin/tests/unit/controllers/onboarding/index-test.js +++ b/ui/admin/tests/unit/controllers/onboarding/index-test.js @@ -36,13 +36,19 @@ module('Unit | Controller | onboarding/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:onboarding/index'); - instances.scopes.global = this.server.create('scope', { - id: 'global', - type: 'global', + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + instances.authMethod = this.server.schema.authMethods.first(); + instances.account = this.server.schema.accounts.first(); + await authenticateSession({ + isGlobal: true, + account_id: instances.account.id, }); urls.onboarding = '/onboarding'; diff --git a/ui/admin/tests/unit/controllers/onboarding/success-test.js b/ui/admin/tests/unit/controllers/onboarding/success-test.js index 6ab61e80d..d4851b08d 100644 --- a/ui/admin/tests/unit/controllers/onboarding/success-test.js +++ b/ui/admin/tests/unit/controllers/onboarding/success-test.js @@ -33,13 +33,19 @@ module('Unit | Controller | onboarding/success', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); controller = this.owner.lookup('controller:onboarding/success'); store = this.owner.lookup('service:store'); - instances.scopes.global = this.server.create('scope', { - id: 'global', - type: 'global', + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + instances.authMethod = this.server.schema.authMethods.first(); + instances.account = this.server.schema.accounts.first(); + await authenticateSession({ + isGlobal: true, + account_id: instances.account.id, }); instances.scopes.org = this.server.create('scope', { type: 'org', diff --git a/ui/admin/tests/unit/controllers/scopes/scope/add-storage-policy/create-test.js b/ui/admin/tests/unit/controllers/scopes/scope/add-storage-policy/create-test.js index a141f6bd6..bc07d9f31 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/add-storage-policy/create-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/add-storage-policy/create-test.js @@ -31,15 +31,22 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/add-storage-policy/create', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.policy = this.server.create('policy', { - scopeId: 'global', + scope: instances.scopes.global, }); urls.globalScope = `/scopes/global`; diff --git a/ui/admin/tests/unit/controllers/scopes/scope/add-storage-policy/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/add-storage-policy/index-test.js index 4e47c19c0..ee24fbb5b 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/add-storage-policy/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/add-storage-policy/index-test.js @@ -31,15 +31,22 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/add-storage-policy/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.policy = this.server.create('policy', { - scopeId: 'global', + scope: instances.scopes.global, }); urls.globalScope = `/scopes/global`; diff --git a/ui/admin/tests/unit/controllers/scopes/scope/aliases/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/aliases/index-test.js index 0bdf211bd..f008be8c3 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/aliases/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/aliases/index-test.js @@ -35,12 +35,19 @@ module('Unit | Controller | scopes/scope/aliases/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/aliases/index'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.alias = this.server.create('alias', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js index 015457708..5b607c6d7 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js @@ -9,7 +9,6 @@ import { visit } from '@ember/test-helpers'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupIntl } from 'ember-intl/test-support'; import { authenticateSession } from 'ember-simple-auth/test-support'; -import { TYPE_AUTH_METHOD_PASSWORD } from 'api/models/auth-method'; module( 'Unit | Controller | scopes/scope/auth-methods/auth-method/accounts/index', @@ -36,24 +35,22 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); controller = this.owner.lookup( 'controller:scopes/scope/auth-methods/auth-method/accounts/index', ); store = this.owner.lookup('service:store'); - instances.scopes.global = this.server.create('scope', { - id: 'global', - type: 'global', - }); - instances.authMethod = this.server.create('auth-method', { - scope: instances.scopes.global, - type: TYPE_AUTH_METHOD_PASSWORD, - }); - instances.account = this.server.create('account', { - scope: instances.scopes.global, - authMethod: instances.authMethod, + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + instances.authMethod = this.server.schema.authMethods.first(); + instances.account = this.server.schema.accounts.first(); + await authenticateSession({ + isGlobal: true, + account_id: instances.account.id, }); getAccountCount = () => this.server.schema.accounts.all().models.length; diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js index aaa61b2db..d8930ea68 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js @@ -36,16 +36,20 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); controller = this.owner.lookup( 'controller:scopes/scope/auth-methods/auth-method/managed-groups/index', ); store = this.owner.lookup('service:store'); - instances.scopes.global = this.server.create('scope', { - id: 'global', - type: 'global', + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, }); instances.authMethod = this.server.create('auth-method', { scope: instances.scopes.global, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js index c06477af5..ee192a053 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js @@ -29,7 +29,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { let getAuthMethodCount; const instances = { - scope: { + scopes: { global: null, }, authMethod: null, @@ -40,16 +40,21 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/auth-methods/index', ); - instances.scope.global = this.server.create('scope', { id: 'global' }); - instances.authMethod = this.server.create('auth-method', { - scope: instances.scope.global, + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + instances.authMethod = this.server.schema.authMethods.first(); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, }); urls.authMethods = '/scopes/global/auth-methods'; @@ -148,7 +153,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { ); await controller.makePrimary(authMethod); - const scope = await store.findRecord('scope', instances.scope.global.id); + const scope = await store.findRecord('scope', instances.scopes.global.id); assert.strictEqual(scope.primary_auth_method_id, instances.authMethod.id); }); @@ -161,7 +166,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { ); await controller.removeAsPrimary(authMethod); - const scope = await store.findRecord('scope', instances.scope.global.id); + const scope = await store.findRecord('scope', instances.scopes.global.id); assert.notOk(scope.primary_auth_method_id); }); @@ -249,7 +254,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { }); test('messageDescription returns correct translation with create authorization', async function (assert) { - instances.scope.global.authorized_collection_actions['auth-methods'] = [ + instances.scopes.global.authorized_collection_actions['auth-methods'] = [ 'create', ]; await visit(urls.authMethods); @@ -263,7 +268,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { }); test('messageDescription returns correct translation with no authorization', async function (assert) { - instances.scope.global.authorized_collection_actions['auth-methods'] = []; + instances.scopes.global.authorized_collection_actions['auth-methods'] = []; await visit(urls.authMethods); assert.strictEqual( diff --git a/ui/admin/tests/unit/controllers/scopes/scope/authenticate/method/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/authenticate/method/index-test.js index 484da28a6..6926255c4 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/authenticate/method/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/authenticate/method/index-test.js @@ -5,18 +5,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { visit } from '@ember/test-helpers'; +import { visit, currentURL, settled } from '@ember/test-helpers'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { setupSqlite } from 'api/test-support/helpers/sqlite'; -import { authenticateSession } from 'ember-simple-auth/test-support'; -import { TYPE_AUTH_METHOD_PASSWORD } from 'api/models/auth-method'; module( 'Unit | Controller | scopes/scope/authenticate/method/index', function (hooks) { setupTest(hooks); setupMirage(hooks); - setupSqlite(hooks); let controller; let store; @@ -25,8 +21,10 @@ module( const instances = { scopes: { global: null, + org: null, }, authMethod: null, + account: null, }; const urls = { @@ -35,51 +33,56 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); controller = this.owner.lookup( 'controller:scopes/scope/authenticate/method/index', ); store = this.owner.lookup('service:store'); session = this.owner.lookup('service:session'); - instances.scopes.global = this.server.create('scope', { - id: 'global', - type: 'global', - }); - instances.authMethod = this.server.create('auth-method', { - scope: instances.scopes.global, - type: TYPE_AUTH_METHOD_PASSWORD, + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + instances.authMethod = this.server.schema.authMethods.first(); + instances.account = this.server.schema.accounts.first(); + instances.scopes.org = this.server.create('scope', { + type: 'org', + scope: { id: 'global', type: 'global' }, }); urls.globalScope = '/scopes/global/scopes'; urls.authenticate = `scopes/global/authenticate/${instances.authMethod}`; }); - test('authenticate action saves login information and redirects to correct page', async function (assert) { + test('authenticate action saves auth information and redirects to correct page', async function (assert) { await visit(urls.authenticate); - const identification = 'admin123'; + const identification = instances.account.attributes.login_name; const authMethod = await store.findRecord( 'auth-method', instances.authMethod.id, ); - const { authenticator: authBefore, username: usernameBefore } = + const { authenticator: authBefore, account_id: accountIdBefore } = session.data.authenticated; - assert.notOk(usernameBefore); - assert.strictEqual(authBefore, 'authenticator:test'); + assert.notOk(accountIdBefore); + assert.notOk(authBefore); + assert.ok(identification); await controller.authenticate(authMethod, { identification, password: 'password', }); - const { authenticator: authAfter, username: usernameAfter } = - session.data.authenticated; + await settled(); + const { authenticator: authAfter, account_id: accountIdAfter } = + session.data.authenticated; assert.strictEqual( authAfter, `authenticator:${instances.authMethod.type}`, ); - assert.strictEqual(usernameAfter, identification); + assert.strictEqual(accountIdAfter, instances.account.id); + assert.strictEqual(currentURL(), urls.globalScope); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js index c5437b006..63184481d 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js @@ -27,7 +27,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -40,14 +39,17 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/credential-store/credential-libraries/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js index f5b6be3ae..bdd98687d 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js @@ -27,7 +27,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -40,14 +39,17 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/credential-store/credentials/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js index f0e12f4cd..158907e58 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js @@ -30,7 +30,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -42,14 +41,17 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/index', ); store = this.owner.lookup('service:store'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/groups/group/add-members-test.js b/ui/admin/tests/unit/controllers/scopes/scope/groups/group/add-members-test.js index 8318a8f71..85d1f9411 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/groups/group/add-members-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/groups/group/add-members-test.js @@ -37,13 +37,20 @@ module( scopes: [{ id: 'global', type: 'global' }], }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/groups/group/add-members', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js index 1ddb187e8..b64defcac 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js @@ -35,12 +35,19 @@ module('Unit | Controller | scopes/scope/groups/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/groups/index'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.group = this.server.create('group', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts-test.js index fdce206b9..8821ea9fa 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts-test.js @@ -22,7 +22,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -36,13 +35,16 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host-test.js index 986803bd1..ba584d7b2 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host-test.js @@ -22,7 +22,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -36,13 +35,16 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js index d64fbcd84..d9c218e3e 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js @@ -26,7 +26,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -39,14 +38,17 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/host-catalogs/host-catalog/host-sets/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js index 05e1ceff1..c25faf3b4 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js @@ -25,7 +25,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -38,14 +37,17 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/host-catalogs/host-catalog/hosts/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js index fa186b8cf..0ac661a03 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js @@ -26,7 +26,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -38,14 +37,17 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/host-catalogs/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/index-test.js index 7186fcdfc..f385088f9 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/index-test.js @@ -34,11 +34,14 @@ module('Unit | Controller | scopes/scope/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/index'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js index e3e3c6bd1..106089b30 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js @@ -32,12 +32,19 @@ module('Unit | Controller | scopes/scope/policies/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/policies/index'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.policy = this.server.create('policy', { scopeId: 'global', }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js index 511aa5af8..e97d09f5a 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js @@ -36,12 +36,19 @@ module('Unit | Controller | scopes/scope/roles/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/roles/index'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.role = this.server.create('role', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/add-principals-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/add-principals-test.js index bff964f9d..d6f34ae87 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/add-principals-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/add-principals-test.js @@ -38,13 +38,20 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/roles/role/add-principals', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/grants-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/grants-test.js index b70767d37..74fb73978 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/grants-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/grants-test.js @@ -28,11 +28,18 @@ module('Unit | Controller | scopes/scope/roles/role/grants', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/roles/role/grants'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.role = this.server.create('role', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/index-test.js index ad75c104b..8c123a561 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/index-test.js @@ -33,15 +33,22 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/roles/role/manage-scopes/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.role = this.server.create('role', { - scopeId: 'global', + scope: instances.scopes.global, grant_scope_ids: [], }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-custom-scopes-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-custom-scopes-test.js index d154be667..57db1f8f4 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-custom-scopes-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-custom-scopes-test.js @@ -22,7 +22,6 @@ module( const instances = { scopes: { - global: null, org: null, }, role: null, @@ -35,13 +34,16 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/roles/role/manage-scopes/manage-custom-scopes', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-org-projects-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-org-projects-test.js index 645bcc5a2..b9731e1bd 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-org-projects-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-org-projects-test.js @@ -36,15 +36,19 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/roles/role/manage-scopes/manage-org-projects', ); - instances.scopes.global = this.server.create('scope', { - id: 'global', - type: 'global', + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, }); instances.scopes.org = this.server.create('scope', { type: 'org', diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/scopes-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/scopes-test.js index 36fa962f2..deb2b9549 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/scopes-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/scopes-test.js @@ -37,10 +37,17 @@ module('Unit | Controller | scopes/scope/roles/role/scopes', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); controller = this.owner.lookup('controller:scopes/scope/roles/role/scopes'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.role = this.server.create('role', { scopeId: 'global', }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js index cdd0f597a..e7a2b3444 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js @@ -35,7 +35,6 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); features = this.owner.lookup('service:features'); store = this.owner.lookup('service:store'); @@ -43,7 +42,15 @@ module( 'controller:scopes/scope/storage-buckets/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.storageBucket = this.server.create('storage-bucket', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/index-test.js index 14d900cd6..75a7a4853 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/index-test.js @@ -50,13 +50,20 @@ module('Unit | Controller | scopes/scope/targets/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/targets/index'); features = this.owner.lookup('service:features'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-brokered-credential-sources-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-brokered-credential-sources-test.js index 8f2af7f47..db3ff4a1c 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-brokered-credential-sources-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-brokered-credential-sources-test.js @@ -31,7 +31,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -46,13 +45,16 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/targets/target/add-brokered-credential-sources', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-host-sources-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-host-sources-test.js index e96b5035f..5e2e8aeac 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-host-sources-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-host-sources-test.js @@ -22,7 +22,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -38,13 +37,16 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/targets/target/add-host-sources', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-injected-application-credential-sources-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-injected-application-credential-sources-test.js index 6a5654682..8c3e47ff5 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-injected-application-credential-sources-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/add-injected-application-credential-sources-test.js @@ -34,7 +34,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -49,13 +48,16 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/targets/target/add-injected-application-credential-sources', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/create-storage-bucket-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/create-storage-bucket-test.js index 9ee2f7aa9..8856543c2 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/create-storage-bucket-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/create-storage-bucket-test.js @@ -22,7 +22,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -36,13 +35,16 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/targets/target/enable-session-recording/create-storage-bucket', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/index-test.js index a6658d04a..107a2956f 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/index-test.js @@ -22,7 +22,6 @@ module( const instances = { scopes: { - global: null, org: null, project: null, }, @@ -35,13 +34,16 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/targets/target/enable-session-recording/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + this.server.create('scope', { id: 'global' }, 'withGlobalAuth'); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js index 07003ab40..1416498cc 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js @@ -35,12 +35,19 @@ module('Unit | Controller | scopes/scope/users/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/users/index'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.user = this.server.create('user', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/users/user/add-accounts-test.js b/ui/admin/tests/unit/controllers/scopes/scope/users/user/add-accounts-test.js index f4b6a05ac..9e787ac96 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/users/user/add-accounts-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/users/user/add-accounts-test.js @@ -32,13 +32,20 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/users/user/add-accounts', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.user = this.server.create('user', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/workers/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/workers/index-test.js index 958e57e4c..47cad4448 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/workers/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/workers/index-test.js @@ -37,12 +37,19 @@ module('Unit | Controller | scopes/scope/workers/index', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); intl = this.owner.lookup('service:intl'); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/workers/index'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.worker = this.server.create('worker', { scope: instances.scopes.global, config_tags: { type: ['dev'] }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/workers/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/workers/new-test.js index 3896a97fd..a7328b4c0 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/workers/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/workers/new-test.js @@ -28,11 +28,18 @@ module('Unit | Controller | scopes/scope/workers/new', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup('controller:scopes/scope/workers/new'); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.worker = this.server.create('worker', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/create-tags-test.js b/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/create-tags-test.js index 0e8cf7a89..50d89d20a 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/create-tags-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/create-tags-test.js @@ -32,13 +32,20 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/workers/worker/create-tags', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.worker = this.server.create('worker', { scope: instances.scopes.global, }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/tags-test.js b/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/tags-test.js index 1824c353a..291b87c9f 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/tags-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/tags-test.js @@ -35,13 +35,20 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/workers/worker/tags', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + await authenticateSession({ + isGlobal: true, + account_id: this.server.schema.accounts.first().id, + }); instances.worker = this.server.create('worker', { scope: instances.scopes.global, api_tags: apiTags, diff --git a/ui/desktop/app/components/settings-card/user/index.hbs b/ui/desktop/app/components/settings-card/user/index.hbs index f36f1bbe6..5c5171546 100644 --- a/ui/desktop/app/components/settings-card/user/index.hbs +++ b/ui/desktop/app/components/settings-card/user/index.hbs @@ -29,7 +29,7 @@ {{t 'form.username.label'}} - {{this.userInfo}} + {{this.session.username}} diff --git a/ui/desktop/app/components/settings-card/user/index.js b/ui/desktop/app/components/settings-card/user/index.js index e47a4818c..4526a1fa1 100644 --- a/ui/desktop/app/components/settings-card/user/index.js +++ b/ui/desktop/app/components/settings-card/user/index.js @@ -13,18 +13,6 @@ export default class SettingsUserInfoComponent extends Component { @service intl; // =attributes - /** - * Returns the username of the current user - * @type {string} - */ - get userInfo() { - const { - data: { - authenticated: { username }, - }, - } = this.session; - return username; - } /** * Returns true if user is authenticated @@ -36,7 +24,7 @@ export default class SettingsUserInfoComponent extends Component { } /** - * Returns the type of authmethod used by the user + * Returns the type of auth-method used by the user * @type {string} */ get authMethod() { diff --git a/ui/desktop/app/controllers/application.js b/ui/desktop/app/controllers/application.js index dab1c3eba..368fee5ab 100644 --- a/ui/desktop/app/controllers/application.js +++ b/ui/desktop/app/controllers/application.js @@ -18,10 +18,11 @@ export default class ApplicationController extends Controller { @service session; @service('browser/window') window; + // =attributes + @tracked isLoggingOut = false; @tracked isAppQuitting = false; - // =attributes removeOnAppQuitListener; constructor() { diff --git a/ui/desktop/app/routes/application.js b/ui/desktop/app/routes/application.js index 11c5f266e..6a1d9cfb6 100644 --- a/ui/desktop/app/routes/application.js +++ b/ui/desktop/app/routes/application.js @@ -49,6 +49,8 @@ export default class ApplicationRoute extends Route { tokenId: sessionData?.id, token: sessionData?.token, }); + + await this.session.loadAuthenticatedAccount(); } } diff --git a/ui/desktop/app/services/session.js b/ui/desktop/app/services/session.js index 1507ba9f1..ecac6b4e9 100644 --- a/ui/desktop/app/services/session.js +++ b/ui/desktop/app/services/session.js @@ -6,9 +6,13 @@ import { service } from '@ember/service'; import BaseSessionService from 'ember-simple-auth/services/session'; import { notifyError } from 'core/decorators/notify'; +import { tracked } from '@glimmer/tracking'; export default class SessionService extends BaseSessionService { @service ipc; + @service store; + + @tracked username; /** * Extend ember simple auth's handleAuthentication method @@ -24,6 +28,28 @@ export default class SessionService extends BaseSessionService { tokenId: sessionData?.id, token: sessionData?.token, }); + await this.loadAuthenticatedAccount(); + } + } + + /** + * Loads account used to authenticate so that it can be used to display + * the authenticated username. + */ + async loadAuthenticatedAccount() { + if (this.data?.authenticated?.account_id) { + try { + const account = await this.store.findRecord( + 'account', + this.data.authenticated.account_id, + ); + this.username = account.accountName; + } catch (e) { + // We are purposefully ignoring errors since loading the + // authenticated account should not block a user because + // account information is for populating a username. + console.error(e); + } } } } diff --git a/ui/desktop/app/templates/application.hbs b/ui/desktop/app/templates/application.hbs index 193cc65ee..d2a8a53da 100644 --- a/ui/desktop/app/templates/application.hbs +++ b/ui/desktop/app/templates/application.hbs @@ -49,19 +49,22 @@ /> {{/if}} - {{#if this.session.isAuthenticated}} + {{#if this.session.username}} - {{#if this.session.data.authenticated.username}} - - {{else}} - - {{/if}} + + + {{t 'actions.deauthenticate'}} + + + {{else}} + + targets.all()); // Generate scopes - instances.scopes.global = this.server.create('scope', { - id: 'global', - name: 'Global', - }); + instances.scopes.global = this.server.schema.scopes.find('global'); const globalScope = { id: 'global', type: 'global' }; instances.scopes.org = this.server.create('scope', { type: 'org', @@ -118,9 +111,7 @@ module('Acceptance | projects | targets | index', function (hooks) { }); // Generate resources - instances.authMethods.global = this.server.create('auth-method', { - scope: instances.scopes.global, - }); + instances.authMethods.global = this.server.schema.authMethods.first(); instances.hostCatalog = this.server.create( 'host-catalog', { scope: instances.scopes.project }, diff --git a/ui/desktop/tests/acceptance/projects/targets/target-test.js b/ui/desktop/tests/acceptance/projects/targets/target-test.js index 2d37f3233..5d4cac159 100644 --- a/ui/desktop/tests/acceptance/projects/targets/target-test.js +++ b/ui/desktop/tests/acceptance/projects/targets/target-test.js @@ -13,16 +13,13 @@ import { fillIn, waitFor, } from '@ember/test-helpers'; -import { setupApplicationTest } from 'ember-qunit'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; +import { setupApplicationTest } from 'desktop/tests/helpers'; import WindowMockIPC from '../../../helpers/window-mock-ipc'; import setupStubs from 'api/test-support/handlers/cache-daemon-search'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | projects | targets | target', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupStubs(hooks); const TARGET_RESOURCE_LINK = (id) => `[data-test-visit-target="${id}"]`; @@ -82,12 +79,11 @@ module('Acceptance | projects | targets | target', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession(); // bypass mirage config that expects recursive to be passed in as queryParam this.server.get('/targets', ({ targets }) => targets.all()); // Generate scopes - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); const globalScope = { id: 'global', type: 'global' }; instances.scopes.org = this.server.create('scope', { type: 'org', @@ -100,9 +96,7 @@ module('Acceptance | projects | targets | target', function (hooks) { }); // Generate resources - instances.authMethods.global = this.server.create('auth-method', { - scope: instances.scopes.global, - }); + instances.authMethods.global = this.server.schema.authMethods.first(); instances.hostCatalog = this.server.create( 'host-catalog', { scope: instances.scopes.project }, diff --git a/ui/desktop/tests/acceptance/scopes-test.js b/ui/desktop/tests/acceptance/scopes-test.js index 333dab2b7..46c30db09 100644 --- a/ui/desktop/tests/acceptance/scopes-test.js +++ b/ui/desktop/tests/acceptance/scopes-test.js @@ -12,12 +12,10 @@ import { findAll, waitFor, } from '@ember/test-helpers'; -import { setupApplicationTest } from 'ember-qunit'; -import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupApplicationTest } from 'desktop/tests/helpers'; import { Response } from 'miragejs'; import { currentSession, - authenticateSession, invalidateSession, } from 'ember-simple-auth/test-support'; import WindowMockIPC from '../helpers/window-mock-ipc'; @@ -26,7 +24,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Acceptance | scopes', function (hooks) { setupApplicationTest(hooks); - setupMirage(hooks); setupStubs(hooks); const APP_STATE_TITLE = '.hds-application-state__title'; @@ -81,12 +78,11 @@ module('Acceptance | scopes', function (hooks) { }; hooks.beforeEach(async function () { - await authenticateSession({ username: 'admin' }); // bypass mirage config that expects recursive to be passed in as queryParam this.server.get('/targets', ({ targets }) => targets.all()); // create scopes - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.schema.scopes.find('global'); const globalScope = { id: 'global', type: 'global' }; instances.scopes.org = this.server.create('scope', { type: 'org', @@ -102,9 +98,7 @@ module('Acceptance | scopes', function (hooks) { scope: orgScope, }); - instances.authMethods.global = this.server.create('auth-method', { - scope: instances.scopes.global, - }); + instances.authMethods.global = this.server.schema.authMethods.first(); instances.hostCatalog = this.server.create( 'host-catalog', diff --git a/ui/desktop/tests/helpers/index.js b/ui/desktop/tests/helpers/index.js index b4c7ee08d..fd622411e 100644 --- a/ui/desktop/tests/helpers/index.js +++ b/ui/desktop/tests/helpers/index.js @@ -8,6 +8,8 @@ import { setupRenderingTest as upstreamSetupRenderingTest, setupTest as upstreamSetupTest, } from 'ember-qunit'; +import { authenticateSession } from 'ember-simple-auth/test-support'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; // This file exists to provide wrappers around ember-qunit's // test setup functions. This way, you can easily extend the setup that is @@ -21,15 +23,23 @@ function setupApplicationTest(hooks, options) { // For example, if you need an authenticated session for each // application test, you could do: // - // hooks.beforeEach(async function () { - // await authenticateSession(); // ember-simple-auth - // }); - // + setupMirage(hooks); + + hooks.beforeEach(async function () { + const scope = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + const account_id = this.server.schema.accounts.first().id; + const user = this.server.create('user', { scope }); + await authenticateSession({ isGlobal: true, account_id, user_id: user.id }); + }); + // This is also a good place to call test setup functions coming // from other addons: // // setupIntl(hooks, 'en-us'); // ember-intl - // setupMirage(hooks); // ember-cli-mirage } function setupRenderingTest(hooks, options) { diff --git a/ui/desktop/tests/integration/components/settings-card/user-test.js b/ui/desktop/tests/integration/components/settings-card/user-test.js index 5df7779a9..11e3525f3 100644 --- a/ui/desktop/tests/integration/components/settings-card/user-test.js +++ b/ui/desktop/tests/integration/components/settings-card/user-test.js @@ -12,7 +12,6 @@ import Service from '@ember/service'; const data = { authenticated: { - username: 'admin', authenticator: 'authenticator:password', }, }; @@ -35,6 +34,7 @@ module('Integration | Component | settings-card/user', function (hooks) { class extends Service { data = data; isAuthenticated = true; + username = 'admin'; }, ); @@ -55,6 +55,7 @@ module('Integration | Component | settings-card/user', function (hooks) { class extends Service { data = oidcData; isAuthenticated = true; + username = 'admin'; }, ); @@ -75,6 +76,7 @@ module('Integration | Component | settings-card/user', function (hooks) { class extends Service { data = ldapData; isAuthenticated = true; + username = 'admin'; }, ); diff --git a/ui/desktop/tests/unit/controllers/scopes/scope/authenticate/method/index-test.js b/ui/desktop/tests/unit/controllers/scopes/scope/authenticate/method/index-test.js index e3722ab15..4acf3a9e6 100644 --- a/ui/desktop/tests/unit/controllers/scopes/scope/authenticate/method/index-test.js +++ b/ui/desktop/tests/unit/controllers/scopes/scope/authenticate/method/index-test.js @@ -6,9 +6,9 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; -import { authenticateSession } from 'ember-simple-auth/test-support'; +import { visit, currentURL, settled } from '@ember/test-helpers'; import { setupIntl } from 'ember-intl/test-support'; -import { TYPE_AUTH_METHOD_PASSWORD } from 'api/models/auth-method'; +import WindowMockIPC from '../../../../../../helpers/window-mock-ipc'; module( 'Unit | Controller | scopes/scope/authenticate/method/index', @@ -24,26 +24,41 @@ module( const instances = { scopes: { global: null, + org: null, }, authMethod: null, + account: null, + }; + + const urls = { + targets: null, + }; + + const setDefaultClusterUrl = (test) => { + const windowOrigin = window.location.origin; + const clusterUrl = test.owner.lookup('service:clusterUrl'); + clusterUrl.rendererClusterUrl = windowOrigin; }; hooks.beforeEach(async function () { - await authenticateSession({}); controller = this.owner.lookup( 'controller:scopes/scope/authenticate/method/index', ); store = this.owner.lookup('service:store'); session = this.owner.lookup('service:session'); - instances.scopes.global = this.server.create('scope', { - id: 'global', - type: 'global', - }); - instances.authMethod = this.server.create('auth-method', { - scope: instances.scopes.global, - type: TYPE_AUTH_METHOD_PASSWORD, - }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + instances.authMethod = this.server.schema.authMethods.first(); + instances.account = this.server.schema.accounts.first(); + + urls.targets = '/scopes/global/projects/targets'; + + this.owner.register('service:browser/window', WindowMockIPC); + setDefaultClusterUrl(this); }); test('it exists', function (assert) { @@ -51,29 +66,34 @@ module( }); test('authenticate action saves login information', async function (assert) { - const identification = 'admin123'; + await visit('/'); + const identification = instances.account.attributes.login_name; const authMethod = await store.findRecord( 'auth-method', instances.authMethod.id, ); - const { authenticator: authBefore, username: usernameBefore } = + const { authenticator: authBefore, account_id: accountIdBefore } = session.data.authenticated; - assert.notOk(usernameBefore); - assert.strictEqual(authBefore, 'authenticator:test'); + assert.notOk(accountIdBefore); + assert.notOk(authBefore); + assert.ok(identification); await controller.authenticate(authMethod, { identification, password: 'password', }); - const { authenticator: authAfter, username: usernameAfter } = + await settled(); + + const { authenticator: authAfter, account_id: accountIdAfter } = session.data.authenticated; assert.strictEqual( authAfter, `authenticator:${instances.authMethod.type}`, ); - assert.strictEqual(usernameAfter, identification); + assert.strictEqual(instances.account.id, accountIdAfter); + assert.strictEqual(currentURL(), urls.targets); }); }, ); diff --git a/ui/desktop/tests/unit/controllers/scopes/scope/projects/sessions/index-test.js b/ui/desktop/tests/unit/controllers/scopes/scope/projects/sessions/index-test.js index c398245f5..39e3e55a4 100644 --- a/ui/desktop/tests/unit/controllers/scopes/scope/projects/sessions/index-test.js +++ b/ui/desktop/tests/unit/controllers/scopes/scope/projects/sessions/index-test.js @@ -44,13 +44,17 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/projects/sessions/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + instances.account = this.server.schema.accounts.first(); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -73,6 +77,7 @@ module( this.ipcStub.withArgs('isCacheDaemonRunning').returns(true); this.stubCacheDaemonSearch('sessions', 'sessions', 'targets'); + await authenticateSession({ account_id: instances.account.id }); }); test('it exists', function (assert) { diff --git a/ui/desktop/tests/unit/controllers/scopes/scope/projects/targets/index-test.js b/ui/desktop/tests/unit/controllers/scopes/scope/projects/targets/index-test.js index b7b191d64..4261f6424 100644 --- a/ui/desktop/tests/unit/controllers/scopes/scope/projects/targets/index-test.js +++ b/ui/desktop/tests/unit/controllers/scopes/scope/projects/targets/index-test.js @@ -48,13 +48,17 @@ module( }; hooks.beforeEach(async function () { - await authenticateSession({}); store = this.owner.lookup('service:store'); controller = this.owner.lookup( 'controller:scopes/scope/projects/targets/index', ); - instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.global = this.server.create( + 'scope', + { id: 'global' }, + 'withGlobalAuth', + ); + instances.account = this.server.schema.accounts.first(); instances.scopes.org = this.server.create('scope', { type: 'org', scope: { id: 'global', type: 'global' }, @@ -77,6 +81,7 @@ module( this.ipcStub.withArgs('isCacheDaemonRunning').returns(true); this.stubCacheDaemonSearch('sessions', 'targets', 'aliases', 'sessions'); + await authenticateSession({ account_id: instances.account.id }); }); test('it exists', function (assert) {