2929import static io .restassured .http .ContentType .JSON ;
3030import static org .apache .http .HttpStatus .*;
3131import static org .junit .jupiter .api .Assertions .assertFalse ;
32+ import static org .junit .jupiter .api .Assertions .assertTrue ;
3233
3334public class UserIT {
3435
3536 @ Test
3637 public void createUser () {
37- createUser ("123" );
38+ final String userId = "123" ;
39+
40+ createUser (userId );
41+
42+ // get user
43+ final ExtractableResponse <Response > userResponse = getUser (userId );
44+
45+ // check they are enabled
46+ assertTrue (userResponse .jsonPath ().getBoolean ("enabled" ));
3847 }
3948
4049 @ Test
41- public void disableUser () {
50+ public void createUserDisabled () {
4251 final String userId = "456" ;
4352
53+ createUser (userId , true );
54+
55+ // get user
56+ final ExtractableResponse <Response > userResponse = getUser (userId );
57+
58+ // check they are disabled
59+ assertFalse (userResponse .jsonPath ().getBoolean ("enabled" ));
60+ }
61+
62+ @ Test
63+ public void disableUser () {
64+ final String userId = "789" ;
65+
4466 // 1. create the user
4567 createUser (userId );
4668
@@ -78,6 +100,10 @@ private ExtractableResponse<Response> getUser(final String userId) {
78100 }
79101
80102 private void createUser (final String userId ) {
103+ createUser (userId ,false );
104+ }
105+
106+ private void createUser (final String userId , final boolean disabled ) {
81107 final Map <String , Object > requestBody = mapOf (
82108 Tuple ("userName" , "user" + userId ),
83109 Tuple ("password" , "user" + userId ),
@@ -93,6 +119,10 @@ private void createUser(final String userId) {
93119 ))
94120 );
95121
122+ if (disabled ) {
123+ requestBody .put ("enabled" , false );
124+ }
125+
96126 given ().
97127 auth ().preemptive ().basic (DEFAULT_ADMIN_USERNAME , DEFAULT_ADMIN_PASSWORD ).
98128 contentType (JSON ).
0 commit comments