dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42264
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21601: DhisConvenienceTest, including unique char in username for createUser to avoid unique constraint ...
------------------------------------------------------------
revno: 21601
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-01-05 19:18:16 +0100
message:
DhisConvenienceTest, including unique char in username for createUser to avoid unique constraint error
modified:
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2016-01-05 18:18:16 +0000
@@ -1075,20 +1075,21 @@
public static User createUser( char uniqueCharacter )
{
+ UserCredentials credentials = new UserCredentials();
User user = new User();
user.setAutoFields();
+ credentials.setUserInfo( user );
+ user.setUserCredentials( credentials );
+
+ credentials.setUsername( "username" + uniqueCharacter );
+ credentials.setPassword( "password" + uniqueCharacter );
+
user.setFirstName( "FirstName" + uniqueCharacter );
user.setSurname( "Surname" + uniqueCharacter );
user.setEmail( "Email" + uniqueCharacter );
user.setPhoneNumber( "PhoneNumber" + uniqueCharacter );
- UserCredentials credentials = new UserCredentials();
- credentials.setUsername( "username" ); //TODO include uniqueCharacter
- credentials.setPassword( "password" );
-
- user.setUserCredentials( credentials );
-
return user;
}
@@ -1615,7 +1616,8 @@
List<GrantedAuthority> authorities = new ArrayList<>();
authorities.add( new SimpleGrantedAuthority( "ALL" ) );
- UserDetails userDetails = new org.springframework.security.core.userdetails.User( "username", "password", authorities );
+ UserDetails userDetails = new org.springframework.security.core.userdetails.User(
+ user.getUserCredentials().getUsername(), user.getUserCredentials().getPassword(), authorities );
Authentication authentication = new UsernamePasswordAuthenticationToken( userDetails, "", authorities );
SecurityContextHolder.getContext().setAuthentication( authentication );