Skip to content

Commit

Permalink
test: add API tests to search user/group with special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Apr 30, 2024
1 parent f962cbb commit e7cbf93
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 4 deletions.
49 changes: 47 additions & 2 deletions tests/acceptance/features/apiGraphUserGroup/getGroup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 "<group>" has been created
When user "Brian" tries to search for group '"<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": "<group>"
},
"id": {
"type": "string",
"pattern": "%group_id_pattern%"
},
"groupTypes": {
"const": []
}
}
}
}
}
}
"""
Examples:
| group | token |
| tea-lovers | -lovers |
| tea@lovers | @lovers |
| -_.ocgrp | -_. |
| _ocgrp@ | _oc |
70 changes: 68 additions & 2 deletions tests/acceptance/features/apiGraphUserGroup/getUser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<user>" has been created with default attributes and without skeleton files
When user "Brian" tries to search for user "<user>" using Graph API
Then the HTTP status code should be "400"
Expand Down Expand Up @@ -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 "%[email protected]%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
Expand Down Expand Up @@ -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 | <displayname> |
| email | specialuser@example.org |
When user "Brian" searches for user '"<search-term>"' 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": "<displayname>"
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"userType": {
"const": "Member"
}
}
}
}
}
}
"""
Examples:
| displayname | search-term |
| -_.ocusr | -_. |
| _ocusr@ | _oc |
| Alice-Wonderland | -Wonderland |
| Alice@Wonderland | @Wonderland |

0 comments on commit e7cbf93

Please sign in to comment.