mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
dispatch-job capability to dispatch periodic jobs
This commit is contained in:
@@ -28,7 +28,7 @@ func (p *Periodic) Force(args *structs.PeriodicForceRequest, reply *structs.Peri
|
||||
// Check for write-job permissions
|
||||
if aclObj, err := p.srv.ResolveToken(args.AuthToken); err != nil {
|
||||
return err
|
||||
} else if aclObj != nil && !aclObj.AllowNsOp(args.RequestNamespace(), acl.NamespaceCapabilitySubmitJob) {
|
||||
} else if aclObj != nil && !aclObj.AllowNsOp(args.RequestNamespace(), acl.NamespaceCapabilityDispatchJob) && !aclObj.AllowNsOp(args.RequestNamespace(), acl.NamespaceCapabilitySubmitJob) {
|
||||
return structs.ErrPermissionDenied
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,24 @@ func TestPeriodicEndpoint_Force_ACL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch the response with a valid token having dispatch permission
|
||||
{
|
||||
policy := mock.NamespacePolicy(structs.DefaultNamespace, "", []string{acl.NamespaceCapabilityDispatchJob})
|
||||
token := mock.CreatePolicyAndToken(t, state, 1005, "valid", policy)
|
||||
req.AuthToken = token.SecretID
|
||||
var resp structs.PeriodicForceResponse
|
||||
assert.Nil(msgpackrpc.CallWithCodec(codec, "Periodic.Force", req, &resp))
|
||||
assert.NotEqual(uint64(0), resp.Index)
|
||||
|
||||
// Lookup the evaluation
|
||||
ws := memdb.NewWatchSet()
|
||||
eval, err := state.EvalByID(ws, resp.EvalID)
|
||||
assert.Nil(err)
|
||||
if assert.NotNil(eval) {
|
||||
assert.Equal(eval.CreateIndex, resp.EvalCreateIndex)
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch the response with management token
|
||||
{
|
||||
req.AuthToken = root.SecretID
|
||||
|
||||
Reference in New Issue
Block a user