Skip to content

Commit

Permalink
update ownerref integration test for less stringent rules
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k committed May 3, 2018
1 parent fd8a8c5 commit 410094c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions test/integration/ownerrefs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestOwnerRefRestriction(t *testing.T) {
Name: "create-svc",
},
Rules: []authorizationapi.PolicyRule{
authorizationapi.NewRule("create").Groups(kapi.GroupName).Resources("services").RuleOrDie(),
authorizationapi.NewRule("create", "update").Groups(kapi.GroupName).Resources("services").RuleOrDie(),
},
})
if err != nil {
Expand Down Expand Up @@ -63,24 +63,28 @@ func TestOwnerRefRestriction(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}

_, err = creatorClient.Core().Services("foo").Create(&kapi.Service{
actual, err := creatorClient.Core().Services("foo").Create(&kapi.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "my-service",
OwnerReferences: []metav1.OwnerReference{{
APIVersion: "foo",
Kind: "bar",
Name: "baz",
UID: types.UID("baq"),
}},
},
Spec: kapi.ServiceSpec{
Ports: []kapi.ServicePort{
{Port: 80},
},
},
})
if err != nil {
t.Fatal(err)
}
actual.OwnerReferences = []metav1.OwnerReference{{
APIVersion: "foo",
Kind: "bar",
Name: "baz",
UID: types.UID("baq"),
}}
actual, err = creatorClient.Core().Services("foo").Update(actual)
if err == nil {
t.Fatalf("missing err")
t.Fatalf("missing error")
}
if !kapierrors.IsForbidden(err) || !strings.Contains(err.Error(), "cannot set an ownerRef on a resource you can't delete") {
t.Fatalf("expecting cannot set an ownerRef on a resource you can't delete, got %v", err)
Expand Down

0 comments on commit 410094c

Please sign in to comment.