Merge pull request #10994 from owncloud/store-share-invite-response
[tests-only][full-ci] Store share invite response
This commit is contained in:
3 files changed
+87
-30
No files matched your search
@@ -116,13 +116,13 @@ trait Sharing {
|
||||
* @return void
|
||||
*/
|
||||
public function shareNgAddToCreatedLinkShares(ResponseInterface $response): void {
|
||||
$this->shareNgCreatedLinkShares[] = $response;
|
||||
$this->shareNgCreatedLinkShares[] = $this->getJsonDecodedResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResponseInterface|null
|
||||
* @return array|null
|
||||
*/
|
||||
public function shareNgGetLastCreatedLinkShare(): ?ResponseInterface {
|
||||
public function shareNgGetLastCreatedLinkShare(): ?array {
|
||||
return \end($this->shareNgCreatedLinkShares);
|
||||
}
|
||||
|
||||
@@ -132,13 +132,13 @@ trait Sharing {
|
||||
* @return void
|
||||
*/
|
||||
public function shareNgAddToCreatedUserGroupShares(ResponseInterface $response): void {
|
||||
$this->shareNgCreatedUserGroupShares[] = $response;
|
||||
$this->shareNgCreatedUserGroupShares[] = $this->getJsonDecodedResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResponseInterface|null
|
||||
* @return array|null
|
||||
*/
|
||||
public function shareNgGetLastCreatedUserGroupShare(): ?ResponseInterface {
|
||||
public function shareNgGetLastCreatedUserGroupShare(): ?array {
|
||||
return \end($this->shareNgCreatedUserGroupShares);
|
||||
}
|
||||
|
||||
@@ -201,10 +201,10 @@ trait Sharing {
|
||||
*/
|
||||
public function shareNgGetLastCreatedLinkShareID(): string {
|
||||
$lastResponse = $this->shareNgGetLastCreatedLinkShare();
|
||||
if (!isset($this->getJsonDecodedResponse($lastResponse)['id'])) {
|
||||
if (!isset($lastResponse['id'])) {
|
||||
throw new Error('Response did not contain share id for the created public link');
|
||||
}
|
||||
return $this->getJsonDecodedResponse($lastResponse)['id'];
|
||||
return $lastResponse['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,15 +212,30 @@ trait Sharing {
|
||||
*/
|
||||
public function shareNgGetLastCreatedLinkShareToken(): string {
|
||||
$lastResponse = $this->shareNgGetLastCreatedLinkShare();
|
||||
if (!isset($this->getJsonDecodedResponse($lastResponse)['link']['webUrl'])) {
|
||||
if (!isset($lastResponse['link']['webUrl'])) {
|
||||
throw new Error(
|
||||
'Response did not contain share id '
|
||||
. $this->getJsonDecodedResponse($lastResponse)['link']['webUrl']
|
||||
. $lastResponse['link']['webUrl']
|
||||
. ' for the created public link'
|
||||
);
|
||||
}
|
||||
$last_created_link_webURL = $this->getJsonDecodedResponse($lastResponse)['link']['webUrl'];
|
||||
return substr(strrchr($last_created_link_webURL, "/"), 1);
|
||||
return substr(strrchr($lastResponse['link']['webUrl'], "/"), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $permissionId
|
||||
* @param ResponseInterface $response
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function shareNgUpdatedCreatedLinkShare(string $permissionId, ResponseInterface $response): void {
|
||||
foreach ($this->shareNgCreatedLinkShares as $key => $share) {
|
||||
if ($share['id'] === $permissionId) {
|
||||
$decodedResponse = $this->getJsonDecodedResponse($response);
|
||||
$this->shareNgCreatedLinkShares[$key] = $decodedResponse;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,10 +243,26 @@ trait Sharing {
|
||||
*/
|
||||
public function shareNgGetLastCreatedUserGroupShareID(): string {
|
||||
$lastResponse = $this->shareNgGetLastCreatedUserGroupShare();
|
||||
if (!isset($this->getJsonDecodedResponse($lastResponse)['value'][0]['id'])) {
|
||||
if (!isset($lastResponse['value'][0]['id'])) {
|
||||
throw new Error('Response did not contain share id for the last created share.');
|
||||
}
|
||||
return $this->getJsonDecodedResponse($lastResponse)['value'][0]['id'];
|
||||
return $lastResponse['value'][0]['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $permissionId
|
||||
* @param ResponseInterface $response
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function shareNgUpdateCreatedUserGroupShare(string $permissionId, ResponseInterface $response): void {
|
||||
foreach ($this->shareNgCreatedUserGroupShares as $key => $share) {
|
||||
if ($share['value'][0]['id'] === $permissionId) {
|
||||
$decodedResponse = $this->getJsonDecodedResponse($response);
|
||||
$this->shareNgCreatedUserGroupShares[$key]['value'] = $decodedResponse;
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -101,7 +101,7 @@ class SharingNgContext implements Context {
|
||||
'password' => $this->featureContext->getActualPassword($bodyRows['password'])
|
||||
];
|
||||
|
||||
return GraphHelper::createLinkShare(
|
||||
$response = GraphHelper::createLinkShare(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
@@ -110,6 +110,12 @@ class SharingNgContext implements Context {
|
||||
$itemId,
|
||||
\json_encode($body)
|
||||
);
|
||||
|
||||
if ($response->getStatusCode() == 200) {
|
||||
$this->featureContext->shareNgAddToCreatedLinkShares($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -681,7 +687,7 @@ class SharingNgContext implements Context {
|
||||
? null : $bodyRows['expirationDateTime'];
|
||||
}
|
||||
|
||||
return GraphHelper::updateShare(
|
||||
$response = GraphHelper::updateShare(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
@@ -691,6 +697,12 @@ class SharingNgContext implements Context {
|
||||
\json_encode($body),
|
||||
$permissionID
|
||||
);
|
||||
|
||||
if ($response->getStatusCode() === 200) {
|
||||
$this->featureContext->shareNgUpdateCreatedUserGroupShare($permissionID, $response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -763,7 +775,6 @@ class SharingNgContext implements Context {
|
||||
);
|
||||
$response = $this->createLinkShare($user, $body);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response);
|
||||
$this->featureContext->shareNgAddToCreatedLinkShares($response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -859,7 +870,7 @@ class SharingNgContext implements Context {
|
||||
$body['displayName'] = $bodyRows['displayName'];
|
||||
}
|
||||
|
||||
return GraphHelper::updateShare(
|
||||
$response = GraphHelper::updateShare(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
@@ -869,6 +880,12 @@ class SharingNgContext implements Context {
|
||||
\json_encode($body),
|
||||
$permissionID
|
||||
);
|
||||
|
||||
if ($response->getStatusCode() === 200) {
|
||||
$this->featureContext->shareNgUpdatedCreatedLinkShare($permissionID, $response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -894,7 +911,7 @@ class SharingNgContext implements Context {
|
||||
throw new Error('Password is missing to set for share link!');
|
||||
}
|
||||
|
||||
return GraphHelper::setLinkSharePassword(
|
||||
$response = GraphHelper::setLinkSharePassword(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
@@ -904,6 +921,11 @@ class SharingNgContext implements Context {
|
||||
\json_encode($body),
|
||||
$permissionID
|
||||
);
|
||||
|
||||
if ($response->getStatusCode() === 200) {
|
||||
$this->featureContext->shareNgUpdatedCreatedLinkShare($permissionID, $response);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2666,18 +2666,22 @@ class SpacesContext implements Context {
|
||||
$itemId = $this->getResourceId($user, $spaceName, $resource);
|
||||
$body['expirationDateTime'] = $rows['expireDate'];
|
||||
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
|
||||
$this->featureContext->setResponse(
|
||||
GraphHelper::updateShare(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$space["id"],
|
||||
$itemId,
|
||||
\json_encode($body),
|
||||
$permissionID
|
||||
)
|
||||
$response = GraphHelper::updateShare(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$space["id"],
|
||||
$itemId,
|
||||
\json_encode($body),
|
||||
$permissionID
|
||||
);
|
||||
|
||||
if ($response->getStatusCode() === 200) {
|
||||
$this->featureContext->shareNgAddToCreatedUserGroupShares($response);
|
||||
}
|
||||
$this->featureContext->setResponse($response);
|
||||
|
||||
} else {
|
||||
$rows['permissions'] = (string)$this->featureContext->getLastCreatedUserGroupShare()->permissions;
|
||||
$this->featureContext->setResponse($this->updateSharedResource($user, $rows));
|
||||
|
||||
Reference in new issue
Block a user