-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tests-only][full-ci] removing the setResponse()
and $this->response
in given/then step in Provisioning file
#7510
Conversation
bfae1e5
to
a770b07
Compare
49f077d
to
f7a8a62
Compare
2c46b2b
to
0fbb7e4
Compare
aae0217
to
573119d
Compare
573119d
to
fc862cc
Compare
fc862cc
to
f793d59
Compare
/** | ||
* @param string $user | ||
* | ||
* @return ResponseInterface | ||
* @throws Exception | ||
*/ | ||
public function deleteTheUserUsingTheProvisioningApi(string $user):ResponseInterface { | ||
$this->emptyLastHTTPStatusCodesArray(); | ||
$this->emptyLastOCSStatusCodesArray(); | ||
$response = null; | ||
// Always try to delete the user | ||
if (OcisHelper::isTestingWithGraphApi()) { | ||
// users can be deleted using the username in the GraphApi too | ||
$response = $this->graphContext->adminDeletesUserUsingTheGraphApi($user); | ||
} else { | ||
$response = UserHelper::deleteUser( | ||
$this->getBaseUrl(), | ||
$user, | ||
$this->getAdminUsername(), | ||
$this->getAdminPassword(), | ||
$this->getStepLineRef(), | ||
$this->ocsApiVersion | ||
); | ||
} | ||
if ($response === null) { | ||
$this->pushToLastStatusCodesArrays(); | ||
} else { | ||
$this->pushToLastHttpStatusCodesArray((string)$response->getStatusCode()); | ||
} | ||
|
||
// Only log a message if the test really expected the user to have been | ||
// successfully created (i.e. the delete is expected to work) and | ||
// there was a problem deleting the user. Because in this case there | ||
// might be an effect on later tests. | ||
if ($this->theUserShouldExist($user) | ||
&& (!\in_array($response->getStatusCode(), [200, 204])) | ||
) { | ||
\error_log( | ||
"INFORMATION: could not delete user '$user' " | ||
. $response->getStatusCode() . " " . $response->getBody() | ||
); | ||
} | ||
|
||
$this->rememberThatUserIsNotExpectedToExist($user); | ||
return $response; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover from rebase?
public function theUsersReturnedByTheApiShouldNotInclude(string $user, ResponseInterface $response):void { | ||
$response = $response ?? $this->response; | ||
$respondedArray = $this->getArrayOfUsersResponded($response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's not reuse Then step methods
public function theDisplayNameReturnedByTheApiShouldBe(string $expectedDisplayName, ?ResponseInterface $response = null):void { | ||
$responseDisplayName = (string) $this->getResponseXml($response, __METHOD__)->data[0]->displayname; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for here as well
f793d59
to
bad274b
Compare
Kudos, SonarCloud Quality Gate passed! |
Description
We have used setResponse() and $this->response in the Given/Then steps and some helper functions (maybe to reuse existing available methods). But storing responses from Given/Then steps and helper functions is not a good idea because it can lead to a false positive assertion in the Then steps.
So, check the use of setResponse() and $this->response in
So this pr make the above changes in
Provisioning.php
Related Issue
part of: #7082
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: