StormMetadataService { public String getTopologySummaryUrl() { return tplgySumUrl; } StormMetadataService(Client httpClient, String tplgySumUrl, String mainPageUrl,
            SecurityContext securityContext, ServiceConfiguration stormEnvConfig, Subject subject,
                                Component nimbus, Collection<ComponentProcess> nimbusProcesses,
                                Component stormUi, Collection<ComponentProcess> stormUiProcesses); StormTopologies getTopologies(); String getMainPageUrl(); String getTopologySummaryUrl(); Keytabs getKeytabs(); Principals getPrincipals(); Security getSecurity(); static final String STORM_REST_API_DO_AS_USER_QUERY_PARAM; static final String SERVICE_STORM_VIEW; static final String STORM_VIEW_CONFIGURATION_KEY_STORM_VIEW_URL; }
@Test public void buildUrl_insecureMode_noQueryParam() throws Exception { List<ComponentProcess> uiProcesses = buildUiComponentProcesses(); new Expectations() {{ securityContext.getAuthenticationScheme(); result = AUTHENTICATION_SCHEME_NOT_KERBEROS; stormUi.getId(); result = 2L; environmentService.listComponentProcesses(2L); result = uiProcesses; }}; final StormMetadataService stormMetadataService = new StormMetadataService .Builder(environmentService, 1L, securityContext, subject).build(); final String tpSumUrl = stormMetadataService.getTopologySummaryUrl(); Assert.assertTrue(tpSumUrl.equals(STORM_UI_URL_EXPECTED)); }
@Test public void buildUrl_insecureMode_doAsUserQueryParam() throws Exception { final String principalUser = "user"; List<ComponentProcess> componentProcesses = buildUiComponentProcesses(); new Expectations() {{ securityContext.getAuthenticationScheme(); result = StreamlineSecurityContext.KERBEROS_AUTH; securityContext.getUserPrincipal().getName(); result = principalUser; environmentService.listComponentProcesses(stormUi.getId()); result = componentProcesses; }}; final StormMetadataService stormMetadataService = new StormMetadataService .Builder(environmentService, 1L, securityContext, subject).build(); final String tpSumUrl = stormMetadataService.getTopologySummaryUrl(); Assert.assertTrue(tpSumUrl.equals(STORM_UI_URL_EXPECTED +"?" + StormMetadataService.STORM_REST_API_DO_AS_USER_QUERY_PARAM + "=" + principalUser)); }