use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class GeoObjectServiceTest method testGetPrivateGeoObject.
@Test
public void testGetPrivateGeoObject() {
// Test allowed users on a private GeoObjectType
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM_PRIVATE, FastTestDataset.USER_CGOV_RC_PRIVATE, FastTestDataset.USER_CGOV_AC_PRIVATE };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
GeoObject geoObj = adapter.getGeoObject(FastTestDataset.PROV_CENTRAL_PRIVATE.getRegistryId(), FastTestDataset.PROV_CENTRAL_PRIVATE.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
FastTestDataset.PROV_CENTRAL_PRIVATE.assertEquals(geoObj);
Assert.assertEquals(true, geoObj.getExists());
});
}
// Disallowed Users
TestUserInfo[] disllowedUsers = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM, FastTestDataset.USER_MOHA_RC, FastTestDataset.USER_MOHA_AC, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
for (TestUserInfo user : disllowedUsers) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
adapter.getGeoObject(FastTestDataset.PROV_CENTRAL_PRIVATE.getRegistryId(), FastTestDataset.PROV_CENTRAL_PRIVATE.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
Assert.fail();
});
} catch (SmartExceptionDTO e) {
// Expected
}
}
}
use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class GeoObjectServiceTest method testGetPrivateGeoObjectByCode.
@Test
public void testGetPrivateGeoObjectByCode() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM_PRIVATE, FastTestDataset.USER_CGOV_RC_PRIVATE, FastTestDataset.USER_CGOV_AC_PRIVATE };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
GeoObject geoObj = adapter.getGeoObjectByCode(FastTestDataset.PROV_CENTRAL_PRIVATE.getCode(), FastTestDataset.PROV_CENTRAL_PRIVATE.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
Assert.assertEquals(geoObj.toJSON().toString(), GeoObject.fromJSON(adapter, geoObj.toJSON().toString()).toJSON().toString());
Assert.assertEquals(true, geoObj.getExists());
});
}
// Disallowed Users
TestUserInfo[] disllowedUsers = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM, FastTestDataset.USER_MOHA_RC, FastTestDataset.USER_MOHA_AC, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
for (TestUserInfo user : disllowedUsers) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
adapter.getGeoObjectByCode(FastTestDataset.PROV_CENTRAL_PRIVATE.getCode(), FastTestDataset.PROV_CENTRAL_PRIVATE.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
Assert.fail();
});
} catch (SmartExceptionDTO e) {
// This is expected
}
}
}
use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class ListTypeTest method testRemoveFromBadRole.
@Test
public void testRemoveFromBadRole() {
JsonObject listJson = getJson(USATestData.ORG_NPS.getServerObject(), USATestData.HIER_ADMIN, USATestData.STATE, USATestData.COUNTRY);
ListTypeService service = new ListTypeService();
JsonObject result = service.apply(testData.clientRequest.getSessionId(), listJson);
String oid = result.get(ComponentInfo.OID).getAsString();
this.waitUntilPublished(oid);
try {
TestUserInfo[] users = new TestUserInfo[] { USATestData.USER_PPP_RA };
for (TestUserInfo user : users) {
USATestData.runAsUser(user, (request, adapter) -> {
try {
service.remove(request.getSessionId(), oid);
Assert.fail("Expected an exception to be thrown.");
} catch (SmartExceptionDTO e) {
// This is expected
}
});
}
} finally {
service.remove(testData.clientRequest.getSessionId(), oid);
}
}
use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class HierarchyServiceTest method testDeleteHierarchyTypeAsBadRole.
@Test
public void testDeleteHierarchyTypeAsBadRole() {
String organizationCode = FastTestDataset.ORG_CGOV.getCode();
HierarchyType reportingDivision = MetadataFactory.newHierarchyType(TEST_HT.getCode(), new LocalizedValue("Reporting Division"), new LocalizedValue("The rporting division hieracy..."), organizationCode, testData.adapter);
String gtJSON = reportingDivision.toJSON().toString();
ServiceFactory.getHierarchyService().createHierarchyType(testData.clientSession.getSessionId(), gtJSON);
TestUserInfo[] users = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_CGOV_RM };
for (TestUserInfo user : users) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
ServiceFactory.getHierarchyService().deleteHierarchyType(request.getSessionId(), TEST_HT.getCode());
});
Assert.fail("Able to update a geo object type as a user with bad roles");
} catch (SmartExceptionDTO e) {
// This is expected
}
}
}
use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class ChangeRequestDocumentActionServiceTest method testListDocuments.
// @Test
public void testListDocuments() {
uploadDocumentsAsAdmin();
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN, FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
for (TestUserInfo user : allowedUsers) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
testListDocumentsAsUser(request);
});
} catch (SmartExceptionDTO e) {
e.printStackTrace();
Assert.fail("Unexpected permission exception was thrown on user [" + user.getUsername() + "].");
}
}
TestUserInfo[] disAllowedUsers = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM, FastTestDataset.USER_MOHA_RC, FastTestDataset.USER_MOHA_AC };
for (TestUserInfo user : disAllowedUsers) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
testListDocumentsAsUser(request);
Assert.fail("Expected a permission exception.");
});
} catch (SmartExceptionDTO e) {
Assert.assertEquals(CGRPermissionException.CLASS, e.getType());
// Expected
}
}
}
Aggregations