-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
218 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@api | ||
Feature: upload file | ||
As a user | ||
I want to be able to upload files when passwords are stored with the full hash difficulty | ||
So that I can store and share files securely between multiple client systems | ||
|
||
Note - this feature is run in CI with ACCOUNTS_HASH_DIFFICULTY set to the default for production | ||
See https://github.com/owncloud/ocis/issues/1542 and https://github.com/owncloud/ocis/pull/839 | ||
|
||
Scenario: list own spaces | ||
Given user "Alice" has been created with default attributes and without skeleton files | ||
And user "Alice" lists all available spaces via the GraphApi | ||
Then the HTTP status code should be "200" | ||
And the webDavUrl of the personal space has been found | ||
And user "Alice" lists the content of the personal spoce root using the WebDav Api | ||
And the HTTP status code should be "207" |
200 changes: 200 additions & 0 deletions
200
tests/acceptance/features/bootstrap/GraphApiContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
<?php | ||
|
||
use Behat\Behat\Context\Context; | ||
use Behat\Behat\Hook\Scope\BeforeScenarioScope; | ||
use TestHelpers\HttpRequestHelper; | ||
use TestHelpers\SetupHelper; | ||
use PHPUnit\Framework\Assert; | ||
|
||
require_once 'bootstrap.php'; | ||
|
||
/** | ||
* Context for Reva specific steps | ||
*/ | ||
class GraphApiContext implements Context { | ||
|
||
/** | ||
* @var FeatureContext | ||
*/ | ||
private $featureContext; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $personalDriveWebDavUrl; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPersonalDriveWebDavUrl(): string | ||
{ | ||
return $this->personalDriveWebDavUrl; | ||
} | ||
|
||
/** | ||
* @param string $personalDriveWebDavUrl | ||
*/ | ||
public function setPersonalDriveWebDavUrl(string $personalDriveWebDavUrl): void | ||
{ | ||
$this->personalDriveWebDavUrl = $personalDriveWebDavUrl; | ||
} | ||
/** | ||
* @BeforeScenario | ||
* | ||
* @param BeforeScenarioScope $scope | ||
* | ||
* @return void | ||
* @throws Exception | ||
*/ | ||
public function setUpScenario(BeforeScenarioScope $scope) { | ||
// Get the environment | ||
$environment = $scope->getEnvironment(); | ||
// Get all the contexts you need in this context | ||
$this->featureContext = $environment->getContext('FeatureContext'); | ||
SetupHelper::init( | ||
$this->featureContext->getAdminUsername(), | ||
$this->featureContext->getAdminPassword(), | ||
$this->featureContext->getBaseUrl(), | ||
$this->featureContext->getOcPath() | ||
); | ||
} | ||
|
||
/** | ||
* Send Graph List Drives Request | ||
* | ||
* @param $baseUrl | ||
* @param $user | ||
* @param $password | ||
* @param $arguments | ||
* @param string $xRequestId | ||
* @param array $body | ||
* @param array $headers | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function listSpacesRequest( | ||
$baseUrl, | ||
$user, | ||
$password, | ||
$arguments, | ||
$xRequestId = '', | ||
$body = [], | ||
$headers = [] | ||
) { | ||
$fullUrl = $baseUrl; | ||
if (\substr($fullUrl, -1) !== '/') { | ||
$fullUrl .= '/'; | ||
} | ||
$fullUrl .= "graph/v1.0/me/drives/" . $arguments; | ||
|
||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'GET', $user, $password, $headers, $body); | ||
} | ||
|
||
/** | ||
* Send Graph List Drives Request | ||
* | ||
* @param $baseUrl | ||
* @param $user | ||
* @param $password | ||
* @param string $spaceName | ||
* @param string $xRequestId | ||
* @param array $headers | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function sendCreateSpaceRequest( | ||
$baseUrl, | ||
$user, | ||
$password, | ||
$spaceName, | ||
$xRequestId = '', | ||
$headers = [] | ||
) { | ||
$fullUrl = $baseUrl; | ||
if (\substr($fullUrl, -1) !== '/') { | ||
$fullUrl .= '/'; | ||
} | ||
$fullUrl .= "drives/" . $spaceName; | ||
|
||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'POST', $user, $password, $headers); | ||
} | ||
|
||
/** | ||
* Send Propfind Request to Url | ||
* | ||
* @param $url | ||
* @param $user | ||
* @param $password | ||
* @param string $spaceName | ||
* @param string $xRequestId | ||
* @param array $headers | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function sendPropfindRequestToUrl( | ||
$fullUrl, | ||
$user, | ||
$password, | ||
$xRequestId = '', | ||
$headers = [] | ||
) { | ||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PROPFIND', $user, $password, $headers); | ||
} | ||
|
||
/** | ||
* @When /^user "([^"]*)" lists all available spaces via the GraphApi$/ | ||
* | ||
* @param $depth | ||
* | ||
* @return void | ||
*/ | ||
public function theUserListsAllHisAvailableSpacesUsingTheGraphApi($user) { | ||
$this->featureContext->setResponse( | ||
$this->listSpacesRequest( | ||
$this->featureContext->getBaseUrl(), | ||
$user, | ||
$this->featureContext->getPasswordForUser($user), | ||
"", | ||
"" | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* @Then the webDavUrl of the personal space has been found | ||
* | ||
* @return void | ||
*/ | ||
public function theWebDavUrlOfThePersonalSpaceHasBeenFound() { | ||
$rawBody = $this->featureContext->getResponse()->getBody()->getContents(); | ||
$drives = \json_decode($rawBody, true)["value"]; | ||
|
||
foreach($drives as $drive) { | ||
if (isset($drive["driveType"]) && $drive["driveType"] === "personal") { | ||
$this->setPersonalDriveWebDavUrl($drive["root"]["webDavUrl"]); | ||
Assert::assertNotEmpty( | ||
$drive["root"]["webDavUrl"], | ||
"The personal space attributes contain no webDavUrl" | ||
); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @When /^user "([^"]*)" lists the content of the personal spoce root using the WebDav Api$/ | ||
* | ||
* @param $user | ||
* | ||
* @return void | ||
*/ | ||
public function theUserListsTheContentOfASpaceRootUsingTheWebDAvApi($user) { | ||
$this->featureContext->setResponse( | ||
$this->sendPropfindRequestToUrl( | ||
$this->getPersonalDriveWebDavUrl(), | ||
$user, | ||
$this->featureContext->getPasswordForUser($user), | ||
"", | ||
[], | ||
[], | ||
[] | ||
) | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.