Skip to content

Commit

Permalink
Refactor icu 15872 await authenticatesession admin (#2603)
Browse files Browse the repository at this point in the history
* Add await for all authenticateSession within /tests/acceptance

* Add await for all authenticateSession within /tests/unit
  • Loading branch information
calcaide authored Dec 3, 2024
1 parent 055607b commit b64f187
Show file tree
Hide file tree
Showing 165 changed files with 312 additions and 312 deletions.
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/accounts/change-password-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module('Acceptance | accounts | change password', function (hooks) {
changePassword: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand All @@ -46,7 +46,7 @@ module('Acceptance | accounts | change password', function (hooks) {
instances.account = this.server.create('account', {
scope: instances.scopes.org,
});
authenticateSession({
await authenticateSession({
account_id: instances.account.id,
username: 'admin',
});
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/accounts/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ module('Acceptance | accounts | create', function (hooks) {
account: null,
};

hooks.beforeEach(function () {
authenticateSession({ username: 'admin' });
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',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/accounts/delete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ module('Acceptance | accounts | delete', function (hooks) {
account: null,
};

hooks.beforeEach(function () {
authenticateSession({ username: 'admin' });
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',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/accounts/list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module('Acceptance | accounts | list', function (hooks) {
account: null,
};

hooks.beforeEach(function () {
authenticateSession({});
hooks.beforeEach(async function () {
await authenticateSession({});
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/accounts/read-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module('Acceptance | accounts | read', function (hooks) {
account: null,
};

hooks.beforeEach(function () {
authenticateSession({ username: 'admin' });
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',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/accounts/set-password-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module('Acceptance | accounts | set password', function (hooks) {
setPassword: null,
};

hooks.beforeEach(function () {
authenticateSession({ username: 'admin' });
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',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/accounts/update-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module('Acceptance | accounts | update', function (hooks) {
account: null,
};

hooks.beforeEach(function () {
authenticateSession({ username: 'admin' });
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',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/aliases/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ module('Acceptance | aliases | create', function (hooks) {
newAlias: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
instances.scopes.global = this.server.create('scope', { id: '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');
authenticateSession({ username: 'admin' });
await authenticateSession({ username: 'admin' });
});

test('users can create a new alias with host and target info', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/aliases/delete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ module('Acceptance | aliases | delete', function (hooks) {
target: null,
};

hooks.beforeEach(function () {
authenticateSession({});
hooks.beforeEach(async function () {
await authenticateSession({});
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/aliases/list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module('Acceptance | aliases | list', function (hooks) {
aliasWithTarget: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand All @@ -71,7 +71,7 @@ module('Acceptance | aliases | list', function (hooks) {
urls.aliasWithTarget = `${urls.aliases}/${instances.aliasWithTarget.id}`;
intl = this.owner.lookup('service:intl');

authenticateSession({});
await authenticateSession({});
});

test('users can navigate to aliases with proper authorization', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/aliases/read-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module('Acceptance | aliases | read', function (hooks) {
unknownAlias: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand All @@ -48,7 +48,7 @@ module('Acceptance | aliases | read', function (hooks) {
urls.alias = `${urls.aliases}/${instances.alias.id}`;
urls.unknownAlias = `${urls.aliases}/foo`;

authenticateSession({ username: 'admin' });
await authenticateSession({ username: 'admin' });
});

test('visiting a alias', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/aliases/update-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module('Acceptance | aliases | update', function (hooks) {
target: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand All @@ -66,7 +66,7 @@ module('Acceptance | aliases | update', function (hooks) {
urls.alias = `${urls.aliases}/${instances.alias.id}`;
aliasCount = () => this.server.schema.aliases.all().models.length;

authenticateSession({});
await authenticateSession({});
});

test('users can update an exisiting alias', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/auth-methods/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ module('Acceptance | auth-methods | create', function (hooks) {
authMethod: null,
};

hooks.beforeEach(function () {
authenticateSession({});
hooks.beforeEach(async function () {
await authenticateSession({});
instances.orgScope = this.server.create(
'scope',
{
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/auth-methods/delete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ module('Acceptance | auth-methods | delete', function (hooks) {
ldapAuthMethod: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
// Setup Mirage mock resources for this test
authenticateSession({ username: 'admin' });
await authenticateSession({ username: 'admin' });
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/auth-methods/list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module('Acceptance | auth-methods | list', function (hooks) {
oidcAuthMethod: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create(
'scope',
Expand All @@ -70,7 +70,7 @@ module('Acceptance | auth-methods | list', function (hooks) {
urls.passwordAuthMethod = `${urls.authMethods}/${instances.passwordAuthMethod.id}`;
urls.oidcAuthMethod = `${urls.authMethods}/${instances.oidcAuthMethod.id}`;

authenticateSession({});
await authenticateSession({});
});

test('users can navigate to auth methods with proper authorization', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/auth-methods/oidc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ module('Acceptance | auth-methods | oidc', function (hooks) {
authMethod: null,
};

hooks.beforeEach(function () {
authenticateSession({ username: 'admin' });
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',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/auth-methods/read-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ module('Acceptance | auth-methods | read', function (hooks) {
oidcAuthMethodGlobal: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
// Setup Mirage mock resources for this test
authenticateSession({ username: 'admin' });
await authenticateSession({ username: 'admin' });
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/auth-methods/update-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ module('Acceptance | auth-methods | update', function (hooks) {
ldapAuthMethod: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
// Setup Mirage mock resources for this test
authenticateSession({ username: 'admin' });
await authenticateSession({ username: 'admin' });
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand Down
8 changes: 4 additions & 4 deletions ui/admin/tests/acceptance/authentication-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ module('Acceptance | authentication', function (hooks) {
});

test('visiting any authentication parent route while already authenticated with an org redirects to projects', async function (assert) {
authenticateSession({ scope });
await authenticateSession({ scope });
await visit(indexURL);
assert.strictEqual(currentURL(), projectsURL);
await visit(scopesURL);
Expand All @@ -250,7 +250,7 @@ module('Acceptance | authentication', function (hooks) {
});

test('visiting index or scopes routes while already authenticated with global redirects to orgs', async function (assert) {
authenticateSession({
await authenticateSession({
scope: { id: globalScope.id, type: globalScope.type },
});
await visit(indexURL);
Expand Down Expand Up @@ -316,7 +316,7 @@ module('Acceptance | authentication', function (hooks) {
});

test('401 responses result in deauthentication', async function (assert) {
authenticateSession({
await authenticateSession({
scope: { id: globalScope.id, type: globalScope.type },
});
await visit(orgsURL);
Expand All @@ -333,7 +333,7 @@ module('Acceptance | authentication', function (hooks) {
});

test('color theme is applied from session data', async function (assert) {
authenticateSession({
await authenticateSession({
scope: { id: globalScope.id, type: globalScope.type },
});
await visit(orgsURL);
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/credential-library/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module('Acceptance | credential-libraries | create', function (hooks) {
newCredentialLibrary: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
// Generate resources
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
Expand Down Expand Up @@ -71,7 +71,7 @@ module('Acceptance | credential-libraries | create', function (hooks) {
// Generate resource counter
getCredentialLibraryCount = () =>
this.server.schema.credentialLibraries.all().models.length;
authenticateSession({ username: 'admin' });
await authenticateSession({ username: 'admin' });
featuresService = this.owner.lookup('service:features');
});

Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/credential-library/delete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module('Acceptance | credential-libraries | delete', function (hooks) {
unknownCredentialLibrary: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
// Generate resources
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
Expand Down Expand Up @@ -73,7 +73,7 @@ module('Acceptance | credential-libraries | delete', function (hooks) {
// Generate resource counter
getCredentialLibraryCount = () =>
this.server.schema.credentialLibraries.all().models.length;
authenticateSession({});
await authenticateSession({});
});

test('can delete resource', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/credential-library/list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module('Acceptance | credential-libraries | list', function (hooks) {
credentialLibraries: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
Expand All @@ -56,7 +56,7 @@ module('Acceptance | credential-libraries | list', function (hooks) {
urls.credentialStore = `${urls.credentialStores}/${instances.credentialStore.id}`;
urls.credentialLibraries = `${urls.credentialStore}/credential-libraries`;
urls.credentialLibrary = `${urls.credentialLibraries}/${instances.credentialLibrary.id}`;
authenticateSession({});
await authenticateSession({});
});

test('Users can navigate to credential libraries with proper authorization', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/credential-library/read-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module('Acceptance | credential-libraries | read', function (hooks) {
vaultSshCredentialLibrary: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
// Generate resources
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
Expand Down Expand Up @@ -65,7 +65,7 @@ module('Acceptance | credential-libraries | read', function (hooks) {
urls.credentialLibrary = `${urls.credentialLibraries}/${instances.credentialLibrary.id}`;
urls.newCredentialLibrary = `${urls.credentialLibraries}/new`;
urls.unknownCredentialLibrary = `${urls.credentialLibraries}/foo`;
authenticateSession({ username: 'admin' });
await authenticateSession({ username: 'admin' });
});

test('can navigate to resource', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/credential-library/update-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module('Acceptance | credential-libraries | update', function (hooks) {
unknownCredentialLibrary: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
// Generate resources
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
Expand Down Expand Up @@ -81,7 +81,7 @@ module('Acceptance | credential-libraries | update', function (hooks) {
urls.credentialLibrary = `${urls.credentialLibraries}/${instances.credentialLibrary.id}`;
urls.newCredentialLibrary = `${urls.credentialLibraries}/new`;
urls.unknownCredentialLibrary = `${urls.credentialLibraries}/foo`;
authenticateSession({});
await authenticateSession({});
});

test('cannot update resource without proper authorization', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/tests/acceptance/credential-store/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module('Acceptance | credential-stores | create', function (hooks) {
newCredentialStore: null,
};

hooks.beforeEach(function () {
hooks.beforeEach(async function () {
// Generate resources
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
Expand Down Expand Up @@ -64,7 +64,7 @@ module('Acceptance | credential-stores | create', function (hooks) {
return this.server.schema.credentialStores.where({ type: 'vault' }).models
.length;
};
authenticateSession({});
await authenticateSession({});
featuresService = this.owner.lookup('service:features');
});

Expand Down
Loading

0 comments on commit b64f187

Please sign in to comment.