[tests-only] Fix share creation methods (#7400) (#7425)

fix steps

add method to create folder

strict check for successful request

fix steps
This commit is contained in:
Sawjan Gurung
2023-10-06 17:11:31 +05:45
committed by GitHub
parent 9cee6bcbcd
commit bfe04776fb
5 changed files with 149 additions and 417 deletions

View File

@@ -657,6 +657,8 @@ class HttpRequestHelper {
* @return array
*/
public static function parseResponseAsXml(ResponseInterface $response):array {
// rewind so that we can reparse it if it was parsed already
$response->getBody()->rewind();
$body = $response->getBody()->getContents();
$parsedResponse = [];
if ($body && \substr($body, 0, 1) === '<') {

View File

@@ -30,8 +30,9 @@ Feature: Email notification
Scenario: user gets an email notification when someone shares a file
Given user "Alice" has uploaded file with content "sample text" to "lorem.txt"
When user "Alice" has shared file "lorem.txt" with user "Brian" with permissions "17"
When user "Alice" shares file "lorem.txt" with user "Brian" with permissions "17" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "100"
And user "Brian" should have received the following email from user "Alice"
"""
Hello Brian Murphy
@@ -80,8 +81,9 @@ Feature: Email notification
And user "Brian" has switched the system language to "es"
And user "Carol" has switched the system language to "de"
And user "Alice" has created folder "/HelloWorld"
When user "Alice" has shared folder "/HelloWorld" with group "group1"
When user "Alice" shares folder "HelloWorld" with group "group1" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "100"
And user "Brian" should have received the following email from user "Alice"
"""
Hola Brian Murphy
@@ -108,8 +110,9 @@ Feature: Email notification
And user "Brian" has switched the system language to "es"
And user "Carol" has switched the system language to "de"
And user "Alice" has uploaded file with content "hello world" to "text.txt"
When user "Alice" has shared file "text.txt" with group "group1"
When user "Alice" shares file "text.txt" with group "group1" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "100"
And user "Brian" should have received the following email from user "Alice"
"""
Hola Brian Murphy

View File

@@ -249,10 +249,10 @@ trait Sharing {
* | | 6 = federated (cloud share). |
* | | Pass either the number or the keyword. |
*
* @return void
* @return ResponseInterface
* @throws Exception
*/
public function createShareWithSettings(string $user, ?TableNode $body):void {
public function createShareWithSettings(string $user, ?TableNode $body): ResponseInterface {
$user = $this->getActualUsername($user);
$this->verifyTableNodeRows(
$body,
@@ -290,7 +290,7 @@ trait Sharing {
$needToParse = \array_key_exists('expireDate', $bodyRows);
$expireDate = $bodyRows['expireDate'] ?? $bodyRows['expireDateAsString'] ?? null;
$bodyRows['expireDate'] = $needToParse ? \date('Y-m-d', \strtotime($expireDate)) : $expireDate;
$this->createShare(
return $this->createShare(
$user,
$bodyRows['path'],
$bodyRows['shareType'],
@@ -314,10 +314,11 @@ trait Sharing {
*/
public function userCreatesAShareWithSettings(string $user, ?TableNode $body):void {
$user = $this->getActualUsername($user);
$this->createShareWithSettings(
$response = $this->createShareWithSettings(
$user,
$body
);
$this->setResponse($response);
$this->pushToLastStatusCodesArrays();
}
@@ -331,26 +332,12 @@ trait Sharing {
* @throws Exception
*/
public function userHasCreatedAShareWithSettings(string $user, ?TableNode $body) {
$this->createShareWithSettings(
$response = $this->createShareWithSettings(
$user,
$body
);
$this->theHTTPStatusCodeShouldBe(
200,
"Failed HTTP status code for last share for user $user" . ", Reason: " . $this->getResponse()->getReasonPhrase()
);
}
/**
* @When /^the user creates a share using the sharing API with settings$/
*
* @param TableNode|null $body
*
* @return void
* @throws Exception
*/
public function theUserCreatesAShareWithSettings(?TableNode $body):void {
$this->createShareWithSettings($this->currentUser, $body);
$this->theHTTPStatusCodeShouldBe(200, "", $response);
$this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response);
}
/**
@@ -367,7 +354,8 @@ trait Sharing {
// A public link share is shareType 3
$rows[] = ['shareType', 'public_link'];
$newBody = new TableNode($rows);
$this->createShareWithSettings($user, $newBody);
$response = $this->createShareWithSettings($user, $newBody);
$this->setResponse($response);
$this->pushToLastStatusCodesArrays();
}
@@ -399,20 +387,6 @@ trait Sharing {
$this->userCreatesAPublicLinkShareWithSettings($this->currentUser, $body);
}
/**
* @Given /^the user has created a share with settings$/
*
* @param TableNode|null $body
*
* @return void
* @throws Exception
*/
public function theUserHasCreatedAShareWithSettings(?TableNode $body):void {
$this->createShareWithSettings($this->currentUser, $body);
$this->ocsContext->theOCSStatusCodeShouldBe("100,200");
$this->theHTTPStatusCodeShouldBe(200);
}
/**
* @Given /^the user has created a public link share with settings$/
*
@@ -436,7 +410,7 @@ trait Sharing {
* @param string|null $linkName
* @param string|null $expireDate
*
* @return void
* @return ResponseInterface
*/
public function createAPublicShare(
string $user,
@@ -446,9 +420,8 @@ trait Sharing {
$permissions = null,
?string $linkName = null,
?string $expireDate = null
):void {
$user = $this->getActualUsername($user);
$this->createShare(
): ResponseInterface {
return $this->createShare(
$user,
$path,
'public_link',
@@ -470,7 +443,8 @@ trait Sharing {
* @return void
*/
public function userCreatesAPublicLinkShareOf(string $user, string $path):void {
$this->createAPublicShare($user, $path);
$response = $this->createAPublicShare($user, $path);
$this->setResponse($response);
}
/**
@@ -482,55 +456,9 @@ trait Sharing {
* @return void
*/
public function userHasCreatedAPublicLinkShareOf(string $user, string $path):void {
$this->createAPublicShare($user, $path);
$this->theHTTPStatusCodeShouldBeSuccess();
}
/**
* @param string $path
*
* @return void
*/
public function createPublicLinkShareOfResourceAsCurrentUser(string $path):void {
$this->createAPublicShare($this->currentUser, $path);
}
/**
* @When /^the user creates a public link share of (?:file|folder) "([^"]*)" using the sharing API$/
*
* @param string $path
*
* @return void
*/
public function aPublicLinkShareOfIsCreated(string $path):void {
$this->createPublicLinkShareOfResourceAsCurrentUser($path);
}
/**
* @Given /^the user has created a public link share of (?:file|folder) "([^"]*)"$/
*
* @param string $path
*
* @return void
*/
public function aPublicLinkShareOfHasCreated(string $path):void {
$this->createPublicLinkShareOfResourceAsCurrentUser($path);
$this->theHTTPStatusCodeShouldBeSuccess();
}
/**
* @param string $user
* @param string $path
* @param string|int|string[]|int[]|null $permissions
*
* @return void
*/
public function createPublicLinkShareOfResourceWithPermission(
string $user,
string $path,
$permissions
):void {
$this->createAPublicShare($user, $path, true, null, $permissions);
$response = $this->createAPublicShare($user, $path);
$this->theHTTPStatusCodeShouldBe(200, "", $response);
$this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response);
}
/**
@@ -547,11 +475,8 @@ trait Sharing {
string $path,
$permissions
):void {
$this->createPublicLinkShareOfResourceWithPermission(
$user,
$path,
$permissions
);
$response = $this->createAPublicShare($user, $path, true, null, $permissions);
$this->setResponse($response);
}
/**
@@ -568,53 +493,9 @@ trait Sharing {
string $path,
$permissions
):void {
$this->createPublicLinkShareOfResourceWithPermission(
$user,
$path,
$permissions
);
$this->theHTTPStatusCodeShouldBeSuccess();
}
/**
* @param string $path
* @param string|int|string[]|int[]|null $permissions
*
* @return void
*/
public function createPublicLinkShareWithPermissionByCurrentUser(string $path, $permissions):void {
$this->createAPublicShare(
$this->currentUser,
$path,
true,
null,
$permissions
);
}
/**
* @When /^the user creates a public link share of (?:file|folder) "([^"]*)" using the sharing API with (read|update|create|delete|change|uploadwriteonly|share|all) permission(?:s|)$/
*
* @param string $path
* @param string|int|string[]|int[]|null $permissions
*
* @return void
*/
public function aPublicLinkShareOfIsCreatedWithPermission(string $path, $permissions):void {
$this->createPublicLinkShareWithPermissionByCurrentUser($path, $permissions);
}
/**
* @Given /^the user has created a public link share of (?:file|folder) "([^"]*)" with (read|update|create|delete|change|uploadwriteonly|share|all) permission(?:s|)$/
*
* @param string $path
* @param string|int|string[]|int[]|null $permissions
*
* @return void
*/
public function aPublicLinkShareOfHasCreatedWithPermission(string $path, $permissions):void {
$this->createPublicLinkShareWithPermissionByCurrentUser($path, $permissions);
$this->theHTTPStatusCodeShouldBeSuccess();
$response = $this->createAPublicShare($user, $path, true, null, $permissions);
$this->theHTTPStatusCodeShouldBe(200, "", $response);
$this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response);
}
/**
@@ -704,43 +585,6 @@ trait Sharing {
);
}
/**
* @When /^the user creates a public link share of (?:file|folder) "([^"]*)" using the sharing API with expiry "([^"]*)$"/
*
* @param string $path
* @param string $expiryDate in a valid date format, e.g. "+30 days"
*
* @return void
*/
public function aPublicLinkShareOfIsCreatedWithExpiry(
string $path,
string $expiryDate
):void {
$this->createPublicLinkShareOfResourceWithExpiryByCurrentUser(
$path,
$expiryDate
);
}
/**
* @Given /^the user has created a public link share of (?:file|folder) "([^"]*)" with expiry "([^"]*)$/
*
* @param string $path
* @param string $expiryDate in a valid date format, e.g. "+30 days"
*
* @return void
*/
public function aPublicLinkShareOfHasCreatedWithExpiry(
string $path,
string $expiryDate
):void {
$this->createPublicLinkShareOfResourceWithExpiryByCurrentUser(
$path,
$expiryDate
);
$this->theHTTPStatusCodeShouldBeSuccess();
}
/**
* @Then /^user "([^"]*)" should not be able to create a public link share of (file|folder) "([^"]*)" using the sharing API$/
*
@@ -752,11 +596,6 @@ trait Sharing {
* @throws Exception
*/
public function shouldNotBeAbleToCreatePublicLinkShare(string $sharer, string $entry, string $filepath):void {
$this->asFileOrFolderShouldExist(
$this->getActualUsername($sharer),
$entry,
$filepath
);
$this->createAPublicShare($sharer, $filepath);
Assert::assertEquals(
404,
@@ -969,7 +808,7 @@ trait Sharing {
* @param string|null $expireDate
* @param string $sharingApp
*
* @return void
* @return ResponseInterface
* @throws JsonException
* @throws Exception
*/
@@ -984,13 +823,13 @@ trait Sharing {
?string $linkName = null,
?string $expireDate = null,
string $sharingApp = 'files_sharing'
):void {
): ResponseInterface {
$userActual = $this->getActualUsername($user);
if (\is_string($permissions) && !\is_numeric($permissions)) {
$permissions = $this->splitPermissionsString($permissions);
}
$this->waitToCreateShare();
$this->response = SharingHelper::createShare(
$response = SharingHelper::createShare(
$this->getBaseUrl(),
$userActual,
$this->getPasswordForUser($user),
@@ -1007,33 +846,24 @@ trait Sharing {
$this->sharingApiVersion,
$sharingApp
);
$httpStatusCode = $this->response->getStatusCode();
// In case of HTTP status code 204 "no content", or a failure code like 4xx
// in the HTTP or OCS status there is no useful content in response payload body.
// Clear the test-runner's memory of "last share data" to avoid later steps
// accidentally using some previous share data.
if (($httpStatusCode === 204)
|| !$this->theHTTPStatusCodeWasSuccess()
|| (($httpStatusCode === 200) && ($this->ocsContext->getOCSResponseStatusCode($this->response) > 299))
// save the created share data
if (($response->getStatusCode() === 200)
&& \in_array($this->ocsContext->getOCSResponseStatusCode($response), ['100', '200'])
) {
if ($shareType === 'public_link') {
$this->emptyCreatedPublicShares();
} else {
$this->emptyCreatedUserGroupShares();
}
} else {
$response = $this->getResponseXml(null, __METHOD__);
if (isset($response->data)) {
$shareData = $response->data;
$xmlResponse = $this->getResponseXml($response);
if (isset($xmlResponse->data)) {
$shareData = $xmlResponse->data;
if ($shareType === 'public_link') {
$this->addToCreatedPublicShares($shareData);
} else {
$sharer = (string) $response->data->uid_owner;
$sharer = (string) $xmlResponse->data->uid_owner;
$this->addToCreatedUserGroupshares($sharer, $shareData);
}
}
}
$this->localLastShareTime = \microtime(true);
return $response;
}
/**
@@ -1310,89 +1140,54 @@ trait Sharing {
/**
*
* @param string $user1
* @param string $sharer
* @param string $filepath
* @param string $user2
* @param string $sharee
* @param string|int|string[]|int[] $permissions
* @param bool|null $getShareData If true then only create the share if it is not
* already existing, and at the end request the
* share information and leave that in $this->response
* Typically used in a "Given" step which verifies
* that the share did get created successfully.
*
* @return void
* @return ResponseInterface
*/
public function shareFileWithUserUsingTheSharingApi(
string $user1,
public function createAUserShare(
string $sharer,
string $filepath,
string $user2,
$permissions = null,
?bool $getShareData = false
):void {
$user1Actual = $this->getActualUsername($user1);
$user2Actual = $this->getActualUsername($user2);
$path = $this->getSharesEndpointPath("?path=" . \urlencode($filepath));
$this->response = OcsApiHelper::sendRequest(
$this->getBaseUrl(),
$user1Actual,
$this->getPasswordForUser($user1),
"GET",
$path,
$this->getStepLineRef(),
[],
$this->ocsApiVersion
string $sharee,
$permissions = null
): ResponseInterface {
return $this->createShare(
$sharer,
$filepath,
'0',
$this->getActualUsername($sharee),
null,
null,
$permissions
);
if ($getShareData && $this->isUserOrGroupInSharedData($user2Actual, "user", $permissions)) {
return;
} else {
$this->createShare(
$user1,
$filepath,
'0',
$user2Actual,
null,
null,
$permissions
);
}
if ($getShareData) {
$this->response = OcsApiHelper::sendRequest(
$this->getBaseUrl(),
$user1Actual,
$this->getPasswordForUser($user1),
"GET",
$path,
$this->getStepLineRef(),
[],
$this->ocsApiVersion
);
}
}
/**
* @When /^user "([^"]*)" shares (?:file|folder|entry) "([^"]*)" with user "([^"]*)"(?: with permissions (\d+))? using the sharing API$/
* @When /^user "([^"]*)" shares (?:file|folder|entry) "([^"]*)" with user "([^"]*)" with permissions "([^"]*)" using the sharing API$/
*
* @param string $user1
* @param string $sharer
* @param string $filepath
* @param string $user2
* @param string $sharee
* @param string|int|string[]|int[] $permissions
*
* @return void
*/
public function userSharesFileWithUserUsingTheSharingApi(
string $user1,
string $sharer,
string $filepath,
string $user2,
string $sharee,
$permissions = null
):void {
$this->shareFileWithUserUsingTheSharingApi(
$user1,
$response = $this->createAUserShare(
$sharer,
$filepath,
$user2,
$this->getActualUsername($sharee),
$permissions
);
$this->setResponse($response);
$this->pushToLastStatusCodesArrays();
}
@@ -1431,37 +1226,28 @@ trait Sharing {
* @Given /^user "([^"]*)" has shared (?:file|folder|entry) "([^"]*)" with user "([^"]*)"(?: with permissions (\d+))?$/
* @Given /^user "([^"]*)" has shared (?:file|folder|entry) "([^"]*)" with user "([^"]*)" with permissions "([^"]*)"$/
*
* @param string $user1
* @param string $sharer
* @param string $filepath
* @param string $user2
* @param string $sharee
* @param string|int|string[]|int[] $permissions
*
* @return void
* @throws Exception
*/
public function userHasSharedFileWithUserUsingTheSharingApi(
string $user1,
string $sharer,
string $filepath,
string $user2,
string $sharee,
$permissions = null
):void {
$user1 = $this->getActualUsername($user1);
$user2 = $this->getActualUsername($user2);
$this->shareFileWithUserUsingTheSharingApi(
$user1,
$response = $this->createAUserShare(
$sharer,
$filepath,
$user2,
$permissions,
true
);
$this->ocsContext->assertOCSResponseIndicatesSuccess(
'The ocs share response does not indicate success.',
);
// this is expected to fail if a file is shared with create and delete permissions, which is not possible
Assert::assertTrue(
$this->isUserOrGroupInSharedData($user2, "user", $permissions),
__METHOD__ . " User $user1 failed to share $filepath with user $user2"
$this->getActualUsername($sharee),
$permissions
);
$this->theHTTPStatusCodeShouldBe(200, "", $response);
$this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response);
}
/**
@@ -1588,58 +1374,24 @@ trait Sharing {
* @param string $filepath
* @param string $group
* @param string|int|string[]|int[] $permissions
* @param bool $getShareData If true then only create the share if it is not
* already existing, and at the end request the
* share information and leave that in $this->response
* Typically used in a "Given" step which verifies
* that the share did get created successfully.
*
* @return void
* @return ResponseInterface
*/
public function shareFileWithGroupUsingTheSharingApi(
public function createAGroupShare(
string $user,
string $filepath,
string$group,
$permissions = null,
bool $getShareData = false
):void {
$userActual = $this->getActualUsername($user);
$path = $this->getSharesEndpointPath("?path=$filepath");
$this->response = OcsApiHelper::sendRequest(
$this->getBaseUrl(),
$userActual,
$this->getPasswordForUser($user),
"GET",
$path,
$this->getStepLineRef(),
[],
$this->ocsApiVersion
$permissions = null
): ResponseInterface {
return $this->createShare(
$user,
$filepath,
'1',
$group,
null,
null,
$permissions
);
if ($getShareData && $this->isUserOrGroupInSharedData($group, "group", $permissions)) {
return;
} else {
$this->createShare(
$user,
$filepath,
'1',
$group,
null,
null,
$permissions
);
}
if ($getShareData) {
$this->response = OcsApiHelper::sendRequest(
$this->getBaseUrl(),
$userActual,
$this->getPasswordForUser($user),
"GET",
$path,
$this->getStepLineRef(),
[],
$this->ocsApiVersion
);
}
}
/**
@@ -1659,12 +1411,13 @@ trait Sharing {
string $group,
$permissions = null
) {
$this->shareFileWithGroupUsingTheSharingApi(
$response = $this->createAGroupShare(
$user,
$filepath,
$group,
$permissions
);
$this->setResponse($response);
$this->pushToLastStatusCodesArrays();
}
@@ -1716,19 +1469,14 @@ trait Sharing {
string $group,
$permissions = null
) {
$this->shareFileWithGroupUsingTheSharingApi(
$response = $this->createAGroupShare(
$user,
$filepath,
$group,
$permissions,
true
);
Assert::assertTrue(
$this->isUserOrGroupInSharedData($group, "group", $permissions),
__METHOD__
. " Could not assert that user '$user' has shared '$filepath' with group '$group' with permissions '$permissions'"
$permissions
);
$this->theHTTPStatusCodeShouldBe(200, "", $response);
$this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response);
}
/**
@@ -1780,12 +1528,7 @@ trait Sharing {
$permissions = null
):void {
$sharee = $this->getActualUsername($sharee);
$this->asFileOrFolderShouldExist(
$this->getActualUsername($sharer),
$entry,
$filepath
);
$this->createShare(
$response = $this->createShare(
$sharer,
$filepath,
$userOrGroupShareType,
@@ -1794,7 +1537,7 @@ trait Sharing {
null,
$permissions
);
$statusCode = $this->ocsContext->getOCSResponseStatusCode($this->response);
$statusCode = $this->ocsContext->getOCSResponseStatusCode($response);
Assert::assertTrue(
($statusCode == 404) || ($statusCode == 403),
"Sharing should have failed with status code 403 or 404 but got status code $statusCode"
@@ -1824,8 +1567,7 @@ trait Sharing {
$permissions = null
):void {
$sharee = $this->getActualUsername($sharee);
$this->asFileOrFolderShouldExist($sharer, $entry, $filepath);
$this->createShare(
$response = $this->createShare(
$sharer,
$filepath,
$userOrGroupShareType,
@@ -1835,9 +1577,11 @@ trait Sharing {
$permissions
);
//v1.php returns 100 as success code
//v2.php returns 200 in the same case
$this->ocsContext->theOCSStatusCodeShouldBe("100, 200");
$statusCode = $this->ocsContext->getOCSResponseStatusCode($response);
Assert::assertTrue(
($statusCode == 100) || ($statusCode == 200),
"Sharing should be successful but got ocs status code $statusCode"
);
}
/**
@@ -2995,7 +2739,6 @@ trait Sharing {
*/
public function checkPublicSharesAreEmpty(string $user, string $entry, string $path):void {
$user = $this->getActualUsername($user);
$this->asFileOrFolderShouldExist($user, $entry, $path);
$response = $this->getShares($user, $path);
//It shouldn't have public shares
Assert::assertEquals(

View File

@@ -1156,7 +1156,8 @@ class SpacesContext implements Context {
$ownerUser = $user;
}
$this->setSpaceIDByName($ownerUser, $spaceName);
$this->featureContext->userCreatesFolder($user, $folder);
$response = $this->featureContext->createFolder($user, $folder);
$this->featureContext->setResponse($response);
}
/**

View File

@@ -446,6 +446,34 @@ trait WebDav {
);
}
/**
*
* @param string $user
* @param string $folder
* @param bool|null $isGivenStep
*
* @return ResponseInterface
* @throws JsonException | GuzzleException
* @throws GuzzleException | JsonException
*/
public function createFolder(string $user, string $folder, ?bool $isGivenStep = false): ResponseInterface {
$folder = '/' . \ltrim($folder, '/');
return $this->makeDavRequest(
$user,
"MKCOL",
$folder,
[],
null,
"files",
null,
false,
null,
[],
null,
$isGivenStep
);
}
/**
* @param string $user
* @param string|null $path
@@ -3627,32 +3655,14 @@ trait WebDav {
*
* @param string $user
* @param string $destination
* @param bool|null $isGivenStep
*
* @return void
* @throws JsonException | GuzzleException
* @throws GuzzleException | JsonException
*/
public function userCreatesFolder(string $user, string $destination, ?bool $isGivenStep = false):void {
$user = $this->getActualUsername($user);
$destination = '/' . \ltrim($destination, '/');
$this->response = $this->makeDavRequest(
$user,
"MKCOL",
$destination,
[],
null,
"files",
null,
false,
null,
[],
null,
$isGivenStep
);
$this->setResponseXml(
HttpRequestHelper::parseResponseAsXml($this->response)
);
public function userCreatesFolder(string $user, string $destination):void {
$response = $this->createFolder($user, $destination);
$this->setResponse($response);
$this->pushToLastHttpStatusCodesArray();
}
@@ -3667,13 +3677,12 @@ trait WebDav {
* @throws GuzzleException
*/
public function userHasCreatedFolder(string $user, string $destination):void {
$user = $this->getActualUsername($user);
$this->userCreatesFolder($user, $destination, true);
$response = $this->createFolder($user, $destination, true);
$this->theHTTPStatusCodeShouldBe(
["201", "204"],
"HTTP status code was not 201 or 204 while trying to create folder '$destination' for user '$user'"
"HTTP status code was not 201 or 204 while trying to create folder '$destination' for user '$user'",
$response
);
$this->emptyLastHTTPStatusCodesArray();
}
/**
@@ -3692,13 +3701,13 @@ trait WebDav {
$admin,
__METHOD__ . "The provided user is not admin but '" . $admin . "'"
);
$this->userCreatesFolder($admin, $destination, true);
$response = $this->createFolder($admin, $destination, true);
$this->theHTTPStatusCodeShouldBe(
["201", "204"],
"HTTP status code was not 201 or 204 while trying to create folder '$destination' for admin '$admin'"
"HTTP status code was not 201 or 204 while trying to create folder '$destination' for admin '$admin'",
$response
);
$this->adminResources[] = $destination;
$this->emptyLastHTTPStatusCodesArray();
}
/**
@@ -3719,32 +3728,6 @@ trait WebDav {
}
}
/**
* @When the user creates folder :destination using the WebDAV API
*
* @param string $destination
*
* @return void
*/
public function theUserCreatesFolder(string $destination):void {
$this->userCreatesFolder($this->getCurrentUser(), $destination);
}
/**
* @Given the user has created folder :destination
*
* @param string $destination
*
* @return void
*/
public function theUserHasCreatedFolder(string $destination):void {
$this->theUserCreatesFolder($destination);
$this->theHTTPStatusCodeShouldBe(
["201", "204"],
"HTTP status code was not 201 or 204 while trying to create folder '$destination'"
);
}
/**
* @Then user :user should be able to create folder :destination
*
@@ -3774,12 +3757,11 @@ trait WebDav {
*/
public function userShouldNotBeAbleToCreateFolder(string $user, string $destination):void {
$user = $this->getActualUsername($user);
$this->userCreatesFolder($user, $destination);
$this->theHTTPStatusCodeShouldBeFailure();
$this->asFileOrFolderShouldNotExist(
$user,
"folder",
$destination
$response = $this->createFolder($user, $destination);
Assert::assertNotEquals(
201,
$response->getStatusCode(),
"User '$user' should not be able to create folder '$destination' but was successful"
);
}
@@ -4842,10 +4824,11 @@ trait WebDav {
* @throws Exception
*/
public function theDavElementShouldBe(string $element, string $message):void {
$resXmlArray = HttpRequestHelper::parseResponseAsXml($this->getResponse());
WebDavAssert::assertDavResponseElementIs(
$element,
$message,
$this->responseXml,
$resXmlArray,
__METHOD__
);
}