refactor(workflow): drop the root identity alias from workflow definitions
This commit is contained in:
1 parent
44a10943c3
commit
db982f2d93
5 files changed
+2
-14
No files matched your search
@@ -60,12 +60,11 @@ func (d *Daemon) adoptWorkflowIdentity(ctx context.Context, task *workflow.Task)
|
||||
// declaredIdentity resolves a workflow's declared identity to the ID it is
|
||||
// authorized as and the name the task carries while it runs: a configured
|
||||
// identity's name, or empty for the root identity of a single-identity
|
||||
// install. RootRef names the instance root, whose name differs per install,
|
||||
// so the shipped workflows can declare it.
|
||||
// install.
|
||||
func (d *Daemon) declaredIdentity(ctx context.Context, task *workflow.Task, ref string) (identity.IdentityID, string, error) {
|
||||
var id identity.IdentityID
|
||||
var name string
|
||||
if ref == workflow.RootRef || identity.IdentityID(ref) == d.RootIdentityID || identity.StableID(ref) == d.RootIdentityID {
|
||||
if identity.IdentityID(ref) == d.RootIdentityID || identity.StableID(ref) == d.RootIdentityID {
|
||||
id = d.RootIdentityID
|
||||
} else {
|
||||
id, name = identity.IdentityID(ref), ref
|
||||
|
||||
@@ -108,7 +108,6 @@ func TestWorkflowIdentity(t *testing.T) {
|
||||
{"refused execution is parked", deploy, "", runAllowed{"root": true}, "", true, []identity.IdentityID{"id-deployer"}, false},
|
||||
{"called workflow runs as its own identity, not its caller's", callee, "id-deployer", runAllowed{"id-deployer": true, "id-bot": true}, "id-bot", false, nil, false},
|
||||
{"caller refused the called workflow is parked", callee, "id-deployer", runAllowed{"id-bot": true}, "", true, []identity.IdentityID{"id-deployer"}, false},
|
||||
{"workflow naming the root runs as the root", "id: deploy\nidentity: root\n", "id-bot", runAllowed{"root": true, "id-bot": true}, "", false, nil, false},
|
||||
{"no declared identity is refused", "id: deploy\n", "id-bot", runAllowed{"root": true, "id-bot": true}, "", true, nil, false},
|
||||
{"unconfigured identity is parked", "id: deploy\nidentity: ghost\n", "", runAllowed{"root": true}, "", true, nil, false},
|
||||
{"disabled workflow is parked", deploy, "id-bot", runAllowed{"id-bot": true, "id-deployer": true}, "", true, nil, true},
|
||||
|
||||
Reference in new issue
Block a user