use of io.cryostat.net.openshift.OpenShiftAuthManager.GroupResource in project cryostat by cryostatio.
the class OpenShiftAuthManagerTest method shouldParseResourceWithGroup.
@Test
void shouldParseResourceWithGroup() {
GroupResource gr = OpenShiftAuthManager.GroupResource.fromString("deployments.apps");
MatcherAssert.assertThat(gr.getGroup(), Matchers.equalTo("apps"));
MatcherAssert.assertThat(gr.getResource(), Matchers.equalTo("deployments"));
MatcherAssert.assertThat(gr.getSubResource(), Matchers.emptyString());
}
use of io.cryostat.net.openshift.OpenShiftAuthManager.GroupResource in project cryostat by cryostatio.
the class OpenShiftAuthManagerTest method shouldParseBareResource.
// the below parsing tests should be in a @Nested class, but this doesn't play nicely with the
// OpenShiftMockServerExtension and results in a test NPE
@Test
void shouldParseBareResource() {
GroupResource gr = OpenShiftAuthManager.GroupResource.fromString("apps");
MatcherAssert.assertThat(gr.getGroup(), Matchers.emptyString());
MatcherAssert.assertThat(gr.getResource(), Matchers.equalTo("apps"));
MatcherAssert.assertThat(gr.getSubResource(), Matchers.emptyString());
}
use of io.cryostat.net.openshift.OpenShiftAuthManager.GroupResource in project cryostat by cryostatio.
the class OpenShiftAuthManagerTest method shouldParseResourceWithSub.
@Test
void shouldParseResourceWithSub() {
GroupResource gr = OpenShiftAuthManager.GroupResource.fromString("apps/scale");
MatcherAssert.assertThat(gr.getGroup(), Matchers.emptyString());
MatcherAssert.assertThat(gr.getResource(), Matchers.equalTo("apps"));
MatcherAssert.assertThat(gr.getSubResource(), Matchers.equalTo("scale"));
}
use of io.cryostat.net.openshift.OpenShiftAuthManager.GroupResource in project cryostat by cryostatio.
the class OpenShiftAuthManagerTest method testPropertiesResourceMapProcessing.
@ParameterizedTest
@MethodSource("getResourceMaps")
void testPropertiesResourceMapProcessing(Map<String, Object> map) throws IOException {
ClassPropertiesLoader loader = Mockito.mock(ClassPropertiesLoader.class);
Map<String, String> resourcesMap = new HashMap<>();
map.entrySet().stream().filter(e -> !e.getKey().equals("expected")).forEach(e -> resourcesMap.put((String) e.getKey(), (String) e.getValue()));
Map<ResourceType, Set<GroupResource>> expected = (Map<ResourceType, Set<GroupResource>>) map.get("expected");
Mockito.when(loader.loadAsMap(Mockito.any())).thenReturn(resourcesMap);
Map<ResourceType, Set<GroupResource>> result = OpenShiftAuthManager.processResourceMapping(loader, logger);
MatcherAssert.assertThat(result, Matchers.equalTo(expected));
}
use of io.cryostat.net.openshift.OpenShiftAuthManager.GroupResource in project cryostat by cryostatio.
the class OpenShiftAuthManagerTest method shouldParseResourceWithGroupAndSub.
@Test
void shouldParseResourceWithGroupAndSub() {
GroupResource gr = OpenShiftAuthManager.GroupResource.fromString("deployments.apps/scale");
MatcherAssert.assertThat(gr.getGroup(), Matchers.equalTo("apps"));
MatcherAssert.assertThat(gr.getResource(), Matchers.equalTo("deployments"));
MatcherAssert.assertThat(gr.getSubResource(), Matchers.equalTo("scale"));
}
Aggregations