mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 10:55:42 +03:00
Account for disabled ACLs in ability tests
This commit is contained in:
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user