Skip to content

Commit 4ce6812

Browse files
committed
test: refactor tests related to OCIS_SHOW_USER_EMAIL_IN_RESULTS
1 parent 375ea28 commit 4ce6812

File tree

2 files changed

+105
-6
lines changed

2 files changed

+105
-6
lines changed

tests/acceptance/features/apiGraphUser/getUser.feature

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,3 +1132,54 @@ Feature: get users
11321132
}
11331133
}
11341134
"""
1135+
1136+
@env-config
1137+
Scenario: non-admin user searches for other users with attributes
1138+
Given the config "OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES" has been set to "onPremisesSamAccountName,userType,mail" for "graph" service
1139+
And the user "Admin" has created a new user with the following attributes:
1140+
| userName | Carol |
1141+
| displayName | carol |
1142+
| email | carol@example.org |
1143+
When user "Brian" searches for user '"carol"' using Graph API
1144+
Then the HTTP status code should be "200"
1145+
And the JSON data of the response should match
1146+
"""
1147+
{
1148+
"type": "object",
1149+
"required": ["value"],
1150+
"properties": {
1151+
"value": {
1152+
"type": "array",
1153+
"minItems": 1,
1154+
"maxItems": 1,
1155+
"items": {
1156+
"type": "object",
1157+
"required": ["displayName", "id", "userType", "onPremisesSamAccountName"],
1158+
"properties": {
1159+
"attributes": {
1160+
"type": "array",
1161+
"minItems": 3,
1162+
"maxItems": 3,
1163+
"uniqueItems": true,
1164+
"items": { "type": "string" },
1165+
"allOf": [
1166+
{ "contains": { "const": "[email protected]" } },
1167+
{ "contains": { "const": "Carol" } },
1168+
{ "contains": { "const": "Member" } }
1169+
]
1170+
},
1171+
"displayName": {"const": "carol"},
1172+
"id": {"pattern": "^%user_id_pattern%$"},
1173+
"userType": {"const": "Member"},
1174+
"onPremisesSamAccountName": {"const": ""},
1175+
"appRoleAssignments": {"const": null},
1176+
"drives": {"const": null},
1177+
"drive": {"const": null},
1178+
"memberOf": {"const": null},
1179+
"email": {"const": "[email protected]"}
1180+
}
1181+
}
1182+
}
1183+
}
1184+
}
1185+
"""

tests/acceptance/features/apiGraphUser/showUserEmailInResult.feature

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Feature: edit/search user including email
99
| displayName | Brian Murphy |
1010
| email | brian@example.com |
1111
| password | 1234 |
12-
And the config "OCIS_SHOW_USER_EMAIL_IN_RESULTS" has been set to "true" for "graph" service
12+
And the config "OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES" has been set to "mail" for "graph" service
1313

1414

1515
Scenario Outline: admin user can edit another user's email
@@ -281,7 +281,8 @@ Feature: edit/search user including email
281281
"attributes": {
282282
"type": "array",
283283
"maxItems": 1,
284-
"minItems": 1
284+
"minItems": 1,
285+
"const": ["[email protected]"]
285286
},
286287
"displayName": {
287288
"const": "Alice Hansen"
@@ -331,7 +332,8 @@ Feature: edit/search user including email
331332
"attributes": {
332333
"type": "array",
333334
"maxItems": 1,
334-
"minItems": 1
335+
"minItems": 1,
336+
"const": ["[email protected]"]
335337
},
336338
"displayName": {
337339
"const": "Alice Hansen"
@@ -380,7 +382,8 @@ Feature: edit/search user including email
380382
"attributes": {
381383
"type": "array",
382384
"maxItems": 1,
383-
"minItems": 1
385+
"minItems": 1,
386+
"const": ["[email protected]"]
384387
},
385388
"displayName": {
386389
"const": "Alice Hansen"
@@ -490,8 +493,8 @@ Feature: edit/search user including email
490493
"""
491494

492495

493-
Scenario Outline: search other users when OCIS_SHOW_USER_EMAIL_IN_RESULTS config is disabled
494-
Given the config "OCIS_SHOW_USER_EMAIL_IN_RESULTS" has been set to "false" for "graph" service
496+
Scenario Outline: search other users when OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES config is disabled
497+
Given the config "OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES" has been set to "" for "graph" service
495498
And the administrator has assigned the role "<user-role>" to user "Alice" using the Graph API
496499
When user "Alice" searches for user "Brian" using Graph API
497500
Then the HTTP status code should be "200"
@@ -501,3 +504,48 @@ Feature: edit/search user including email
501504
| Space Admin |
502505
| User |
503506
| User Light |
507+
508+
509+
Scenario: non-admin user searches other users by e-mail
510+
Given the following configs have been set:
511+
| config | value |
512+
| OCIS_USER_SEARCH_DISPLAYED_ATTRIBUTES | |
513+
| OCIS_SHOW_USER_EMAIL_IN_RESULTS | true |
514+
And the administrator has assigned the role "Admin" to user "Alice" using the Graph API
515+
When user "Alice" gets information of user "Brian" using Graph API
516+
Then the HTTP status code should be "200"
517+
And the JSON data of the response should match
518+
"""
519+
{
520+
"type": "object",
521+
"required": [
522+
"displayName",
523+
"id",
524+
"mail",
525+
"onPremisesSamAccountName",
526+
"accountEnabled",
527+
"userType"
528+
],
529+
"properties": {
530+
"displayName": {
531+
"const": "Brian Murphy"
532+
},
533+
"id" : {
534+
"type": "string",
535+
"pattern": "^%user_id_pattern%$"
536+
},
537+
"mail": {
538+
"const": "[email protected]"
539+
},
540+
"onPremisesSamAccountName": {
541+
"const": "Brian"
542+
},
543+
"accountEnabled": {
544+
"const": true
545+
},
546+
"userType": {
547+
"const": "Member"
548+
}
549+
}
550+
}
551+
"""

0 commit comments

Comments
 (0)