adding tests for searching user as a normal user (#8094)
This commit is contained in:
@@ -259,6 +259,32 @@ class GraphHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
* @param string $adminUser
|
||||
* @param string $adminPassword
|
||||
* @param string $searchTerm
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public static function searchUser(
|
||||
string $baseUrl,
|
||||
string $xRequestId,
|
||||
string $adminUser,
|
||||
string $adminPassword,
|
||||
string $searchTerm
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, "users?\$search=$searchTerm");
|
||||
return HttpRequestHelper::get(
|
||||
$url,
|
||||
$xRequestId,
|
||||
$adminUser,
|
||||
$adminPassword,
|
||||
self::getRequestHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
|
||||
@@ -59,8 +59,6 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
||||
|
||||
#### [A User can get information of another user with Graph API](https://github.com/owncloud/ocis/issues/5125)
|
||||
|
||||
- [apiGraph/getUser.feature:87](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L87)
|
||||
- [apiGraph/getUser.feature:88](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L88)
|
||||
- [apiGraph/getUser.feature:89](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L89)
|
||||
- [apiGraph/getUser.feature:90](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L90)
|
||||
- [apiGraph/getUser.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L91)
|
||||
@@ -71,18 +69,20 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
||||
- [apiGraph/getUser.feature:96](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L96)
|
||||
- [apiGraph/getUser.feature:97](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L97)
|
||||
- [apiGraph/getUser.feature:98](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L98)
|
||||
- [apiGraph/getUser.feature:642](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L642)
|
||||
- [apiGraph/getUser.feature:643](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L643)
|
||||
- [apiGraph/getUser.feature:644](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L644)
|
||||
- [apiGraph/getUser.feature:645](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L645)
|
||||
- [apiGraph/getUser.feature:646](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L646)
|
||||
- [apiGraph/getUser.feature:647](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L647)
|
||||
- [apiGraph/getUser.feature:648](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L648)
|
||||
- [apiGraph/getUser.feature:649](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L649)
|
||||
- [apiGraph/getUser.feature:99](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L99)
|
||||
- [apiGraph/getUser.feature:100](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L100)
|
||||
- [apiGraph/getUser.feature:650](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L650)
|
||||
- [apiGraph/getUser.feature:651](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L651)
|
||||
- [apiGraph/getUser.feature:652](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L652)
|
||||
- [apiGraph/getUser.feature:653](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L653)
|
||||
- [apiGraph/getUser.feature:654](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L654)
|
||||
- [apiGraph/getUser.feature:655](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L655)
|
||||
- [apiGraph/getUser.feature:656](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L656)
|
||||
- [apiGraph/getUser.feature:657](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L657)
|
||||
- [apiGraph/getUser.feature:658](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L658)
|
||||
- [apiGraph/getUser.feature:659](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L659)
|
||||
- [apiGraph/getUser.feature:660](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L660)
|
||||
- [apiGraph/getUser.feature:661](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L661)
|
||||
|
||||
#### [Normal user can get expanded members information of a group](https://github.com/owncloud/ocis/issues/5604)
|
||||
|
||||
|
||||
@@ -75,8 +75,10 @@ Feature: get users
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"type": "string",
|
||||
"enum": ["Unauthorized"]
|
||||
"message":{
|
||||
"type": "string",
|
||||
"enum": ["Unauthorized"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,8 +271,10 @@ Feature: get users
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"type": "string",
|
||||
"enum": ["Unauthorized"]
|
||||
"message": {
|
||||
"type": "string",
|
||||
"enum": ["search term too short"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -359,14 +363,16 @@ Feature: get users
|
||||
"user"
|
||||
],
|
||||
"properties": {
|
||||
"user": "string",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"enum": ["%user_id_pattern%"]
|
||||
"user": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "%user_id_pattern%"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -630,8 +636,10 @@ Feature: get users
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"type": "string",
|
||||
"enum": ["Unauthorized"]
|
||||
"message: {
|
||||
"type": "string",
|
||||
"enum": ["Unauthorized"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -905,8 +913,10 @@ Feature: get users
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"type": "string",
|
||||
"enum": ["Unauthorized"]
|
||||
"message": {
|
||||
"type": "string",
|
||||
"enum": ["search term too short"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1057,8 +1067,10 @@ Feature: get users
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"type": "string",
|
||||
"enum": ["Unauthorized"]
|
||||
"message": {
|
||||
"type": "string",
|
||||
"enum": ["search term too short"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1327,3 +1339,107 @@ Feature: get users
|
||||
| Space Admin |
|
||||
| User |
|
||||
| User Light |
|
||||
|
||||
|
||||
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",
|
||||
"required": [
|
||||
"displayName",
|
||||
"id",
|
||||
"mail",
|
||||
"userType"
|
||||
],
|
||||
"properties": {
|
||||
"displayName": {
|
||||
"type": "string",
|
||||
"enum": ["Alice Hansen"]
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^%user_id_pattern%$"
|
||||
},
|
||||
"mail": {
|
||||
"type": "string",
|
||||
"enum": ["alice@example.org"]
|
||||
},
|
||||
"userType": {
|
||||
"type": "string",
|
||||
"enum": ["Member"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
Scenario: non-admin user tries to search for a user by display name with less than 3 characters
|
||||
When user "Brian" tries to search for user "al" using Graph API
|
||||
Then the HTTP status code should be "403"
|
||||
And the JSON data of the response should match
|
||||
"""
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"error"
|
||||
],
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string",
|
||||
"enum": ["search term too short"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
@issue-7990
|
||||
Scenario Outline: non-admin user tries to search for a user by display name with invalid characters/token
|
||||
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"
|
||||
And the JSON data of the response should match
|
||||
"""
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"error"
|
||||
],
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string",
|
||||
"enum": ["Token '<errorToken>' is invalid"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
Examples:
|
||||
| user | errorToken |
|
||||
| Alice-From-Wonderland | -From-Wonderland |
|
||||
| Alice@From@Wonderland | @From@Wonderland |
|
||||
|
||||
@@ -1277,6 +1277,28 @@ class GraphContext implements Context {
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :byUser tries to search for user :searchTerm using Graph API
|
||||
* @When user :byUser searches for user :searchTerm using Graph API
|
||||
*
|
||||
* @param string $byUser
|
||||
* @param string $searchTerm
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSearchesForUserUsingGraphApi(string $byUser, string $searchTerm): void {
|
||||
$credentials = $this->getAdminOrUserCredentials($byUser);
|
||||
$response = GraphHelper::searchUser(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$credentials['username'],
|
||||
$credentials['password'],
|
||||
$searchTerm,
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user tries to get all users using the Graph API
|
||||
* @When user :user gets all users using the Graph API
|
||||
|
||||
Reference in New Issue
Block a user