Refactor type to use const values (#1695)
* refactor: 💡 use auth-method type consts
This commit is contained in:
1 parent
8d77bc60b3
commit
fde4ec4e05
13 files changed
+55
-27
No files matched your search
@@ -7,6 +7,7 @@ import GeneratedRoleModel from '../generated/models/role';
|
||||
import { attr } from '@ember-data/model';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { all, resolve } from 'rsvp';
|
||||
import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
|
||||
|
||||
export default class RoleModel extends GeneratedRoleModel {
|
||||
// =services
|
||||
@@ -133,7 +134,7 @@ export default class RoleModel extends GeneratedRoleModel {
|
||||
// Collect all auth methods.
|
||||
const authMethods = this.resourceFilterStore.queryBy(
|
||||
'auth-method',
|
||||
{ type: 'oidc' },
|
||||
{ type: TYPE_AUTH_METHOD_OIDC },
|
||||
{ scope_id: 'global', recursive: true }
|
||||
);
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
|
||||
import { Factory } from 'miragejs';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { TYPE_AUTH_METHOD_PASSWORD } from 'api/models/auth-method';
|
||||
|
||||
/**
|
||||
* GeneratedAccountFactory
|
||||
*/
|
||||
export default Factory.extend({
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
created_time: () => faker.date.recent(),
|
||||
updated_time: () => faker.date.recent(),
|
||||
version: () => faker.datatype.number(),
|
||||
|
||||
@@ -30,7 +30,7 @@ module('Unit | Model | account', function (hooks) {
|
||||
assert.expect(2);
|
||||
store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('account', {
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
});
|
||||
assert.notOk(model.accountName);
|
||||
model.login_name = 'foobar';
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import {
|
||||
TYPE_AUTH_METHOD_PASSWORD,
|
||||
TYPE_AUTH_METHOD_OIDC,
|
||||
} from 'api/models/auth-method';
|
||||
|
||||
module('Unit | Serializer | account', function (hooks) {
|
||||
setupTest(hooks);
|
||||
@@ -14,7 +18,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('account');
|
||||
const record = store.createRecord('account', {
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
name: 'Name',
|
||||
auth_method_id: '1',
|
||||
description: 'Description',
|
||||
@@ -27,7 +31,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
const snapshot = record._createSnapshot();
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
name: 'Name',
|
||||
auth_method_id: '1',
|
||||
description: 'Description',
|
||||
@@ -48,7 +52,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
id: '1',
|
||||
type: 'account',
|
||||
attributes: {
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
name: 'Name',
|
||||
auth_method_id: '1',
|
||||
description: 'Description',
|
||||
@@ -65,7 +69,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.notOk(serializedRecord.attributes);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
name: 'Name',
|
||||
auth_method_id: '1',
|
||||
description: 'Description',
|
||||
@@ -78,7 +82,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('account');
|
||||
const record = store.createRecord('account', {
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
name: 'Name',
|
||||
auth_method_id: '1',
|
||||
description: 'Description',
|
||||
@@ -88,7 +92,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
const snapshot = record._createSnapshot();
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
name: 'Name',
|
||||
auth_method_id: '1',
|
||||
description: 'Description',
|
||||
@@ -104,7 +108,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('account');
|
||||
const record = store.createRecord('account', {
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
name: 'Name',
|
||||
auth_method_id: '1',
|
||||
description: 'Description',
|
||||
@@ -117,7 +121,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
};
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
name: 'Name',
|
||||
auth_method_id: '1',
|
||||
description: 'Description',
|
||||
@@ -138,7 +142,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('account');
|
||||
const record = store.createRecord('account', {
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
login_name: 'Login Name',
|
||||
@@ -162,7 +166,7 @@ module('Unit | Serializer | account', function (hooks) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('account');
|
||||
const record = store.createRecord('account', {
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
login_name: 'Login Name',
|
||||
|
||||
@@ -8,6 +8,11 @@ import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render, find } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
import { setupIntl } from 'ember-intl/test-support';
|
||||
import {
|
||||
TYPE_AUTH_METHOD_PASSWORD,
|
||||
TYPE_AUTH_METHOD_OIDC,
|
||||
TYPE_AUTH_METHOD_LDAP,
|
||||
} from 'api/models/auth-method';
|
||||
|
||||
module('Integration | Component | form | authenticate', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
@@ -18,7 +23,9 @@ module('Integration | Component | form | authenticate', function (hooks) {
|
||||
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
this.model = store.createRecord('auth-method', { type: 'ldap' });
|
||||
this.model = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_LDAP,
|
||||
});
|
||||
this.submit = () => {};
|
||||
this.disabled = () => {};
|
||||
|
||||
@@ -39,7 +46,9 @@ module('Integration | Component | form | authenticate', function (hooks) {
|
||||
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
this.model = store.createRecord('auth-method', { type: 'password' });
|
||||
this.model = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
});
|
||||
this.submit = () => {};
|
||||
this.disabled = () => {};
|
||||
|
||||
@@ -60,7 +69,9 @@ module('Integration | Component | form | authenticate', function (hooks) {
|
||||
|
||||
const store = this.owner.lookup('service:store');
|
||||
|
||||
this.model = store.createRecord('auth-method', { type: 'oidc' });
|
||||
this.model = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
this.submit = () => {};
|
||||
this.disabled = () => {};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { hash, all } from 'rsvp';
|
||||
import { loading } from 'ember-loading';
|
||||
import { notifySuccess, notifyError } from 'core/decorators/notify';
|
||||
import { resourceFilter } from 'core/decorators/resource-filter';
|
||||
import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
|
||||
|
||||
export default class ScopesScopeRolesRoleAddPrincipalsRoute extends Route {
|
||||
// =services
|
||||
@@ -75,12 +76,12 @@ export default class ScopesScopeRolesRoleAddPrincipalsRoute extends Route {
|
||||
const oidcAuthMethods = scopeIDs?.length
|
||||
? await this.resourceFilterStore.queryBy(
|
||||
'auth-method',
|
||||
{ scope_id: scopeIDs, type: 'oidc' },
|
||||
{ scope_id: scopeIDs, type: TYPE_AUTH_METHOD_OIDC },
|
||||
{ scope_id: 'global', recursive: true }
|
||||
)
|
||||
: await this.resourceFilterStore.queryBy(
|
||||
'auth-method',
|
||||
{ type: 'oidc' },
|
||||
{ type: TYPE_AUTH_METHOD_OIDC },
|
||||
{ scope_id: 'global', recursive: true }
|
||||
);
|
||||
//extract oidc authMethod IDs
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
// //currentSession,
|
||||
// //invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
|
||||
|
||||
module('Acceptance | auth methods | update', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -73,7 +74,7 @@ module('Acceptance | auth methods | update', function (hooks) {
|
||||
assert.expect(12);
|
||||
instances.authMethod = this.server.create('auth-method', {
|
||||
scope: instances.scopes.org,
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
await visit(`${urls.authMethods}/${instances.authMethod.id}`);
|
||||
await click('form [type="button"]:not(:disabled)', 'Activate edit mode');
|
||||
|
||||
@@ -25,6 +25,10 @@ import {
|
||||
invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
import Service from '@ember/service';
|
||||
import {
|
||||
TYPE_AUTH_METHOD_PASSWORD,
|
||||
TYPE_AUTH_METHOD_OIDC,
|
||||
} from 'api/models/auth-method';
|
||||
|
||||
module('Acceptance | authentication', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -76,15 +80,15 @@ module('Acceptance | authentication', function (hooks) {
|
||||
scope = { id: orgScope.id, type: orgScope.type };
|
||||
globalAuthMethod = this.server.create('auth-method', {
|
||||
scope: globalScope,
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
});
|
||||
authMethod = this.server.create('auth-method', {
|
||||
scope: orgScope,
|
||||
type: 'password',
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
});
|
||||
authMethodOIDC = this.server.create('auth-method', {
|
||||
scope: orgScope,
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
orgScopeID = orgScope.id;
|
||||
globalAuthMethodID = globalAuthMethod.id;
|
||||
|
||||
@@ -10,6 +10,7 @@ import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import { Response } from 'miragejs';
|
||||
import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
|
||||
|
||||
module('Acceptance | managed-groups | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -40,7 +41,7 @@ module('Acceptance | managed-groups | create', function (hooks) {
|
||||
});
|
||||
instances.authMethod = this.server.create('auth-method', {
|
||||
scope: instances.scopes.org,
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
instances.managedGroup = this.server.create('managed-group', {
|
||||
scope: instances.scopes.org,
|
||||
|
||||
@@ -10,6 +10,7 @@ import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import { Response } from 'miragejs';
|
||||
import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
|
||||
|
||||
module('Acceptance | managed-groups | delete', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -40,7 +41,7 @@ module('Acceptance | managed-groups | delete', function (hooks) {
|
||||
});
|
||||
instances.authMethod = this.server.create('auth-method', {
|
||||
scope: instances.scopes.org,
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
instances.managedGroup = this.server.create('managed-group', {
|
||||
scope: instances.scopes.org,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { visit, click, find } 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 { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
|
||||
|
||||
module('Acceptance | managed-groups | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -38,7 +39,7 @@ module('Acceptance | managed-groups | list', function (hooks) {
|
||||
});
|
||||
instances.authMethod = this.server.create('auth-method', {
|
||||
scope: instances.scopes.org,
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
instances.managedGroup = this.server.create('managed-group', {
|
||||
scope: instances.scopes.org,
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
//currentSession,
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
|
||||
|
||||
module('Acceptance | managed-groups | members', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -47,7 +48,7 @@ module('Acceptance | managed-groups | members', function (hooks) {
|
||||
'auth-method',
|
||||
{
|
||||
scope: instances.scopes.org,
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
},
|
||||
'withAccountsAndUsersAndManagedGroups'
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
|
||||
|
||||
module('Acceptance | managed-groups | read', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -39,7 +40,7 @@ module('Acceptance | managed-groups | read', function (hooks) {
|
||||
});
|
||||
instances.authMethod = this.server.create('auth-method', {
|
||||
scope: instances.scopes.org,
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
instances.managedGroup = this.server.create('managed-group', {
|
||||
scope: instances.scopes.org,
|
||||
|
||||
Reference in new issue
Block a user