Skip to content

Commit

Permalink
Merge 128ecdd into 937c451
Browse files Browse the repository at this point in the history
  • Loading branch information
adhicoder committed Feb 6, 2018
2 parents 937c451 + 128ecdd commit bd3e1eb
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion manager_test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package ladon

import (
"fmt"
"reflect"
"testing"

"github.com/pborman/uuid"
Expand Down Expand Up @@ -147,6 +148,25 @@ var TestManagerPolicies = []*DefaultPolicy{
"owner": &EqualsSubjectCondition{},
},
},
//Two new policies which do not persist in MySQL correctly
{
ID: uuid.New(),
Description: "A failed policy",
Subjects: []string{"supplier"},
Effect: AllowAccess,
Resources: []string{"product:<.*>"},
Actions: []string{"update"},
Conditions: Conditions{},
},
{
ID: uuid.New(),
Description: "Another failed policy",
Subjects: []string{"buyer"},
Effect: AllowAccess,
Resources: []string{"products:attributeGroup:<.*>"},
Actions: []string{"create"},
Conditions: Conditions{},
},
}

var testPolicies = []*DefaultPolicy{
Expand Down Expand Up @@ -354,13 +374,15 @@ func TestHelperCreateGetDelete(s Manager) func(t *testing.T) {
found := map[string]int{}
for _, got := range pols {
for _, expect := range TestManagerPolicies {
if got.GetID() == expect.GetID() {
//This is a modified equality check
if got.GetID() == expect.GetID() && reflect.DeepEqual(got.GetResources(), expect.GetResources()) && reflect.DeepEqual(got.GetActions(), expect.GetActions()) {
found[got.GetID()]++
}
}
}

for _, f := range found {
//This assert is supposed to fail
assert.Equal(t, 1, f)
}
})
Expand Down

0 comments on commit bd3e1eb

Please sign in to comment.