From f98c59e15bb1199037cf6ad9caa67ffff23ca451 Mon Sep 17 00:00:00 2001 From: Puja Sharma Date: Thu, 31 Mar 2022 19:25:29 +0530 Subject: [PATCH] feat(jans-config-api): user mgmt endpoint --- .../profiles/local/test.properties | 6 +- .../jans/configapi/rest/ApiApplication.java | 1 + .../rest/resource/auth/UserResource.java | 124 ++------ .../main/resources/config-api-rs-protect.json | 23 ++ .../test/resources/feature/user/user-ref.json | 274 ++++++++++++++++++ .../test/resources/feature/user/user.feature | 130 +++++++++ .../src/test/resources/feature/user/user.json | 262 +++++++++++++++++ 7 files changed, 723 insertions(+), 97 deletions(-) create mode 100644 jans-config-api/server/src/test/resources/feature/user/user-ref.json create mode 100644 jans-config-api/server/src/test/resources/feature/user/user.feature create mode 100644 jans-config-api/server/src/test/resources/feature/user/user.json diff --git a/jans-config-api/profiles/local/test.properties b/jans-config-api/profiles/local/test.properties index bcad7a33e42..a287b969e03 100644 --- a/jans-config-api/profiles/local/test.properties +++ b/jans-config-api/profiles/local/test.properties @@ -1,5 +1,5 @@ #LOCAL -test.scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/database/couchbase.readonly https://jans.io/oauth/config/database/couchbase.write https://jans.io/oauth/config/database/couchbase.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write +test.scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/database/couchbase.readonly https://jans.io/oauth/config/database/couchbase.write https://jans.io/oauth/config/database/couchbase.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete # Test env Setting #token.endpoint=https://jenkins-config-api.gluu.org/jans-auth/restv1/token @@ -70,6 +70,6 @@ test.scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/con # jans.server token.endpoint=https://jans.server/jans-auth/restv1/token token.grant.type=client_credentials -test.client.id=1800.77e9a8e6-8fee-4b86-b294-017ba6ab2112 -test.client.secret=dobHjXDhH6zh +test.client.id=1800.579122e0-7c35-4a68-80ad-a3121a5abf1e +test.client.secret=ljVYGAQUzUol test.issuer=https://jans.server \ No newline at end of file diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/rest/ApiApplication.java b/jans-config-api/server/src/main/java/io/jans/configapi/rest/ApiApplication.java index 91638787dc4..6b49f3a553e 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/rest/ApiApplication.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/rest/ApiApplication.java @@ -48,6 +48,7 @@ public Set> getClasses() { classes.add(HealthCheckResource.class); classes.add(OrganizationResource.class); classes.add(SqlConfigurationResource.class); + classes.add(UserResource.class); return classes; } diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/UserResource.java b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/UserResource.java index f9162427a39..c9285f1e906 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/UserResource.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/UserResource.java @@ -8,23 +8,20 @@ import com.github.fge.jsonpatch.JsonPatchException; import static io.jans.as.model.util.Util.escapeLog; -import io.jans.as.common.model.common.User; -//import io.jans.configapi.rest.model.user.User; -import io.jans.as.common.service.common.EncryptionService; -import io.jans.as.common.service.common.InumService; +import io.jans.as.common.model.common.User; import io.jans.configapi.core.rest.ProtectedApi; import io.jans.configapi.rest.model.SearchRequest; import io.jans.configapi.service.auth.UserService; -import io.jans.configapi.service.auth.ConfigurationService; import io.jans.configapi.util.ApiAccessConstants; import io.jans.configapi.util.ApiConstants; -import io.jans.configapi.util.AttributeNames; import io.jans.configapi.core.util.Jackson; -import io.jans.orm.PersistenceEntryManager; import io.jans.orm.model.PagedResult; import io.jans.util.StringHelper; import io.jans.util.security.StringEncrypter.EncryptionException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.validation.Valid; @@ -32,20 +29,16 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import org.slf4j.Logger; +import org.slf4j.Logger; @Path(ApiConstants.USER) @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @ApplicationScoped public class UserResource extends BaseResource { - + private static final String USER = "user"; @Inject @@ -53,15 +46,6 @@ public class UserResource extends BaseResource { @Inject UserService userSrv; - - @Inject - ConfigurationService configurationService; - - @Inject - private InumService inumService; - - @Inject - EncryptionService encryptionService; @GET @ProtectedApi(scopes = { ApiAccessConstants.USER_READ_ACCESS }) @@ -76,107 +60,73 @@ public Response getOpenIdConnectClients( escapeLog(limit), escapeLog(pattern), escapeLog(startIndex), escapeLog(sortBy), escapeLog(sortOrder)); } + logger.error("User serach param - limit:{}, pattern:{}, startIndex:{}, sortBy:{}, sortOrder:{}", + escapeLog(limit), escapeLog(pattern), escapeLog(startIndex), escapeLog(sortBy), escapeLog(sortOrder)); - SearchRequest searchReq = createSearchRequest(userSrv.getPeopleBaseDn(), pattern, sortBy, sortOrder, - startIndex, limit, null, null); + SearchRequest searchReq = createSearchRequest(userSrv.getPeopleBaseDn(), pattern, sortBy, sortOrder, startIndex, + limit, null, null); final List users = this.doSearch(searchReq); - logger.trace("User serach result:{}", users); - return Response.ok(getUsers(users)).build(); + logger.error("User serach result:{}", users); + return Response.ok(users).build(); } @GET - @ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_READ_ACCESS }) + @ProtectedApi(scopes = { ApiAccessConstants.USER_WRITE_ACCESS }) @Path(ApiConstants.INUM_PATH) public Response getUserByInum(@PathParam(ApiConstants.INUM) @NotNull String inum) { if (logger.isDebugEnabled()) { logger.debug("User serach by inum:{}", escapeLog(inum)); } User user = userSrv.getUserByInum(inum); - checkResourceNotNull(user, USER); + logger.error("Based on inum:{}, user:{}", inum, user); return Response.ok(user).build(); } - /* @POST - @ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_WRITE_ACCESS }) + @POST + @ProtectedApi(scopes = { ApiAccessConstants.USER_WRITE_ACCESS }) public Response createOpenIdConnect(@Valid User user) throws EncryptionException { if (logger.isDebugEnabled()) { logger.debug("User details to be added - user:{}", escapeLog(user)); } - String inum = user.getUserId(); - if (inum == null || inum.isEmpty() || inum.isBlank()) { - inum = inumService.generateClientInum(); - user.setUserId(inum); - } - checkNotNull(user., AttributeNames.DISPLAY_NAME); - String clientSecret = client.getClientSecret(); - - if (StringHelper.isEmpty(clientSecret)) { - clientSecret = generatePassword(); - } - client.setClientSecret(encryptionService.encrypt(clientSecret)); - client.setDn(userSrv.getDnForClient(inum)); - client.setDeletable(client.getClientSecretExpiresAt() != null); - ignoreCustomObjectClassesForNonLDAP(client); - - logger.debug("Final Client details to be added - client:{}", client); - userSrv.addClient(user); - User result = userSrv.getUserByInum(inum); - result.setClientSecret(encryptionService.decrypt(result.getClientSecret())); - - return Response.status(Response.Status.CREATED).entity(result).build(); + user = userSrv.addUser(user, true); + logger.error("User created {}", user); + return Response.status(Response.Status.CREATED).entity(user).build(); } @PUT - @ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_WRITE_ACCESS }) + @ProtectedApi(scopes = { ApiAccessConstants.USER_WRITE_ACCESS }) public Response updateUser(@Valid User user) throws EncryptionException { if (logger.isDebugEnabled()) { logger.debug("User details to be updated - user:{}", escapeLog(user)); - } - String inum = client.getClientId(); - checkNotNull(inum, AttributeNames.INUM); - checkNotNull(client.getClientName(), AttributeNames.DISPLAY_NAME); - Client existingClient = userSrv.getClientByInum(inum); - checkResourceNotNull(existingClient, USER); - client.setClientId(existingClient.getClientId()); - client.setBaseDn(userSrv.getDnForClient(inum)); - client.setDeletable(client.getExpirationDate() != null); - if (client.getClientSecret() != null) { - client.setClientSecret(encryptionService.encrypt(client.getClientSecret())); - } - ignoreCustomObjectClassesForNonLDAP(client); - - logger.debug("Final Client details to be updated - user:{}", user); - userSrv.updateClient(client); - User result = userSrv.getClientByInum(existingClient.getClientId()); - result.setClientSecret(encryptionService.decrypt(client.getClientSecret())); - - return Response.ok(result).build(); + } + user = userSrv.updateUser(user); + logger.debug("Updated user:{}", user); + + return Response.ok(user).build(); } @PATCH @Consumes(MediaType.APPLICATION_JSON_PATCH_JSON) - @ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_WRITE_ACCESS }) + @ProtectedApi(scopes = { ApiAccessConstants.USER_WRITE_ACCESS }) @Path(ApiConstants.INUM_PATH) public Response patchUser(@PathParam(ApiConstants.INUM) @NotNull String inum, @NotNull String pathString) throws JsonPatchException, IOException { if (logger.isDebugEnabled()) { - logger.debug("User details to be patched - inum:{}, pathString:{}", escapeLog(inum), - escapeLog(pathString)); + logger.debug("User details to be patched - inum:{}, pathString:{}", escapeLog(inum), escapeLog(pathString)); } - User existingUser = userSrv.getClientByInum(inum); + User existingUser = userSrv.getUserByInum(inum); checkResourceNotNull(existingUser, USER); existingUser = Jackson.applyPatch(pathString, existingUser); - userSrv.updateClient(existingUser); + userSrv.updateUser(existingUser); return Response.ok(existingUser).build(); } -*/ @DELETE @Path(ApiConstants.INUM_PATH) - @ProtectedApi(scopes = { ApiAccessConstants.OPENID_CLIENTS_DELETE_ACCESS }) + @ProtectedApi(scopes = { ApiAccessConstants.USER_DELETE_ACCESS }) public Response deleteUser(@PathParam(ApiConstants.INUM) @NotNull String inum) { if (logger.isDebugEnabled()) { logger.debug("User to be deleted - inum:{} ", escapeLog(inum)); @@ -187,19 +137,6 @@ public Response deleteUser(@PathParam(ApiConstants.INUM) @NotNull String inum) { return Response.noContent().build(); } - private List getUsers(List users) throws EncryptionException { - if (users != null && !users.isEmpty()) { - for (User user : users) { - //user.setClientSecret(encryptionService.decrypt(user.)); - } - } - return users; - } - - private String generatePassword() { - return UUID.randomUUID().toString(); - } - private List doSearch(SearchRequest searchReq) { if (logger.isDebugEnabled()) { logger.debug("User search params - searchReq:{} ", escapeLog(searchReq)); @@ -220,6 +157,5 @@ private List doSearch(SearchRequest searchReq) { } return users; } - } diff --git a/jans-config-api/server/src/main/resources/config-api-rs-protect.json b/jans-config-api/server/src/main/resources/config-api-rs-protect.json index 34c6bc9f9b1..7534547dce5 100644 --- a/jans-config-api/server/src/main/resources/config-api-rs-protect.json +++ b/jans-config-api/server/src/main/resources/config-api-rs-protect.json @@ -690,6 +690,29 @@ ] } ] + }, + { + "path":"/jans-config-api/api/v1/user", + "conditions":[ + { + "httpMethods":["GET"], + "scopes":[ + "https://jans.io/oauth/config/user.readonly" + ] + }, + { + "httpMethods":["PATCH","POST","PUT"], + "scopes":[ + "https://jans.io/oauth/config/user.write" + ] + }, + { + "httpMethods":["DELETE"], + "scopes":[ + "https://jans.io/oauth/config/user.delete" + ] + } + ] } ] } \ No newline at end of file diff --git a/jans-config-api/server/src/test/resources/feature/user/user-ref.json b/jans-config-api/server/src/test/resources/feature/user/user-ref.json new file mode 100644 index 00000000000..97740843e29 --- /dev/null +++ b/jans-config-api/server/src/test/resources/feature/user/user-ref.json @@ -0,0 +1,274 @@ +{ + "dn": "inum=B1F3-AEAE-B799,ou=people,o=jans", + "userId": "admin_user21, + "updatedAt": "2017-02-13T19:25:12", + "customAttributes": [ + { + "name": "birthdate", + "multiValued": false, + "values": [ + "19830106010101.253Z" + ], + "value": "19830106010101.253Z", + "displayValue": "19830106010101.253Z" + }, + { + "name": "c", + "multiValued": false, + "values": [ + "US" + ], + "value": "US", + "displayValue": "US" + }, + { + "name": "cn", + "multiValued": false, + "values": [ + "Test User2" + ], + "value": "Test User2", + "displayValue": "Test User2" + }, + { + "name": "displayName", + "multiValued": false, + "values": [ + "Jans Auth Test User2" + ], + "value": "Jans Auth Test User2", + "displayValue": "Jans Auth Test User2" + }, + { + "name": "emailVerified", + "multiValued": false, + "values": [ + "TRUE" + ], + "value": "TRUE", + "displayValue": "TRUE" + }, + { + "name": "gender", + "multiValued": false, + "values": [ + "Male" + ], + "value": "Male", + "displayValue": "Male" + }, + { + "name": "givenName", + "multiValued": false, + "values": [ + "Test2" + ], + "value": "Test2", + "displayValue": "Test2" + }, + { + "name": "inum", + "multiValued": false, + "values": [ + "B1F3-AEAE-B799" + ], + "value": "B1F3-AEAE-B799", + "displayValue": "B1F3-AEAE-B799" + }, + { + "name": "jansPrefUsrName", + "multiValued": false, + "values": [ + "user2" + ], + "value": "user2", + "displayValue": "user2" + }, + { + "name": "jansStatus", + "multiValued": false, + "values": [ + "active" + ], + "value": "active", + "displayValue": "active" + }, + { + "name": "l", + "multiValued": false, + "values": [ + "Austin" + ], + "value": "Austin", + "displayValue": "Austin" + }, + { + "name": "locale", + "multiValued": false, + "values": [ + "en-US" + ], + "value": "en-US", + "displayValue": "en-US" + }, + { + "name": "mail", + "multiValued": false, + "values": [ + "test_user2@test.org" + ], + "value": "test_user2@test.org", + "displayValue": "test_user2@test.org" + }, + { + "name": "memberOf", + "multiValued": true, + "values": [ + "inum=7890,ou=groups,o=jans", + "inum=7891,ou=groups,o=jans" + ], + "value": "inum=7890,ou=groups,o=jans", + "displayValue": "inum=7890,ou=groups,o=jans, inum=7891,ou=groups,o=jans" + }, + { + "name": "middleName", + "multiValued": false, + "values": [ + "User2" + ], + "value": "User2", + "displayValue": "User2" + }, + { + "name": "mobile", + "multiValued": false, + "values": [ + "(512) 516-2414" + ], + "value": "(512) 516-2414", + "displayValue": "(512) 516-2414" + }, + { + "name": "nickname", + "multiValued": false, + "values": [ + "user2" + ], + "value": "user2", + "displayValue": "user2" + }, + { + "name": "o", + "multiValued": false, + "values": [ + "Test" + ], + "value": "Test", + "displayValue": "Test" + }, + { + "name": "phoneNumberVerified", + "multiValued": false, + "values": [ + "TRUE" + ], + "value": "TRUE", + "displayValue": "TRUE" + }, + { + "name": "picture", + "multiValued": false, + "values": [ + "http://www.jans.org/wp-content/uploads/2012/04/mike3.png" + ], + "value": "http://www.jans.org/wp-content/uploads/2012/04/mike3.png", + "displayValue": "http://www.jans.org/wp-content/uploads/2012/04/mike3.png" + }, + { + "name": "preferredLanguage", + "multiValued": false, + "values": [ + "en_US" + ], + "value": "en_US", + "displayValue": "en_US" + }, + { + "name": "profile", + "multiValued": false, + "values": [ + "http://www.mywebsite.com/profile" + ], + "value": "http://www.mywebsite.com/profile", + "displayValue": "http://www.mywebsite.com/profile" + }, + { + "name": "sn", + "multiValued": false, + "values": [ + "User2" + ], + "value": "User2", + "displayValue": "User2" + }, + { + "name": "st", + "multiValued": false, + "values": [ + "Texas" + ], + "value": "Texas", + "displayValue": "Texas" + }, + { + "name": "street", + "multiValued": false, + "values": [ + "622 East 6th Street" + ], + "value": "622 East 6th Street", + "displayValue": "622 East 6th Street" + }, + { + "name": "telephoneNumber", + "multiValued": false, + "values": [ + "(512) 516-2414" + ], + "value": "(512) 516-2414", + "displayValue": "(512) 516-2414" + }, + { + "name": "userPassword", + "multiValued": false, + "values": [ + "{SSHA512}gFcj2ucCCyO8NLN+IfBIbdzr3xjI7b07vAdwkJ8sw9Ynghj4uWPjfSHI2pHZ9dsyAdL3+mFl8g0ywxp6jcKs3exo/gRLQtre" + ], + "value": "{SSHA512}gFcj2ucCCyO8NLN+IfBIbdzr3xjI7b07vAdwkJ8sw9Ynghj4uWPjfSHI2pHZ9dsyAdL3+mFl8g0ywxp6jcKs3exo/gRLQtre", + "displayValue": "{SSHA512}gFcj2ucCCyO8NLN+IfBIbdzr3xjI7b07vAdwkJ8sw9Ynghj4uWPjfSHI2pHZ9dsyAdL3+mFl8g0ywxp6jcKs3exo/gRLQtre" + }, + { + "name": "website", + "multiValued": false, + "values": [ + "http://www.jans.io" + ], + "value": "http://www.jans.io", + "displayValue": "http://www.jans.io" + }, + { + "name": "zoneinfo", + "multiValued": false, + "values": [ + "America/Chicago" + ], + "value": "America/Chicago", + "displayValue": "America/Chicago" + } + ], + "customObjectClasses": [ + "top", + "jansCustomPerson" + ], + "baseDn": "inum=B1F3-AEAE-B799,ou=people,o=jans" +} \ No newline at end of file diff --git a/jans-config-api/server/src/test/resources/feature/user/user.feature b/jans-config-api/server/src/test/resources/feature/user/user.feature new file mode 100644 index 00000000000..c0a251fd175 --- /dev/null +++ b/jans-config-api/server/src/test/resources/feature/user/user.feature @@ -0,0 +1,130 @@ + +Feature: Openid connect clients + + Background: + * def mainUrl = openidclients_url + +Scenario: Fetch all openid connect clients without bearer token +Given url mainUrl +When method GET +Then status 401 + + +Scenario: Fetch all openid connect clients +Given url mainUrl +And header Authorization = 'Bearer ' + accessToken +When method GET +Then status 200 +And print response +And assert response.length != null + + +Scenario: Fetch the first three openidconnect clients +Given url mainUrl +And header Authorization = 'Bearer ' + accessToken +And param limit = 3 +When method GET +Then status 200 +And print response +And assert response.length == 3 + + +Scenario: Search openid connect clients given a serach pattern +Given url mainUrl +And header Authorization = 'Bearer ' + accessToken +And param limit = 1 +When method GET +Then status 200 +And print response +Given url mainUrl +And header Authorization = 'Bearer ' + accessToken +And param pattern = response[0].displayName +And print 'pattern = '+pattern +When method GET +Then status 200 +And print response +And assert response.length !=0 + +Scenario: Search openid connect clients given a serach pattern and pagination +Given url mainUrl +And header Authorization = 'Bearer ' + accessToken +And param pattern = 'test' +And param limit = 10 +And param startIndex = 1 +When method GET +Then status 200 +And print response + +Scenario: Get an openid connect client by inum(unexisting client) +Given url mainUrl + '/53553532727272772' +And header Authorization = 'Bearer ' + accessToken +When method GET +Then status 404 + + +Scenario: Get an openid connect client by inum +Given url mainUrl +And header Authorization = 'Bearer ' + accessToken +When method GET +Then status 200 +Given url mainUrl + '/' +response[0].inum +And header Authorization = 'Bearer ' + accessToken +When method GET +Then status 200 +And print response + + +@CreateUpdateDelete +Scenario: Create new OpenId Connect Client +Given url mainUrl +And header Authorization = 'Bearer ' + accessToken +And request read('client.json') +When method POST +Then status 201 +And print response +Then def result = response +Then set result.displayName = 'UpdatedQAAddedClient' +Given url mainUrl +And header Authorization = 'Bearer ' + accessToken +And request result +When method PUT +Then status 200 +And print response +And assert response.displayName == 'UpdatedQAAddedClient' +Given url mainUrl + '/' +response.inum +And header Authorization = 'Bearer ' + accessToken +When method DELETE +Then status 204 +And print response + + +Scenario: Delete a non-existion openid connect client by inum +Given url mainUrl + '/1402.66633-8675-473e-a749' +And header Authorization = 'Bearer ' + accessToken +When method GET +Then status 404 +And print response + + +Scenario: Patch openid connect client +Given url mainUrl +And header Authorization = 'Bearer ' + accessToken +And param limit = 1 +When method GET +Then status 200 +And print response +Given url mainUrl + '/' +response[0].inum +And header Authorization = 'Bearer ' + accessToken +And header Content-Type = 'application/json-patch+json' +And header Accept = 'application/json' +And def newName = response[0].displayName +And print " newName = "+newName +#And request "[ {\"op\":\"replace\", \"path\": \"/displayName\", \"value\":\""+newName+"\"} ]" +And def request_body = (response.displayName == null ? "[ {\"op\":\"add\", \"path\": \"/displayName\", \"value\":null } ]" : "[ {\"op\":\"replace\", \"path\": \"/displayName\", \"value\":"+response.displayName+" } ]") +And print 'request_body ='+request_body +And request request_body +When method PATCH +Then status 200 +And print response +And assert response.length !=0 + diff --git a/jans-config-api/server/src/test/resources/feature/user/user.json b/jans-config-api/server/src/test/resources/feature/user/user.json new file mode 100644 index 00000000000..d87fa615038 --- /dev/null +++ b/jans-config-api/server/src/test/resources/feature/user/user.json @@ -0,0 +1,262 @@ +{ + "userId": "config_test_user_1", + "customAttributes": [ + { + "name": "birthdate", + "multiValued": false, + "values": [ + "19830106010101.253Z" + ], + "value": "19830106010101.253Z", + "displayValue": "19830106010101.253Z" + }, + { + "name": "c", + "multiValued": false, + "values": [ + "US" + ], + "value": "US", + "displayValue": "US" + }, + { + "name": "cn", + "multiValued": false, + "values": [ + "Config Test User 1" + ], + "value": "Config Test User 1", + "displayValue": "Config Test User 1" + }, + { + "name": "displayName", + "multiValued": false, + "values": [ + "Config Test User" + ], + "value": "Config Test User", + "displayValue": "Config Test User" + }, + { + "name": "emailVerified", + "multiValued": false, + "values": [ + "TRUE" + ], + "value": "TRUE", + "displayValue": "TRUE" + }, + { + "name": "gender", + "multiValued": false, + "values": [ + "Male" + ], + "value": "Male", + "displayValue": "Male" + }, + { + "name": "givenName", + "multiValued": false, + "values": [ + "Test" + ], + "value": "Test", + "displayValue": "Test" + }, + { + "name": "jansPrefUsrName", + "multiValued": false, + "values": [ + "config_user_1" + ], + "value": "config_user_1", + "displayValue": "config_user_1" + }, + { + "name": "jansStatus", + "multiValued": false, + "values": [ + "active" + ], + "value": "active", + "displayValue": "active" + }, + { + "name": "l", + "multiValued": false, + "values": [ + "Austin" + ], + "value": "Austin", + "displayValue": "Austin" + }, + { + "name": "locale", + "multiValued": false, + "values": [ + "en-US" + ], + "value": "en-US", + "displayValue": "en-US" + }, + { + "name": "mail", + "multiValued": false, + "values": [ + "config_user_1@test.org" + ], + "value": "config_user_1@test.org", + "displayValue": "config_user_1@test.org" + }, + { + "name": "memberOf", + "multiValued": true, + "values": [ + "inum=7890,ou=groups,o=jans", + "inum=7891,ou=groups,o=jans" + ], + "value": "inum=7890,ou=groups,o=jans", + "displayValue": "inum=7890,ou=groups,o=jans, inum=7891,ou=groups,o=jans" + }, + { + "name": "middleName", + "multiValued": false, + "values": [ + "config_user_1" + ], + "value": "config_user_1", + "displayValue": "config_user_1" + }, + { + "name": "mobile", + "multiValued": false, + "values": [ + "(512) 516-2414" + ], + "value": "(512) 516-2414", + "displayValue": "(512) 516-2414" + }, + { + "name": "nickname", + "multiValued": false, + "values": [ + "user1" + ], + "value": "user1", + "displayValue": "user1" + }, + { + "name": "o", + "multiValued": false, + "values": [ + "Test" + ], + "value": "Test", + "displayValue": "Test" + }, + { + "name": "phoneNumberVerified", + "multiValued": false, + "values": [ + "TRUE" + ], + "value": "TRUE", + "displayValue": "TRUE" + }, + { + "name": "picture", + "multiValued": false, + "values": [ + "http://www.jans.org/wp-content/uploads/2012/04/mike3.png" + ], + "value": "http://www.jans.org/wp-content/uploads/2012/04/mike3.png", + "displayValue": "http://www.jans.org/wp-content/uploads/2012/04/mike3.png" + }, + { + "name": "preferredLanguage", + "multiValued": false, + "values": [ + "en_US" + ], + "value": "en_US", + "displayValue": "en_US" + }, + { + "name": "profile", + "multiValued": false, + "values": [ + "http://www.mywebsite.com/profile" + ], + "value": "http://www.mywebsite.com/profile", + "displayValue": "http://www.mywebsite.com/profile" + }, + { + "name": "sn", + "multiValued": false, + "values": [ + "User1" + ], + "value": "User1", + "displayValue": "User1" + }, + { + "name": "st", + "multiValued": false, + "values": [ + "Texas" + ], + "value": "Texas", + "displayValue": "Texas" + }, + { + "name": "street", + "multiValued": false, + "values": [ + "622 East 6th Street" + ], + "value": "622 East 6th Street", + "displayValue": "622 East 6th Street" + }, + { + "name": "telephoneNumber", + "multiValued": false, + "values": [ + "(512) 516-2414" + ], + "value": "(512) 516-2414", + "displayValue": "(512) 516-2414" + }, + { + "name": "userPassword", + "multiValued": false, + "values": [ + "{SSHA512}gFcj2ucCCyO8NLN+IfBIbdzr3xjI7b07vAdwkJ8sw9Ynghj4uWPjfSHI2pHZ9dsyAdL3+mFl8g0ywxp6jcKs3exo/gRLQtre" + ], + "value": "{SSHA512}gFcj2ucCCyO8NLN+IfBIbdzr3xjI7b07vAdwkJ8sw9Ynghj4uWPjfSHI2pHZ9dsyAdL3+mFl8g0ywxp6jcKs3exo/gRLQtre", + "displayValue": "{SSHA512}gFcj2ucCCyO8NLN+IfBIbdzr3xjI7b07vAdwkJ8sw9Ynghj4uWPjfSHI2pHZ9dsyAdL3+mFl8g0ywxp6jcKs3exo/gRLQtre" + }, + { + "name": "website", + "multiValued": false, + "values": [ + "http://www.jans.io" + ], + "value": "http://www.jans.io", + "displayValue": "http://www.jans.io" + }, + { + "name": "zoneinfo", + "multiValued": false, + "values": [ + "America/Chicago" + ], + "value": "America/Chicago", + "displayValue": "America/Chicago" + } + ], + "customObjectClasses": [ + "top", + "jansCustomPerson" + ] +} \ No newline at end of file