use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.AbstractWorkspaceServiceAccount.PREFERENCES_CONFIGMAP_NAME in project che-server by eclipse-che.
the class KubernetesWorkspaceServiceAccountTest method shouldCreatePreferencesConfigmapRole.
@Test
public void shouldCreatePreferencesConfigmapRole() throws Exception {
KubernetesClient localK8sClient = spy(serverMock.getClient());
when(clientFactory.create(anyString())).thenReturn(localK8sClient);
// when
serviceAccount.prepare();
// then
RoleList rl = k8sClient.rbac().roles().inNamespace(NAMESPACE).list();
Optional<Role> roleOptional = rl.getItems().stream().filter(r -> r.getMetadata().getName().equals(CONFIGMAPS_ROLE_NAME)).findFirst();
assertTrue(roleOptional.isPresent());
PolicyRule rule = roleOptional.get().getRules().get(0);
assertEquals(rule.getResources(), singletonList("configmaps"));
assertEquals(rule.getResourceNames(), singletonList(PREFERENCES_CONFIGMAP_NAME));
assertEquals(rule.getApiGroups(), singletonList(""));
assertEquals(rule.getVerbs(), Arrays.asList("get", "patch"));
RoleBindingList rbl = k8sClient.rbac().roleBindings().inNamespace(NAMESPACE).list();
assertTrue(rbl.getItems().stream().anyMatch(rb -> rb.getMetadata().getName().equals(SA_NAME + "-configmaps")));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.namespace.AbstractWorkspaceServiceAccount.PREFERENCES_CONFIGMAP_NAME in project devspaces-images by redhat-developer.
the class KubernetesWorkspaceServiceAccountTest method shouldCreatePreferencesConfigmapRole.
@Test
public void shouldCreatePreferencesConfigmapRole() throws Exception {
KubernetesClient localK8sClient = spy(serverMock.getClient());
when(clientFactory.create(anyString())).thenReturn(localK8sClient);
// when
serviceAccount.prepare();
// then
RoleList rl = k8sClient.rbac().roles().inNamespace(NAMESPACE).list();
Optional<Role> roleOptional = rl.getItems().stream().filter(r -> r.getMetadata().getName().equals(CONFIGMAPS_ROLE_NAME)).findFirst();
assertTrue(roleOptional.isPresent());
PolicyRule rule = roleOptional.get().getRules().get(0);
assertEquals(rule.getResources(), singletonList("configmaps"));
assertEquals(rule.getResourceNames(), singletonList(PREFERENCES_CONFIGMAP_NAME));
assertEquals(rule.getApiGroups(), singletonList(""));
assertEquals(rule.getVerbs(), Arrays.asList("get", "patch"));
RoleBindingList rbl = k8sClient.rbac().roleBindings().inNamespace(NAMESPACE).list();
assertTrue(rbl.getItems().stream().anyMatch(rb -> rb.getMetadata().getName().equals(SA_NAME + "-configmaps")));
}
Aggregations