making required changes

revert-70aa11f8
Nirothipan 7 years ago
parent 569d5d06ac
commit 77e735e525

@ -55,20 +55,24 @@ public class APIPublisherUtilTest extends BaseAPIPublisherTest {
} }
@Test(description = "test buildAPIConfig method and ensures an APIConfig is created") @Test(description = "test buildAPIConfig method and ensures an APIConfig is created")
private void buildApiConfigAsNonAdminUser() throws UserStoreException, RegistryException { private void buildApiConfigTest() throws UserStoreException, RegistryException {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername("test"); try {
setUserRealm(); startTenantFlowAsTestTenant();
ServletContext servletContext = new MockServletContext(); setUserRealm();
APIResourceConfiguration apiDef = new APIResourceConfiguration(); ServletContext servletContext = new MockServletContext();
List<APIResource> resources = new ArrayList<>(); APIResourceConfiguration apiDef = new APIResourceConfiguration();
apiDef.setResources(resources); List<APIResource> resources = new ArrayList<>();
APIConfig apiConfig = buildApiConfig(servletContext, apiDef); apiDef.setResources(resources);
Assert.assertNotNull(apiConfig, "API configuration is null."); APIConfig apiConfig = buildApiConfig(servletContext, apiDef);
Assert.assertNotNull(apiConfig, "API configuration is null.");
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
} }
@Test(description = "test buildAPIConfig method as SuperTenant and ensures" + @Test(description = "test buildAPIConfig method as SuperTenant and ensures" +
" an APIConfig is created") " an APIConfig is created")
private void buildApiConfigAsAdminUser() throws UserStoreException { private void buildApiConfigAsSuperTenat() throws UserStoreException {
ServletContext servletContext = new MockServletContext(); ServletContext servletContext = new MockServletContext();
APIResourceConfiguration apiDef = new APIResourceConfiguration(); APIResourceConfiguration apiDef = new APIResourceConfiguration();
List<APIResource> resources = new ArrayList<>(); List<APIResource> resources = new ArrayList<>();
@ -113,4 +117,10 @@ public class APIPublisherUtilTest extends BaseAPIPublisherTest {
UserRealm userRealm = new InMemoryRealmService().getUserRealm(configuration); UserRealm userRealm = new InMemoryRealmService().getUserRealm(configuration);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUserRealm(userRealm); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUserRealm(userRealm);
} }
private void startTenantFlowAsTestTenant() {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID, true);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain("test");
}
} }

Loading…
Cancel
Save