From f5662817ffc09547ba5811ebbef744ff60fb7d1f Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 30 Jan 2020 16:34:35 -0800 Subject: [PATCH] Account for disabled ACLs in ability tests --- ui/tests/unit/abilities/client-test.js | 13 +++++++++++++ ui/tests/unit/abilities/job-test.js | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/ui/tests/unit/abilities/client-test.js b/ui/tests/unit/abilities/client-test.js index d4e0b2a3f..d037fb281 100644 --- a/ui/tests/unit/abilities/client-test.js +++ b/ui/tests/unit/abilities/client-test.js @@ -7,8 +7,18 @@ module('Unit | Ability | client', function(hooks) { setupTest(hooks); setupAbility('client')(hooks); + test('it permits client write when ACLs are disabled', function(assert) { + const mockToken = Service.extend({ + aclEnabled: false, + }); + this.owner.register('service:token', mockToken); + + assert.ok(this.ability.canWrite); + }); + test('it permits client write for management tokens', function(assert) { const mockToken = Service.extend({ + aclEnabled: true, selfToken: { type: 'management' }, }); this.owner.register('service:token', mockToken); @@ -18,6 +28,7 @@ module('Unit | Ability | client', function(hooks) { test('it permits client write for tokens with a policy that has node-write', function(assert) { const mockToken = Service.extend({ + aclEnabled: true, selfToken: { type: 'client' }, selfTokenPolicies: [ { @@ -36,6 +47,7 @@ module('Unit | Ability | client', function(hooks) { test('it permits client write for tokens with a policy that allows write and another policy that disallows it', function(assert) { const mockToken = Service.extend({ + aclEnabled: true, selfToken: { type: 'client' }, selfTokenPolicies: [ { @@ -61,6 +73,7 @@ module('Unit | Ability | client', function(hooks) { test('it blocks client write for tokens with a policy that does not allow node-write', function(assert) { const mockToken = Service.extend({ + aclEnabled: true, selfToken: { type: 'client' }, selfTokenPolicies: [ { diff --git a/ui/tests/unit/abilities/job-test.js b/ui/tests/unit/abilities/job-test.js index 63c393a06..e1e661d0c 100644 --- a/ui/tests/unit/abilities/job-test.js +++ b/ui/tests/unit/abilities/job-test.js @@ -7,8 +7,19 @@ module('Unit | Ability | job', function(hooks) { setupTest(hooks); setupAbility('job')(hooks); + test('it permits job run when ACLs are disabled', function(assert) { + const mockToken = Service.extend({ + aclEnabled: false, + }); + + this.owner.register('service:token', mockToken); + + assert.ok(this.ability.canRun); + }); + test('it permits job run for management tokens', function(assert) { const mockToken = Service.extend({ + aclEnabled: true, selfToken: { type: 'management' }, }); @@ -19,12 +30,14 @@ module('Unit | Ability | job', function(hooks) { test('it permits job run for client tokens with a policy that has namespace submit-job', function(assert) { const mockSystem = Service.extend({ + aclEnabled: true, activeNamespace: { name: 'aNamespace', }, }); const mockToken = Service.extend({ + aclEnabled: true, selfToken: { type: 'client' }, selfTokenPolicies: [ { @@ -48,12 +61,14 @@ module('Unit | Ability | job', function(hooks) { test('it permits job run for client tokens with a policy that has default namespace submit-job and no capabilities for active namespace', function(assert) { const mockSystem = Service.extend({ + aclEnabled: true, activeNamespace: { name: 'anotherNamespace', }, }); const mockToken = Service.extend({ + aclEnabled: true, selfToken: { type: 'client' }, selfTokenPolicies: [ { @@ -81,12 +96,14 @@ module('Unit | Ability | job', function(hooks) { test('it blocks job run for client tokens with a policy that has no submit-job capability', function(assert) { const mockSystem = Service.extend({ + aclEnabled: true, activeNamespace: { name: 'aNamespace', }, }); const mockToken = Service.extend({ + aclEnabled: true, selfToken: { type: 'client' }, selfTokenPolicies: [ { @@ -110,12 +127,14 @@ module('Unit | Ability | job', function(hooks) { test('it handles globs in namespace names', function(assert) { const mockSystem = Service.extend({ + aclEnabled: true, activeNamespace: { name: 'aNamespace', }, }); const mockToken = Service.extend({ + aclEnabled: true, selfToken: { type: 'client' }, selfTokenPolicies: [ {