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; ...@@ -19,6 +19,7 @@ import java.util.Set;
import org.genesys.blocks.security.NoUserFoundException; import org.genesys.blocks.security.NoUserFoundException;
import org.genesys.blocks.security.NotUniqueUserException; import org.genesys.blocks.security.NotUniqueUserException;
import org.genesys.blocks.security.UserException;
import org.genesys.blocks.security.model.BasicUser; import org.genesys.blocks.security.model.BasicUser;
import org.genesys.blocks.security.service.PasswordPolicy.PasswordPolicyException; import org.genesys.blocks.security.service.PasswordPolicy.PasswordPolicyException;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
...@@ -50,9 +51,12 @@ public interface BasicUserService<R extends GrantedAuthority, T extends BasicUse ...@@ -50,9 +51,12 @@ public interface BasicUserService<R extends GrantedAuthority, T extends BasicUse
* @param fullName Full name * @param fullName Full name
* @param password initial account password * @param password initial account password
* @param accountType TODO * @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 * @return the new user
*/ */
T createUser(String email, String fullName, String password, BasicUser.AccountType accountType) throws NotUniqueUserException, PasswordPolicyException; 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. * Grant specified roles to user. The {@link UserRole#USER} will be added if missing.
......
...@@ -18,7 +18,7 @@ package org.genesys.blocks.security.tests; ...@@ -18,7 +18,7 @@ package org.genesys.blocks.security.tests;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; 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.BasicUser.AccountType;
import org.genesys.blocks.security.model.TestUser; import org.genesys.blocks.security.model.TestUser;
import org.genesys.blocks.security.service.PasswordPolicy.PasswordPolicyException; import org.genesys.blocks.security.service.PasswordPolicy.PasswordPolicyException;
...@@ -34,7 +34,7 @@ public class BasicUserServiceTest extends ServiceTest { ...@@ -34,7 +34,7 @@ public class BasicUserServiceTest extends ServiceTest {
private static final String USER_FULLNAME = "Full Name"; private static final String USER_FULLNAME = "Full Name";
@Test @Test
public void testChangePassword() throws NotUniqueUserException, PasswordPolicyException { public void testChangePassword() throws UserException {
TestUser user = testUserService.createUser(USER_EMAIL, USER_FULLNAME, "password", AccountType.LOCAL); TestUser user = testUserService.createUser(USER_EMAIL, USER_FULLNAME, "password", AccountType.LOCAL);
assertThat(user.getId(), is(notNullValue())); assertThat(user.getId(), is(notNullValue()));
assertThat(user.getUuid(), is(notNullValue())); assertThat(user.getUuid(), is(notNullValue()));
...@@ -43,7 +43,7 @@ public class BasicUserServiceTest extends ServiceTest { ...@@ -43,7 +43,7 @@ public class BasicUserServiceTest extends ServiceTest {
} }
@Test(expected = PasswordPolicyException.class) @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); TestUser user = testUserService.createUser(USER_EMAIL, USER_FULLNAME, "password", AccountType.SYSTEM);
assertThat(user.getAccountType(), is(AccountType.SYSTEM)); assertThat(user.getAccountType(), is(AccountType.SYSTEM));
assertThat(user.getPassword(), is("THIS-IS-NOT-A-PASSWORD")); assertThat(user.getPassword(), is("THIS-IS-NOT-A-PASSWORD"));
......
Supports Markdown
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