Commit 1d140c51 authored by Matija Obreza's avatar Matija Obreza
Browse files

Declare the generic UserException in #createUser

parent af08c8ef
......@@ -19,6 +19,7 @@ import java.util.Set;
import org.genesys.blocks.security.NoUserFoundException;
import org.genesys.blocks.security.NotUniqueUserException;
import org.genesys.blocks.security.UserException;
import org.genesys.blocks.security.model.BasicUser;
import org.genesys.blocks.security.service.PasswordPolicy.PasswordPolicyException;
import org.springframework.security.core.GrantedAuthority;
......@@ -44,15 +45,18 @@ public interface BasicUserService<R extends GrantedAuthority, T extends BasicUse
T getUserByEmail(String email) throws UsernameNotFoundException;
/**
* Create a new user account
*
* @param email unique email address
* @param fullName Full name
* @param password initial account password
* @param accountType TODO
* @return the new user
*/
T createUser(String email, String fullName, String password, BasicUser.AccountType accountType) throws NotUniqueUserException, PasswordPolicyException;
* Create a new user account
*
* @param email unique email address
* @param fullName Full name
* @param password initial account password
* @param accountType TODO
* @throws PasswordPolicyException password violates current password policy
* @throws NotUniqueUserException user is not unique in the system
* @throws UserException any other exception
* @return the new user
*/
T createUser(String email, String fullName, String password, BasicUser.AccountType accountType) throws NotUniqueUserException, PasswordPolicyException, UserException;
/**
* Grant specified roles to user. The {@link UserRole#USER} will be added if missing.
......
......@@ -18,7 +18,7 @@ package org.genesys.blocks.security.tests;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import org.genesys.blocks.security.NotUniqueUserException;
import org.genesys.blocks.security.UserException;
import org.genesys.blocks.security.model.BasicUser.AccountType;
import org.genesys.blocks.security.model.TestUser;
import org.genesys.blocks.security.service.PasswordPolicy.PasswordPolicyException;
......@@ -34,7 +34,7 @@ public class BasicUserServiceTest extends ServiceTest {
private static final String USER_FULLNAME = "Full Name";
@Test
public void testChangePassword() throws NotUniqueUserException, PasswordPolicyException {
public void testChangePassword() throws UserException {
TestUser user = testUserService.createUser(USER_EMAIL, USER_FULLNAME, "password", AccountType.LOCAL);
assertThat(user.getId(), is(notNullValue()));
assertThat(user.getUuid(), is(notNullValue()));
......@@ -43,7 +43,7 @@ public class BasicUserServiceTest extends ServiceTest {
}
@Test(expected = PasswordPolicyException.class)
public void testChangePasswordFail() throws NotUniqueUserException, PasswordPolicyException {
public void testChangePasswordFail() throws UserException {
TestUser user = testUserService.createUser(USER_EMAIL, USER_FULLNAME, "password", AccountType.SYSTEM);
assertThat(user.getAccountType(), is(AccountType.SYSTEM));
assertThat(user.getPassword(), is("THIS-IS-NOT-A-PASSWORD"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment