Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#Fixes 3155 Made Changes to RbacGroupAPIGroupClient and RbacAPIGroupDSL files #3211

Merged
merged 10 commits into from
Jun 7, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.fabric8.kubernetes.api.model.rbac.*;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.RbacAPIGroupDSL;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.internal.rbac.v1.ClusterRoleBindingOperationsImpl;
Expand Down Expand Up @@ -46,12 +47,12 @@ public MixedOperation<RoleBinding, RoleBindingList, Resource<RoleBinding>> roleB
}

@Override
public MixedOperation<ClusterRole, ClusterRoleList, Resource<ClusterRole>> clusterRoles() {
public NonNamespaceOperation<ClusterRole, ClusterRoleList, Resource<ClusterRole>> clusterRoles() {
return new ClusterRoleOperationsImpl(httpClient, getConfiguration());
}

@Override
public MixedOperation<ClusterRoleBinding, ClusterRoleBindingList, Resource<ClusterRoleBinding>> clusterRoleBindings() {
public NonNamespaceOperation<ClusterRoleBinding, ClusterRoleBindingList, Resource<ClusterRoleBinding>> clusterRoleBindings() {
return new ClusterRoleBindingOperationsImpl(httpClient, getConfiguration());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public interface RbacAPIGroupDSL extends Client{

MixedOperation<RoleBinding, RoleBindingList, Resource<RoleBinding>> roleBindings();

MixedOperation<ClusterRole, ClusterRoleList, Resource<ClusterRole>> clusterRoles();
NonNamespaceOperation<ClusterRole, ClusterRoleList, Resource<ClusterRole>> clusterRoles();

MixedOperation<ClusterRoleBinding, ClusterRoleBindingList, Resource<ClusterRoleBinding>> clusterRoleBindings();
NonNamespaceOperation<ClusterRoleBinding, ClusterRoleBindingList, Resource<ClusterRoleBinding>> clusterRoleBindings();

}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void createClusterRoleBindingK8s() {
assertNotNull(clusterRoleBindingCreated);
assertNotNull(clusterRoleBindingCreated.getMetadata().getUid());
assertEquals(name, clusterRoleBindingCreated.getMetadata().getName());
client.rbac().clusterRoleBindings().inNamespace(session.getNamespace()).withName(name).delete();
client.rbac().clusterRoleBindings().withName(name).delete();
}

@Test
Expand All @@ -151,13 +151,13 @@ public void createClusterRoleK8s() {
.build();

// When
ClusterRole createdClusterRole = client.rbac().clusterRoles().inNamespace(session.getNamespace()).create(clusterRole);
ClusterRole createdClusterRole = client.rbac().clusterRoles().create(clusterRole);

// Then
assertNotNull(createdClusterRole);
assertNotNull(createdClusterRole.getMetadata().getUid());
assertEquals(name, createdClusterRole.getMetadata().getName());
client.rbac().clusterRoles().inNamespace(session.getNamespace()).withName(name).delete();
client.rbac().clusterRoles().withName(name).delete();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void init() {
.build()
)
.build();
client.rbac().clusterRoles().inNamespace(currentNamespace).createOrReplace(impersonatorRole);
client.rbac().clusterRoles().createOrReplace(impersonatorRole);

// Create Service Account
serviceAccount1 = new ServiceAccountBuilder()
Expand Down Expand Up @@ -109,7 +109,7 @@ public void init() {
)
.build();

client.rbac().clusterRoleBindings().inNamespace(currentNamespace).createOrReplace(impersonatorRoleBinding);
client.rbac().clusterRoleBindings().createOrReplace(impersonatorRoleBinding);
}


Expand Down Expand Up @@ -153,11 +153,11 @@ public void cleanup() {
requestConfig.setImpersonateGroups((String) null);

// DeleteEntity Cluster Role
client.rbac().clusterRoles().inNamespace(currentNamespace).delete(impersonatorRole);
client.rbac().clusterRoles().delete(impersonatorRole);
await().atMost(30, TimeUnit.SECONDS).until(kubernetesClusterRoleIsDeleted());

// DeleteEntity Cluster Role binding
client.rbac().clusterRoleBindings().inNamespace(currentNamespace).delete(impersonatorRoleBinding);
client.rbac().clusterRoleBindings().delete(impersonatorRoleBinding);
await().atMost(30, TimeUnit.SECONDS).until(kubernetesClusterRoleBindingIsDeleted());

// DeleteEntity project
Expand All @@ -178,11 +178,11 @@ private Callable<Boolean> projectIsDeleted() {
}

private Callable<Boolean> kubernetesClusterRoleBindingIsDeleted() {
return () -> client.rbac().clusterRoleBindings().inNamespace(currentNamespace).withName("impersonator-role").get() == null;
return () -> client.rbac().clusterRoleBindings().withName("impersonator-role").get() == null;
}

private Callable<Boolean> kubernetesClusterRoleIsDeleted() {
return () -> client.rbac().clusterRoles().inNamespace(currentNamespace).withName("impersonator").get() == null;
return () -> client.rbac().clusterRoles().withName("impersonator").get() == null;
}


Expand Down