Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
App Blocks
Commits
1d140c51
Commit
1d140c51
authored
Jun 28, 2017
by
Matija Obreza
Browse files
Declare the generic UserException in #createUser
parent
af08c8ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
security/src/main/java/org/genesys/blocks/security/service/BasicUserService.java
View file @
1d140c51
...
...
@@ -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.
...
...
security/src/test/java/org/genesys/blocks/security/tests/BasicUserServiceTest.java
View file @
1d140c51
...
...
@@ -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.
NotUnique
UserException
;
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
,
PasswordPolicy
Exception
{
public
void
testChangePassword
()
throws
User
Exception
{
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
,
PasswordPolicy
Exception
{
public
void
testChangePasswordFail
()
throws
User
Exception
{
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"
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment