Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Add test case for custom regexp matching
Browse files Browse the repository at this point in the history
  • Loading branch information
drbig committed Aug 27, 2019
1 parent 461cfc1 commit 05794b2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions policy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const samplePolicy = `{
"mesos:framework:service/*": {
"roles":["mesos_framework_service"],
"num_uses":1
},
"mesos:marathone:*":{
"roles":["mesos_marathone_taskA"],
"regexp":"\\d{4}\\w{2}\\.taskA",
"num_uses":1
}
}`

Expand Down Expand Up @@ -91,6 +96,10 @@ func TestSamplePolicy(t *testing.T) {
t.Fatalf("Test of '%s' failed. 'task2' should not conatain permission of 'task'. Had: %v", "mesos:framework:task", actual)
}

if pass, _, actual := shouldContainAll(mustGet(pols.Get("mesos:marathone:6668wz.taskA")), "mesos_child", "mesos_marathone_taskA"); pass {
t.Fatalf("Test of '%s' failed. 'task2' should not conatain permission of 'task'. Had: %v", "mesos:framework:task", actual)
}

if policy, ok := pols.Get("mesos:framework:task"); ok {
if policy.Roles[0] != "mesos_framework_task" {
t.Fatalf("Expected most specific role of '%s'. Had: %v", "mesos:framework:task", policy.Roles[0])
Expand Down

0 comments on commit 05794b2

Please sign in to comment.