From 05794b2688fc0ecebd5244690d4365c80af4548f Mon Sep 17 00:00:00 2001
From: "Piotr S. Staszewski"
Date: Tue, 27 Aug 2019 12:40:10 +0200
Subject: [PATCH] Add test case for custom regexp matching
---
policy/policy_test.go | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/policy/policy_test.go b/policy/policy_test.go
index 81fa5d8..ab2d28b 100644
--- a/policy/policy_test.go
+++ b/policy/policy_test.go
@@ -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
}
}`
@@ -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])