[tests-only] add graph API tests for password change re-authentication (#12664)
test: add graph API tests for password change re-authentication Signed-off-by: nabim777 <nabinalemagar019@gmail.com>
This commit is contained in:
1 parent
2ea716aea4
commit
afa8790227
3 files changed
+63
-1
No files matched your search
@@ -1181,6 +1181,37 @@ class GraphHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
* @param string $newPassword
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function updateUserPasswordUsingPatch(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $newPassword,
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, 'me');
|
||||
$payload = [
|
||||
'passwordProfile' => [
|
||||
'password' => $newPassword,
|
||||
],
|
||||
];
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$url,
|
||||
'PATCH',
|
||||
$user,
|
||||
$password,
|
||||
self::getRequestHeaders(),
|
||||
\json_encode($payload),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $user
|
||||
|
||||
@@ -1009,6 +1009,26 @@ class GraphContext implements Context {
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user tries to change their password to :new_password with patch request using the Graph API
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $newPassword
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function usertriesToChangesOwnPassword(string $user, string $newPassword): void {
|
||||
$response = GraphHelper::updateUserPasswordUsingPatch(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$newPassword,
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user gets all the groups using the Graph API
|
||||
*
|
||||
|
||||
@@ -12,9 +12,20 @@ Feature: an user changes its own password
|
||||
| current-password | new-password | http-status-code |
|
||||
| 123456 | validPass | 204 |
|
||||
| 123456 | кириллица | 204 |
|
||||
| 123456 | 密码 | 204 |
|
||||
| 123456 | 密码 | 204 |
|
||||
| 123456 | ?&^%0 | 204 |
|
||||
| 123456 | | 400 |
|
||||
| 123456 | 123456 | 400 |
|
||||
| wrongPass | 123456 | 400 |
|
||||
| | validPass | 400 |
|
||||
|
||||
|
||||
Scenario Outline: user tries to change password without current password using PATCH
|
||||
Given user "Alice" has been created with default attributes
|
||||
When user "Alice" tries to change their password to "<new-password>" with patch request using the Graph API
|
||||
Then the HTTP status code should be "<http-status-code>"
|
||||
Examples:
|
||||
| new-password | http-status-code |
|
||||
| 123456 | 400 |
|
||||
| newPass | 400 |
|
||||
| | 400 |
|
||||
Reference in new issue
Block a user