From 43abf34be884ff648f4fd8b590589d0a360bb543 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Wed, 3 Apr 2024 13:06:45 +0545 Subject: [PATCH] test(api): adjust user search tests expectation --- .../apiGraphUserGroup/editUser.feature | 29 ++----- .../apiGraphUserGroup/getUser.feature | 84 ++++++++++--------- 2 files changed, 52 insertions(+), 61 deletions(-) diff --git a/tests/acceptance/features/apiGraphUserGroup/editUser.feature b/tests/acceptance/features/apiGraphUserGroup/editUser.feature index 64543b16ef..dc0e6d9768 100644 --- a/tests/acceptance/features/apiGraphUserGroup/editUser.feature +++ b/tests/acceptance/features/apiGraphUserGroup/editUser.feature @@ -15,8 +15,9 @@ Feature: edit user | email | brian@example.com | | password | 1234 | - + @env-config Scenario Outline: admin user can edit another user's email + Given the config "OCIS_SHOW_USER_EMAIL_IN_RESULTS" has been set to "true" When the user "Alice" changes the email of user "Brian" to "" using the Graph API Then the HTTP status code should be "" And the user information of "Brian" should match this JSON schema @@ -120,9 +121,10 @@ Feature: edit user } """ - + @env-config Scenario Outline: normal user should not be able to change their email address Given the administrator has assigned the role "" to user "Brian" using the Graph API + And the config "OCIS_SHOW_USER_EMAIL_IN_RESULTS" has been set to "true" When the user "Brian" tries to change the email of user "Brian" to "newemail@example.com" using the Graph API Then the HTTP status code should be "401" And the user information of "Brian" should match this JSON schema @@ -146,9 +148,10 @@ Feature: edit user | User | | User Light | - + @env-config Scenario Outline: normal user should not be able to edit another user's email Given the administrator has assigned the role "" to user "Brian" using the Graph API + And the config "OCIS_SHOW_USER_EMAIL_IN_RESULTS" has been set to "true" And the user "Alice" has created a new user with the following attributes: | userName | Carol | | displayName | Carol King | @@ -329,7 +332,6 @@ Feature: edit user "required": [ "displayName", "id", - "mail", "onPremisesSamAccountName", "accountEnabled" ], @@ -342,10 +344,6 @@ Feature: edit user "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["brian@example.com"] - }, "onPremisesSamAccountName": { "type": "string", "enum": ["Brian"] @@ -373,7 +371,6 @@ Feature: edit user "required": [ "displayName", "id", - "mail", "onPremisesSamAccountName", "accountEnabled" ], @@ -386,10 +383,6 @@ Feature: edit user "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["carol@example.org"] - }, "onPremisesSamAccountName": { "type": "string", "enum": ["Carol"] @@ -421,7 +414,6 @@ Feature: edit user "required": [ "displayName", "id", - "mail", "onPremisesSamAccountName", "accountEnabled" ], @@ -434,10 +426,6 @@ Feature: edit user "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["brian@example.com"] - }, "onPremisesSamAccountName": { "type": "string", "enum": ["Brian"] @@ -466,7 +454,6 @@ Feature: edit user "required": [ "displayName", "id", - "mail", "onPremisesSamAccountName", "accountEnabled" ], @@ -479,10 +466,6 @@ Feature: edit user "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["carol@example.org"] - }, "onPremisesSamAccountName": { "type": "string", "enum": ["Carol"] diff --git a/tests/acceptance/features/apiGraphUserGroup/getUser.feature b/tests/acceptance/features/apiGraphUserGroup/getUser.feature index 421abd6b67..4309fc1c5d 100644 --- a/tests/acceptance/features/apiGraphUserGroup/getUser.feature +++ b/tests/acceptance/features/apiGraphUserGroup/getUser.feature @@ -298,7 +298,6 @@ Feature: get users "required": [ "displayName", "id", - "mail", "onPremisesSamAccountName", "drive", "accountEnabled", @@ -313,10 +312,6 @@ Feature: get users "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["brian@example.org"] - }, "onPremisesSamAccountName": { "type": "string", "enum": ["Brian"] @@ -428,7 +423,6 @@ Feature: get users "required": [ "displayName", "id", - "mail", "onPremisesSamAccountName", "drive", "accountEnabled", @@ -443,10 +437,6 @@ Feature: get users "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["brian@example.org"] - }, "onPremisesSamAccountName": { "type": "string", "enum": ["Brian"] @@ -567,7 +557,6 @@ Feature: get users "type": "object", "required": [ "id", - "mail", "onPremisesSamAccountName" ], "properties": { @@ -575,10 +564,6 @@ Feature: get users "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["brian@example.org"] - }, "onPremisesSamAccountName": { "type": "string", "enum": ["Brian"] @@ -1352,6 +1337,50 @@ Feature: get users Scenario: non-admin user searches other users by display name + When user "Brian" searches for user "ali" using Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "items": { + "type": "object", + "required": [ + "displayName", + "id", + "userType" + ], + "properties": { + "displayName": { + "type": "string", + "enum": ["Alice Hansen"] + }, + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "userType": { + "type": "string", + "enum": ["Member"] + } + } + } + } + } + } + """ + + @env-config + Scenario: non-admin user searches other users by display name (OCIS_SHOW_USER_EMAIL_IN_RESULTS enabled) + Given the config "OCIS_SHOW_USER_EMAIL_IN_RESULTS" has been set to "true" When user "Brian" searches for user "ali" using Graph API Then the HTTP status code should be "200" And the JSON data of the response should match @@ -1480,7 +1509,6 @@ Feature: get users "required": [ "displayName", "id", - "mail", "userType" ], "properties": { @@ -1492,10 +1520,6 @@ Feature: get users "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["alice@example.org"] - }, "userType": { "type": "string", "enum": ["Member"] @@ -1529,7 +1553,6 @@ Feature: get users "required": [ "displayName", "id", - "mail", "userType" ], "properties": { @@ -1541,10 +1564,6 @@ Feature: get users "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["alice@example.org"] - }, "userType": { "type": "string", "enum": ["Member"] @@ -1560,10 +1579,9 @@ Feature: get users Scenario: non-admin user searches for multiple users having same displayname Given the user "Admin" has created a new user with the following attributes: | userName | another-alice | - | displayName | Alice Hansen | + | displayName | Alice Murphy | | email | another-alice@example.org | | password | containsCharacters(*:!;_+-&) | - When user "Brian" searches for user "alice" using Graph API Then the HTTP status code should be "200" And the JSON data of the response should match @@ -1586,7 +1604,6 @@ Feature: get users "required": [ "displayName", "id", - "mail", "userType" ], "properties": { @@ -1598,10 +1615,6 @@ Feature: get users "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["alice@example.org"] - }, "userType": { "type": "string", "enum": ["Member"] @@ -1613,22 +1626,17 @@ Feature: get users "required": [ "displayName", "id", - "mail", "userType" ], "properties": { "displayName": { "type": "string", - "enum": ["Alice Hansen"] + "enum": ["Alice Murphy"] }, "id": { "type": "string", "pattern": "^%user_id_pattern%$" }, - "mail": { - "type": "string", - "enum": ["another-alice@example.org"] - }, "userType": { "type": "string", "enum": ["Member"]