From e7cbf93fca5708de5d9a7aec0680fbb274e2673e Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 30 Apr 2024 12:09:13 +0545 Subject: [PATCH] test: add API tests to search user/group with special chars --- .../apiGraphUserGroup/getGroup.feature | 49 ++++++++++++- .../apiGraphUserGroup/getUser.feature | 70 ++++++++++++++++++- 2 files changed, 115 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/features/apiGraphUserGroup/getGroup.feature b/tests/acceptance/features/apiGraphUserGroup/getGroup.feature index 9bc296ecb5e..16ebff90e7e 100644 --- a/tests/acceptance/features/apiGraphUserGroup/getGroup.feature +++ b/tests/acceptance/features/apiGraphUserGroup/getGroup.feature @@ -464,7 +464,7 @@ Feature: get groups and their members Then the HTTP status code should be "404" - Scenario Outline: non-admin user search for a group by group name + Scenario Outline: non-admin user searches for a group by group name Given these users have been created with default attributes and without skeleton files: | username | | Brian | @@ -546,7 +546,7 @@ Feature: get groups and their members """ @issue-7990 - Scenario Outline: non-admin user tries to search for a group by group name with invalid characters/token + Scenario Outline: user tries to search for groups with invalid characters/token (search term without quotation) Given these users have been created with default attributes and without skeleton files: | username | | Brian | @@ -580,3 +580,48 @@ Feature: get groups and their members | group | token | | tea-lovers | -lovers | | tea@lovers | @lovers | + + @issue-7990 + Scenario Outline: user searches for groups with special characters (search term with quotation) + Given these users have been created with default attributes and without skeleton files: + | username | + | Brian | + And group "" has been created + When user "Brian" tries to search for group '""' 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", + "maxItems": 1, + "minItems": 1, + "items": { + "type": "object", + "required": ["displayName", "id", "groupTypes"], + "properties": { + "displayName": { + "const": "" + }, + "id": { + "type": "string", + "pattern": "%group_id_pattern%" + }, + "groupTypes": { + "const": [] + } + } + } + } + } + } + """ + Examples: + | group | token | + | tea-lovers | -lovers | + | tea@lovers | @lovers | + | -_.ocgrp | -_. | + | _ocgrp@ | _oc | diff --git a/tests/acceptance/features/apiGraphUserGroup/getUser.feature b/tests/acceptance/features/apiGraphUserGroup/getUser.feature index 92cb4354060..7e337319fc2 100644 --- a/tests/acceptance/features/apiGraphUserGroup/getUser.feature +++ b/tests/acceptance/features/apiGraphUserGroup/getUser.feature @@ -1402,7 +1402,7 @@ Feature: get users """ @issue-7990 - Scenario Outline: non-admin user tries to search for a user by display name with invalid characters/token + Scenario Outline: user tries to search other users with invalid characters/token (search term without quotation) Given user "" has been created with default attributes and without skeleton files When user "Brian" tries to search for user "" using Graph API Then the HTTP status code should be "400" @@ -1433,9 +1433,11 @@ Feature: get users | user | error-token | | Alice-From-Wonderland | -From-Wonderland | | Alice@From@Wonderland | @From@Wonderland | + | -_.ocusr | -_. | + | _ocusr@ | _oc | @issue-7990 - Scenario: non-admin user searches other users by e-mail + Scenario: non-admin user searches other users by e-mail (search term with quotation) When user "Brian" searches for user "%22alice@example.org%22" using Graph API Then the HTTP status code should be "200" And the JSON data of the search response should not contain user email @@ -1601,3 +1603,67 @@ Feature: get users } } """ + + + Scenario: user searches for a non-existent user/group + When user "Brian" tries to search for user "nonexistent" 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": 0, + "maxItems": 0 + } + } + } + """ + + @issue-7990 + Scenario Outline: user searches for other users having special characters in displayname (search term with quotation) + Given the user "Admin" has created a new user with the following attributes: + | userName | specail-user | + | displayName | | + | email | specialuser@example.org | + When user "Brian" searches for user '""' 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": { + "const": "" + }, + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "userType": { + "const": "Member" + } + } + } + } + } + } + """ + Examples: + | displayname | search-term | + | -_.ocusr | -_. | + | _ocusr@ | _oc | + | Alice-Wonderland | -Wonderland | + | Alice@Wonderland | @Wonderland | \ No newline at end of file