use of org.finra.herd.model.api.xml.UserNamespaceAuthorizationUpdateRequest in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testUpdateUserNamespaceAuthorizationNoExists.
@Test
public void testUpdateUserNamespaceAuthorizationNoExists() {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
// Try to update a user namespace authorization when it does not exist.
try {
userNamespaceAuthorizationService.updateUserNamespaceAuthorization(key, new UserNamespaceAuthorizationUpdateRequest(Arrays.asList(NamespacePermissionEnum.READ, NamespacePermissionEnum.WRITE, NamespacePermissionEnum.EXECUTE, NamespacePermissionEnum.GRANT)));
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.UserNamespaceAuthorizationUpdateRequest in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testUpdateUserNamespaceAuthorizationLowerCaseParameters.
@Test
public void testUpdateUserNamespaceAuthorizationLowerCaseParameters() {
// 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, Arrays.asList(NamespacePermissionEnum.READ, NamespacePermissionEnum.WRITE));
// Update a user namespace authorization using lowercase input parameters.
UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.updateUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toLowerCase(), key.getNamespace().toLowerCase()), new UserNamespaceAuthorizationUpdateRequest(SUPPORTED_NAMESPACE_PERMISSIONS));
// Validate the returned object.
assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizationUpdateRequest in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testUpdateUserNamespaceAuthorizationDuplicatePermissions.
@Test
public void testUpdateUserNamespaceAuthorizationDuplicatePermissions() {
// Try to update a user namespace authorization using duplicate permission values.
UserNamespaceAuthorizationUpdateRequest request = new UserNamespaceAuthorizationUpdateRequest(Arrays.asList(NamespacePermissionEnum.READ, NamespacePermissionEnum.READ));
try {
userNamespaceAuthorizationService.updateUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE), request);
fail("Should throw an IllegalArgumentException when using duplicate permission values.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Duplicate namespace permission \"%s\" is found.", NamespacePermissionEnum.READ.value()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizationUpdateRequest in project herd by FINRAOS.
the class UserNamespaceAuthorizationRestControllerTest method testUpdateUserNamespaceAuthorization.
@Test
public void testUpdateUserNamespaceAuthorization() {
// Create a user namespace authorization key
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
UserNamespaceAuthorization userNamespaceAuthorization = new UserNamespaceAuthorization(ID, key, Arrays.asList(NamespacePermissionEnum.EXECUTE, NamespacePermissionEnum.GRANT));
UserNamespaceAuthorizationUpdateRequest request = new UserNamespaceAuthorizationUpdateRequest(Arrays.asList(NamespacePermissionEnum.EXECUTE, NamespacePermissionEnum.GRANT));
// Mock calls to external method.
when(userNamespaceAuthorizationService.updateUserNamespaceAuthorization(key, request)).thenReturn(userNamespaceAuthorization);
// Update a user namespace authorization.
UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationRestController.updateUserNamespaceAuthorization(key.getUserId(), key.getNamespace(), request);
// Verify the external calls.
verify(userNamespaceAuthorizationService).updateUserNamespaceAuthorization(key, request);
verifyNoMoreInteractions(userNamespaceAuthorizationService);
// Validate the returned object.
assertEquals(userNamespaceAuthorization, resultUserNamespaceAuthorization);
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizationUpdateRequest in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testUpdateUserNamespaceAuthorizationUpperCaseParameters.
@Test
public void testUpdateUserNamespaceAuthorizationUpperCaseParameters() {
// 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, Arrays.asList(NamespacePermissionEnum.READ, NamespacePermissionEnum.WRITE));
// Update a user namespace authorization using uppercase input parameters.
UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.updateUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toUpperCase(), key.getNamespace().toUpperCase()), new UserNamespaceAuthorizationUpdateRequest(SUPPORTED_NAMESPACE_PERMISSIONS));
// Validate the returned object.
assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
}
Aggregations