use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class GeoObjectServiceTest method testUpdatePrivateGeoObject.
@Test
public void testUpdatePrivateGeoObject() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM_PRIVATE };
for (TestUserInfo user : allowedUsers) {
TestGeoObjectInfo go = testData.newTestGeoObjectInfo("UpdateTest", FastTestDataset.PROVINCE_PRIVATE);
go.apply();
TestDataSet.runAsUser(user, (request, adapter) -> {
updateGO(adapter, go, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
});
go.delete();
}
// Disallowed Users
TestUserInfo[] disallowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM, FastTestDataset.USER_MOHA_RC, FastTestDataset.USER_MOHA_AC };
for (TestUserInfo user : disallowedUsers) {
TestGeoObjectInfo go = testData.newTestGeoObjectInfo("UpdateTest", FastTestDataset.PROVINCE_PRIVATE);
go.apply();
TestDataSet.runAsUser(user, (request, adapter) -> {
try {
updateGO(adapter, go, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
Assert.fail();
} catch (SmartExceptionDTO ex) {
// expected
}
});
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class GeoObjectServiceTest method testGetGeoObject.
@Test
public void testGetGeoObject() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
GeoObject geoObj = adapter.getGeoObject(FastTestDataset.CAMBODIA.getRegistryId(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
FastTestDataset.CAMBODIA.assertEquals(geoObj);
Assert.assertEquals(true, geoObj.getExists());
});
}
}
use of net.geoprism.registry.test.TestUserInfo 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 net.geoprism.registry.test.TestUserInfo 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 net.geoprism.registry.test.TestUserInfo 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);
}
}
Aggregations