Icu 9202 disable all actions for ldap auth method (#1683)
* refactor: 💡 disable all actions for ldap auth-method ✅ Closes: ICU-9202
This commit is contained in:
1 parent
4c80f8d8ff
commit
3b3d6ab50f
14 files changed
+424
-67
No files matched your search
@@ -6,13 +6,23 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import {
|
||||
TYPE_AUTH_METHOD_PASSWORD,
|
||||
TYPE_AUTH_METHOD_OIDC,
|
||||
TYPE_AUTH_METHOD_LDAP,
|
||||
} from 'api/models/auth-method';
|
||||
|
||||
module('Unit | Model | auth method', function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let store;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
store = this.owner.lookup('service:store');
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('auth-method', {});
|
||||
assert.ok(model);
|
||||
});
|
||||
@@ -32,13 +42,12 @@ module('Unit | Model | auth method', function (hooks) {
|
||||
return { id: '123abc' };
|
||||
}
|
||||
);
|
||||
const store = this.owner.lookup('service:store');
|
||||
store.push({
|
||||
data: {
|
||||
id: '123abc',
|
||||
type: 'auth-method',
|
||||
attributes: {
|
||||
type: 'oidc',
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
state: 'foobar',
|
||||
version: 1,
|
||||
scope: {
|
||||
@@ -51,4 +60,72 @@ module('Unit | Model | auth method', function (hooks) {
|
||||
const model = store.peekRecord('auth-method', '123abc');
|
||||
await model.changeState('foobar');
|
||||
});
|
||||
|
||||
test('it has isPassword property and returns the expected values', async function (assert) {
|
||||
assert.expect(3);
|
||||
const modelA = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
});
|
||||
const modelB = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
const modelC = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_LDAP,
|
||||
});
|
||||
assert.true(modelA.isPassword);
|
||||
assert.false(modelB.isPassword);
|
||||
assert.false(modelC.isPassword);
|
||||
});
|
||||
|
||||
test('it has isOIDC property and returns the expected values', async function (assert) {
|
||||
assert.expect(3);
|
||||
const modelA = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
const modelB = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
});
|
||||
const modelC = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_LDAP,
|
||||
});
|
||||
assert.true(modelA.isOIDC);
|
||||
assert.false(modelB.isOIDC);
|
||||
assert.false(modelC.isOIDC);
|
||||
});
|
||||
|
||||
test('it has isLDAP property and returns the expected values', async function (assert) {
|
||||
assert.expect(3);
|
||||
const modelA = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_LDAP,
|
||||
});
|
||||
const modelB = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
});
|
||||
const modelC = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
assert.true(modelA.isLDAP);
|
||||
assert.false(modelB.isLDAP);
|
||||
assert.false(modelC.isLDAP);
|
||||
});
|
||||
|
||||
test('it has isUnknown property and returns the expected values', async function (assert) {
|
||||
assert.expect(4);
|
||||
const modelA = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_LDAP,
|
||||
});
|
||||
const modelB = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_PASSWORD,
|
||||
});
|
||||
const modelC = store.createRecord('auth-method', {
|
||||
type: TYPE_AUTH_METHOD_OIDC,
|
||||
});
|
||||
const modelD = store.createRecord('auth-method', {
|
||||
type: 'no-such-type',
|
||||
});
|
||||
assert.false(modelA.isUnknown);
|
||||
assert.false(modelB.isUnknown);
|
||||
assert.false(modelC.isUnknown);
|
||||
assert.true(modelD.isUnknown);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user