Skip to content

Commit

Permalink
add query params to the log (#7493) (#7399)
Browse files Browse the repository at this point in the history
Co-authored-by: Sawjan Gurung <saw.jan.grg3e@gmail.com>
  • Loading branch information
nirajacharya2 and saw-jan committed Oct 31, 2023
1 parent cc1f93e commit cbfd894
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
4 changes: 3 additions & 1 deletion tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public static function createUser(
* @param string $adminUser
* @param string $adminPassword
* @param string $userId
* @param string $method
* @param string|null $userName
* @param string|null $password
* @param string|null $email
Expand All @@ -187,6 +188,7 @@ public static function editUser(
string $adminUser,
string $adminPassword,
string $userId,
?string $method = "PATCH",
?string $userName = null,
?string $password = null,
?string $email = null,
Expand All @@ -204,7 +206,7 @@ public static function editUser(
return HttpRequestHelper::sendRequest(
$url,
$xRequestId,
"PATCH",
$method,
$adminUser,
$adminPassword,
self::getRequestHeaders(),
Expand Down
6 changes: 3 additions & 3 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1444,13 +1444,13 @@ public function theOcsDataOfTheResponseShouldMatch(
* @Then the JSON data of the response should match
*
* @param PyStringNode $schemaString
* @param ResponseInterface|null $response
*
* @return void
*
* @throws Exception
*/
public function theDataOfTheResponseShouldMatch(PyStringNode $schemaString): void {
$responseBody = $this->getJsonDecodedResponseBodyContent();
public function theDataOfTheResponseShouldMatch(PyStringNode $schemaString, ResponseInterface $response=null): void {
$responseBody = $this->getJsonDecodedResponseBodyContent($response);
$this->assertJsonDocumentMatchesSchema(
$responseBody,
$this->getJSONSchema($schemaString)
Expand Down
29 changes: 15 additions & 14 deletions tests/acceptance/features/bootstrap/GraphContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ public function theUserEnablesUserToUsingTheGraphApi(string $byUser, string $use
* @throws JsonException
*/
public function theUserInformationShouldMatchTheJSON(string $user, PyStringNode $schemaString): void {
$this->adminHasRetrievedUserUsingTheGraphApi($user);
$this->featureContext->theDataOfTheResponseShouldMatch($schemaString);
$response = $this->adminHasRetrievedUserUsingTheGraphApi($user);
$this->featureContext->theDataOfTheResponseShouldMatch($schemaString, $response);
}

/**
Expand All @@ -219,11 +219,12 @@ public function theUserInformationShouldMatchTheJSON(string $user, PyStringNode
* @param string|null $email
* @param string|null $displayName
* @param bool|true $accountEnabled
* @param string $method
*
* @return void
* @throws GuzzleException
*/
public function editUserUsingTheGraphApi(string $byUser, string $user, string $userName = null, string $password = null, string $email = null, string $displayName = null, bool $accountEnabled = true): ResponseInterface {
public function editUserUsingTheGraphApi(string $byUser, string $user, string $userName = null, string $password = null, string $email = null, string $displayName = null, bool $accountEnabled = true, string $method="PATCH"): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id');
$userId = $userId ?? $user;
Expand All @@ -233,6 +234,7 @@ public function editUserUsingTheGraphApi(string $byUser, string $user, string $u
$byUser,
$this->featureContext->getPasswordForUser($byUser),
$userId,
$method,
$userName,
$password,
$email,
Expand All @@ -244,23 +246,21 @@ public function editUserUsingTheGraphApi(string $byUser, string $user, string $u
/**
* @param string $user
*
* @return void
* @return ResponseInterface
* @throws JsonException
* @throws GuzzleException
*/
public function adminHasRetrievedUserUsingTheGraphApi(string $user): void {
public function adminHasRetrievedUserUsingTheGraphApi(string $user): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
$userId = $userId ?: $user;
$result = GraphHelper::getUser(
return GraphHelper::getUser(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$this->featureContext->getAdminUsername(),
$this->featureContext->getAdminPassword(),
$userId
);
$this->featureContext->setResponse($result);
$this->featureContext->thenTheHTTPStatusCodeShouldBe(200);
}

/**
Expand Down Expand Up @@ -523,21 +523,21 @@ public function adminChangesPasswordOfUserToUsingTheGraphApi(
string $user,
string $password,
?string $byUser = null
): void {
): ResponseInterface {
$credentials = $this->getAdminOrUserCredentials($byUser);
$user = $this->featureContext->getActualUsername($user);
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
$userId = $userId ?? $user;
$response = GraphHelper::editUser(
return GraphHelper::editUser(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$credentials["username"],
$credentials["password"],
$userId,
null,
"PATCH",
$user,
$password
);
$this->featureContext->setResponse($response);
}

/**
Expand All @@ -551,7 +551,8 @@ public function adminChangesPasswordOfUserToUsingTheGraphApi(
* @throws Exception
*/
public function theUserResetsThePasswordOfUserToUsingTheGraphApi(string $byUser, string $user, string $password) {
$this->adminChangesPasswordOfUserToUsingTheGraphApi($user, $password, $byUser);
$response = $this->adminChangesPasswordOfUserToUsingTheGraphApi($user, $password, $byUser);
$this->featureContext->setResponse($response);
}

/**
Expand Down Expand Up @@ -1415,7 +1416,7 @@ public function userTriesToGetOwnDriveInformation(string $user) {
* @param array $userIds
* @param string $groupId
*
* @return void
* @return ResponseInterface
* @throws GuzzleException
* @throws Exception
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,8 @@ public function usersHaveBeenCreated(
if (!$this->isTestingWithLdap()) {
// for graph api, we need to save the user id to be able to add it in some group
// can be fetched with the "onPremisesSamAccountName" i.e. userid
$this->graphContext->adminHasRetrievedUserUsingTheGraphApi($userAttributes['userid']);
$userAttributes['id'] = $this->getJsonDecodedResponse()['id'];
$response = $this->graphContext->adminHasRetrievedUserUsingTheGraphApi($userAttributes['userid']);
$userAttributes['id'] = $this->getJsonDecodedResponse($response)['id'];
} else {
$userAttributes['id'] = null;
}
Expand Down

0 comments on commit cbfd894

Please sign in to comment.