Skip to content

Commit

Permalink
Merge pull request #16000 from simo5/notpc
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 15885, 15973, 16000)

Remove usless test and resolved comments

Fixes  #15815
  • Loading branch information
openshift-merge-robot authored Sep 6, 2017
2 parents 14ebc56 + 967cabd commit 971d942
Showing 1 changed file with 2 additions and 53 deletions.
55 changes: 2 additions & 53 deletions test/integration/authorization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,23 +302,15 @@ func TestAuthorizationResolution(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}

// try to add Valerie to a non-existent role, looping until it is true due to
// the policy cache taking time to react
if err := wait.Poll(time.Second, 2*time.Minute, func() (bool, error) {
err := addValerie.AddRole()
if err == nil || kapierror.IsNotFound(err) { // TODO what does this mean?
return true, nil
}
return false, err
}); err != nil {
if err := addValerie.AddRole(); err != nil {
t.Fatalf("unexpected error: %v", err)
}

roleWithGroup := &authorizationapi.ClusterRole{}
roleWithGroup.Name = "with-group"
roleWithGroup.Rules = append(roleWithGroup.Rules, authorizationapi.PolicyRule{
Verbs: sets.NewString("list"),
Resources: sets.NewString("builds"), // TODO we may need to track these down
Resources: sets.NewString("builds"),
})
if _, err := clusterAdminClient.ClusterRoles().Create(roleWithGroup); err != nil {
t.Fatalf("unexpected error: %v", err)
Expand Down Expand Up @@ -1655,46 +1647,3 @@ func TestClusterPolicyCache(t *testing.T) {
}
}
}

// TestPolicyCache confirms that the creation of role bindings fallback to live lookups when the referenced role is not cached
func TestPolicyCache(t *testing.T) {
masterConfig, clusterAdminKubeConfig, err := testserver.StartTestMasterAPI()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
defer testserver.CleanupMasterEtcd(t, masterConfig)

clusterAdminClient, err := testutil.GetClusterAdminClient(clusterAdminKubeConfig)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

clusterAdminClientConfig, err := testutil.GetClusterAdminClientConfig(clusterAdminKubeConfig)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

user := "harold"
namespace := "hammer-project"

haroldClient, err := testserver.CreateNewProject(clusterAdminClient, *clusterAdminClientConfig, namespace, user)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
haroldClient.RESTClient.Throttle = flowcontrol.NewFakeAlwaysRateLimiter() // turn off rate limiting so cache misses are more likely

for i := 0; i < 100; i++ { // usually takes less than 60 attempts for this to cache miss
role := &authorizationapi.Role{ObjectMeta: metav1.ObjectMeta{GenerateName: time.Now().String()}}
role, err = haroldClient.Roles(namespace).Create(role)
if err != nil {
t.Fatalf("unexpected error creating role %q: %v", role.Name, err)
}
roleBinding := &authorizationapi.RoleBinding{
ObjectMeta: metav1.ObjectMeta{Name: role.Name},
Subjects: []kapi.ObjectReference{{Name: user, Kind: authorizationapi.UserKind}},
RoleRef: kapi.ObjectReference{Name: role.Name, Namespace: namespace}}
if _, err := haroldClient.RoleBindings(namespace).Create(roleBinding); err != nil {
t.Fatalf("cache error creating role binding %d %q: %v", i, roleBinding.Name, err)
}
}
}

0 comments on commit 971d942

Please sign in to comment.