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',
|
||||
|
||||
Reference in new issue
Block a user