[test-only] add test to filter or (#5771)

* add test to filter or

* lint
This commit is contained in:
Viktor Scharf
2023-03-10 09:05:00 +01:00
committed by GitHub
parent 8560015c18
commit 94c3df2246
3 changed files with 71 additions and 0 deletions

View File

@@ -1151,6 +1151,35 @@ class GraphHelper {
);
}
/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
* @param string $firstGroup
* @param string $secondGroup
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function getUsersFromOneOrOtherGroup(
string $baseUrl,
string $xRequestId,
string $user,
string $password,
string $firstGroup,
string $secondGroup
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$firstGroup') " . "or memberOf/any(m:m/id eq '$secondGroup')");
return HttpRequestHelper::get(
$url,
$xRequestId,
$user,
$password,
self::getRequestHeaders()
);
}
/**
* @param string $baseUrl
* @param string $xRequestId

View File

@@ -135,6 +135,26 @@ Feature: get users
| Alice Hansen | %uuid_v4% | alice@example.org | Alice | true |
| Carol King | %uuid_v4% | carol@example.org | Carol | true |
@skipOnStable2.0
Scenario: admin user gets all users of certain groups
Given user "Carol" has been created with default attributes and without skeleton files
And group "tea-lover" has been created
And group "coffee-lover" has been created
And group "wine-lover" has been created
And user "Alice" has been added to group "tea-lover"
And user "Brian" has been added to group "coffee-lover"
And user "Carol" has been added to group "wine-lover"
When the user "Alice" gets all users from that are members in the group "tea-lover" or the group "coffee-lover" using the Graph API
Then the HTTP status code should be "200"
And the API response should contain following users with the information:
| displayName | id | mail | onPremisesSamAccountName | accountEnabled |
| Alice Hansen | %uuid_v4% | alice@example.org | Alice | true |
| Brian Murphy | %uuid_v4% | brian@example.org | Brian | true |
But the API response should not contain following user with the information:
| displayName | id | mail | onPremisesSamAccountName | accountEnabled |
| Carol King | %uuid_v4% | carol@example.org | Carol | false |
Scenario Outline: non admin user tries to get users of certain groups
Given the administrator has given "Brian" the role "<role>" using the settings api
And group "tea-lover" has been created

View File

@@ -1890,6 +1890,28 @@ class GraphContext implements Context {
$this->featureContext->setResponse($response);
}
/**
* @When the user :user gets all users from that are members in the group :firstGroup or the group :secondGroup using the Graph API
*
* @param string $user
* @param string $firstGroup
* @param string $secondGroup
*
* @return void
* @throws GuzzleException
*/
public function userGetsAllUsersOfFirstGroupOderSecondGroupUsingTheGraphApi(string $user, string $firstGroup, string $secondGroup) {
$response = GraphHelper::getUsersFromOneOrOtherGroup(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$firstGroup,
$secondGroup
);
$this->featureContext->setResponse($response);
}
/**
* Get roleId by role name
*