test('it permits alloc exec when ACLs are disabled',function(assert){
constmockToken=Service.extend({
aclEnabled:false,
});
this.owner.register('service:token',mockToken);
assert.ok(this.ability.canExec);
});
test('it permits alloc exec for management tokens',function(assert){
constmockToken=Service.extend({
aclEnabled:true,
selfToken:{type:'management'},
});
this.owner.register('service:token',mockToken);
assert.ok(this.ability.canExec);
});
test('it permits alloc exec for client tokens with a policy that has namespace alloc-exec',function(assert){
constmockSystem=Service.extend({
aclEnabled:true,
activeNamespace:{
name:'aNamespace',
},
});
constmockToken=Service.extend({
aclEnabled:true,
selfToken:{type:'client'},
selfTokenPolicies:[
{
rulesJSON:{
Namespaces:[
{
Name:'aNamespace',
Capabilities:['alloc-exec'],
},
],
},
},
],
});
this.owner.register('service:system',mockSystem);
this.owner.register('service:token',mockToken);
assert.ok(this.ability.canExec);
});
test('it permits alloc exec for client tokens with a policy that has default namespace alloc-exec and no capabilities for active namespace',function(assert){
constmockSystem=Service.extend({
aclEnabled:true,
activeNamespace:{
name:'anotherNamespace',
},
});
constmockToken=Service.extend({
aclEnabled:true,
selfToken:{type:'client'},
selfTokenPolicies:[
{
rulesJSON:{
Namespaces:[
{
Name:'aNamespace',
Capabilities:[],
},
{
Name:'default',
Capabilities:['alloc-exec'],
},
],
},
},
],
});
this.owner.register('service:system',mockSystem);
this.owner.register('service:token',mockToken);
assert.ok(this.ability.canExec);
});
test('it blocks alloc exec for client tokens with a policy that has no alloc-exec capability',function(assert){
constmockSystem=Service.extend({
aclEnabled:true,
activeNamespace:{
name:'aNamespace',
},
});
constmockToken=Service.extend({
aclEnabled:true,
selfToken:{type:'client'},
selfTokenPolicies:[
{
rulesJSON:{
Namespaces:[
{
Name:'aNamespace',
Capabilities:['list-jobs'],
},
],
},
},
],
});
this.owner.register('service:system',mockSystem);
this.owner.register('service:token',mockToken);
assert.notOk(this.ability.canExec);
});
test('it handles globs in namespace names',function(assert){