mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
making required changes
This commit is contained in:
parent
62aef0b6f6
commit
569d5d06ac
@ -55,24 +55,20 @@ 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 buildApiConfigAsNonAdmin() throws UserStoreException, RegistryException {
|
private void buildApiConfigAsNonAdminUser() throws UserStoreException, RegistryException {
|
||||||
try {
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername("test");
|
||||||
startTenantFlowAsNonAdmin();
|
setUserRealm();
|
||||||
setUserRealm();
|
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<>();
|
apiDef.setResources(resources);
|
||||||
apiDef.setResources(resources);
|
APIConfig apiConfig = buildApiConfig(servletContext, apiDef);
|
||||||
APIConfig apiConfig = buildApiConfig(servletContext, apiDef);
|
Assert.assertNotNull(apiConfig, "API configuration is null.");
|
||||||
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 buildApiConfigAdminUser() throws UserStoreException {
|
private void buildApiConfigAsAdminUser() 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<>();
|
||||||
@ -117,10 +113,4 @@ 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 startTenantFlowAsNonAdmin() {
|
|
||||||
PrivilegedCarbonContext.startTenantFlow();
|
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID, true);
|
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername("test");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user