@@ -190,32 +190,77 @@ func TestGetUsers(t *testing.T) {
190190 assert .True (t , list .HasNextPage )
191191}
192192
193- func userIDByLoginIDHandler (t * testing.T , loginID , userUUID string ) func (http.ResponseWriter , * http.Request ) {
193+ func userIDByLoginIDHandler (t * testing.T , loginID , email , userUUID string ) func (http.ResponseWriter , * http.Request ) {
194194 return func (w http.ResponseWriter , r * http.Request ) {
195195 if r .Method != "GET" {
196196 t .Errorf ("Expected ‘GET’ request, got ‘%s’" , r .Method )
197197 }
198198 w .Header ().Set ("Content-Type" , "application/json" )
199199 w .WriteHeader (http .StatusOK )
200+ userId := r .URL .Query ().Get ("userId" )
200201
201- if r . URL . Query (). Get ( "loginId" ) != loginID {
202+ if ! ( userId == loginID || userId == userUUID ) {
202203 _ , _ = io .WriteString (w , `{
203- "responseCode ": "4010" ,
204- "responseMessage ": "User does not exist"
204+ "total ": 0 ,
205+ "entry ": []
205206 }` )
206207 return
207208 }
208209 _ , _ = io .WriteString (w , `{
209- "exchange": {
210- "users": [
211- {
212- "userUUID": "` + userUUID + `"
213- }
214- ]
215- },
216- "responseCode": "200",
217- "responseMessage": "Success"
218- }` )
210+ "total": 1,
211+ "entry": [
212+ {
213+ "preferredLanguage": "en-US",
214+ "loginId": "` + loginID + `",
215+ "emailAddress": "` + email + `",
216+ "id": "` + userUUID + `",
217+ "managingOrganization": "c29cdb88-7cda-4fc1-af8b-ee5947659958",
218+ "name": {
219+ "given": "Ron",
220+ "family": "Swanson"
221+ },
222+ "memberships": [
223+ {
224+ "organizationId": "c29cdb88-7cda-4fc1-af8b-ee5947659958",
225+ "organizationName": "Pawnee",
226+ "roles": [
227+ "ANALYZE",
228+ "S3CREDSADMINROLE",
229+ "ADMIN"
230+ ],
231+ "groups": [
232+ "S3CredsAdminGroup",
233+ "AdminGroup"
234+ ]
235+ },
236+ {
237+ "organizationId": "d4be75cc-e81b-4d7d-b034-baf6f3f10792",
238+ "organizationName": "Eagleton",
239+ "roles": [
240+ "LOGUSER"
241+ ],
242+ "groups": [
243+ "LogUserGroup"
244+ ]
245+ }
246+ ],
247+ "passwordStatus": {
248+ "passwordExpiresOn": "2022-02-04T10:07:55Z",
249+ "passwordChangedOn": "2020-02-15T10:07:55Z"
250+ },
251+ "accountStatus": {
252+ "mfaStatus": "NOTREQUIRED",
253+ "lastLoginTime": "2020-05-09T12:27:41Z",
254+ "emailVerified": true,
255+ "numberOfInvalidAttempt": 0,
256+ "disabled": false
257+ },
258+ "consentedApps": [
259+ "default default default"
260+ ]
261+ }
262+ ]
263+ }` )
219264 }
220265}
221266
@@ -224,8 +269,9 @@ func TestGetUserIDByLoginID(t *testing.T) {
224269 defer teardown ()
225270
226271 userUUID := "f5fe538f-c3b5-4454-8774-cd3789f59b9f"
227- loginID := "foo@bar.com"
228- muxIDM .HandleFunc ("/security/users" , userIDByLoginIDHandler (t , loginID , userUUID ))
272+ loginID := "ron"
273+ email := "foo@bar.com"
274+ muxIDM .HandleFunc ("/authorize/identity/User" , userIDByLoginIDHandler (t , loginID , email , userUUID ))
229275
230276 uuid , resp , err := client .Users .GetUserIDByLoginID (loginID )
231277 if ! assert .NotNil (t , resp ) {
@@ -241,31 +287,10 @@ func TestGetUserByID(t *testing.T) {
241287 defer teardown ()
242288
243289 userUUID := "44d20214-7879-4e35-923d-f9d4e01c9746"
290+ loginID := "ron"
291+ email := "foo@bar.com"
244292
245- muxIDM .HandleFunc ("/security/users/" + userUUID , func (w http.ResponseWriter , r * http.Request ) {
246- if r .Method != "GET" {
247- t .Errorf ("Expected ‘GET’ request, got ‘%s’" , r .Method )
248- }
249-
250- w .Header ().Set ("Content-Type" , "application/json" )
251- w .WriteHeader (http .StatusOK )
252- _ , _ = io .WriteString (w , `{
253- "exchange": {
254- "loginId": "john.doe@domain.com",
255- "profile": {
256- "contact": {
257- "emailAddress": "john.doe@domain.com"
258- },
259- "givenName": "John",
260- "familyName": "Doe",
261- "addresses": [],
262- "disabled": false
263- }
264- },
265- "responseCode": "200",
266- "responseMessage": "Success"
267- }` )
268- })
293+ muxIDM .HandleFunc ("/authorize/identity/User" , userIDByLoginIDHandler (t , loginID , email , userUUID ))
269294
270295 foundUser , resp , err := client .Users .GetUserByID (userUUID )
271296 if ! assert .NotNil (t , resp ) {
@@ -276,11 +301,8 @@ func TestGetUserByID(t *testing.T) {
276301 }
277302 assert .Nil (t , err )
278303 assert .Equal (t , http .StatusOK , resp .StatusCode )
279- if ! assert .NotEqual (t , 0 , len (foundUser .Telecom )) {
280- return
281- }
282- assert .Equal (t , "john.doe@domain.com" , foundUser .Telecom [0 ].Value )
283- assert .Equal (t , "Doe" , foundUser .Name .Family )
304+ assert .Equal (t , email , foundUser .EmailAddress )
305+ assert .Equal (t , "Swanson" , foundUser .Name .Family )
284306}
285307
286308func TestUserActions (t * testing.T ) {
@@ -296,8 +318,9 @@ func TestUserActions(t *testing.T) {
296318 muxIDM .HandleFunc ("/authorize/identity/User/$recover-password" ,
297319 actionRequestHandler (t , "recoverPassword" , "TODO: fix" , http .StatusOK ))
298320 userUUID := "f5fe538f-c3b5-4454-8774-cd3789f59b9f"
299- loginID := "foo@bar.com"
300- muxIDM .HandleFunc ("/security/users" , userIDByLoginIDHandler (t , loginID , userUUID ))
321+ loginID := "ron"
322+ email := "foo@bar.com"
323+ muxIDM .HandleFunc ("/authorize/identity/User" , userIDByLoginIDHandler (t , loginID , email , userUUID ))
301324 muxIDM .HandleFunc ("/authorize/identity/User/" + userUUID + "/$mfa" ,
302325 actionRequestHandler (t , "setMFA" , "TODO: fix" , http .StatusAccepted ))
303326 muxIDM .HandleFunc ("/authorize/identity/User/" + userUUID + "/$unlock" ,
@@ -340,9 +363,8 @@ func TestUserActions(t *testing.T) {
340363 return
341364 }
342365 assert .Nil (t , err )
343- assert .True (t , ok )
344- assert .Equal (t , http .StatusOK , resp .StatusCode )
345366 assert .Equal (t , userUUID , uuid )
367+ assert .Equal (t , http .StatusOK , resp .StatusCode )
346368
347369 ok , resp , err = client .Users .SetMFAByLoginID (loginID , true )
348370 if ! assert .NotNil (t , resp ) {
0 commit comments