use of org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testUpdateUserNamespaceAuthorizationMissingRequiredParameters.
@Test
public void testUpdateUserNamespaceAuthorizationMissingRequiredParameters() {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
// Try to update a user namespace authorization when user namespace authorization key is not specified.
try {
userNamespaceAuthorizationService.updateUserNamespaceAuthorization(null, new UserNamespaceAuthorizationUpdateRequest(SUPPORTED_NAMESPACE_PERMISSIONS));
fail("Should throw an IllegalArgumentException when user namespace authorization key is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A user namespace authorization key must be specified.", e.getMessage());
}
// Try to update a user namespace authorization when user id is not specified.
try {
userNamespaceAuthorizationService.updateUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(BLANK_TEXT, NAMESPACE), new UserNamespaceAuthorizationUpdateRequest(SUPPORTED_NAMESPACE_PERMISSIONS));
fail("Should throw an IllegalArgumentException when user id is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A user id must be specified.", e.getMessage());
}
// Try to update a user namespace authorization when namespace is not specified.
try {
userNamespaceAuthorizationService.updateUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(USER_ID, BLANK_TEXT), new UserNamespaceAuthorizationUpdateRequest(SUPPORTED_NAMESPACE_PERMISSIONS));
fail("Should throw an IllegalArgumentException when namespace is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
// Try to update a user namespace authorization when permissions are not specified (passed as null).
try {
userNamespaceAuthorizationService.updateUserNamespaceAuthorization(key, new UserNamespaceAuthorizationUpdateRequest(null));
fail("Should throw an IllegalArgumentException when permissions are not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Namespace permissions must be specified.", e.getMessage());
}
// Try to update a user namespace authorization when permissions are not specified (passed as an empty list).
try {
userNamespaceAuthorizationService.updateUserNamespaceAuthorization(key, new UserNamespaceAuthorizationUpdateRequest(new ArrayList<>()));
fail("Should throw an IllegalArgumentException when permissions are not specified.");
} catch (IllegalArgumentException e) {
assertEquals("Namespace permissions must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationsByNamespaceUpperCaseParameters.
@Test
public void testGetUserNamespaceAuthorizationsByNamespaceUpperCaseParameters() throws Exception {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
// Create and persist the relative database entities.
UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = userNamespaceAuthorizationDaoTestHelper.createUserNamespaceAuthorizationEntity(key, SUPPORTED_NAMESPACE_PERMISSIONS);
// Get user namespace authorizations for the specified namespace using uppercase namespace code.
UserNamespaceAuthorizations resultUserNamespaceAuthorizations = userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByNamespace(key.getNamespace().toUpperCase());
// Validate the returned object.
assertEquals(new UserNamespaceAuthorizations(Arrays.asList(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS))), resultUserNamespaceAuthorizations);
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationNoExists.
@Test
public void testGetUserNamespaceAuthorizationNoExists() {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
// Try to get a user namespace authorization when it does not exist.
try {
userNamespaceAuthorizationService.getUserNamespaceAuthorization(key);
fail("Should throw an ObjectNotFoundException when user namespace authorization does not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("User namespace authorization with user id \"%s\" and namespace \"%s\" doesn't exist.", key.getUserId(), key.getNamespace()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testDeleteUserNamespaceAuthorizationUpperCaseParameters.
@Test
public void testDeleteUserNamespaceAuthorizationUpperCaseParameters() {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
// Create and persist the relative database entities.
UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = userNamespaceAuthorizationDaoTestHelper.createUserNamespaceAuthorizationEntity(key, SUPPORTED_NAMESPACE_PERMISSIONS);
// Validate that this user namespace authorization exists.
assertNotNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
// Delete a user namespace authorization using uppercase input parameters.
UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.deleteUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toUpperCase(), key.getNamespace().toUpperCase()));
// Validate the returned object.
assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
// Ensure that this user namespace authorization is no longer there.
assertNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testDeleteUserNamespaceAuthorizationLowerCaseParameters.
@Test
public void testDeleteUserNamespaceAuthorizationLowerCaseParameters() {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
// Create and persist the relative database entities.
UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = userNamespaceAuthorizationDaoTestHelper.createUserNamespaceAuthorizationEntity(key, SUPPORTED_NAMESPACE_PERMISSIONS);
// Validate that this user namespace authorization exists.
assertNotNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
// Delete a user namespace authorization using lowercase input parameters.
UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.deleteUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toLowerCase(), key.getNamespace().toLowerCase()));
// Validate the returned object.
assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
// Ensure that this user namespace authorization is no longer there.
assertNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
}
Aggregations