Skip to content
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] use spaces dav path in apiAuth suite #39712

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ public static function getPersonalSpaceIdForUser(string $baseUrl, string $user,
if (\array_key_exists($user, self::$spacesIdRef) && \array_key_exists("personal", self::$spacesIdRef[$user])) {
return self::$spacesIdRef[$user]["personal"];
}
$drivesPath = 'graph/v1.0/me/drives';
$fullUrl = $baseUrl . $drivesPath;
$drivesPath = '/graph/v1.0/me/drives';
$fullUrl = \trim($baseUrl, "/") . $drivesPath;
$response = HttpRequestHelper::get(
$fullUrl,
$xRequestId,
Expand Down
17 changes: 15 additions & 2 deletions tests/acceptance/features/apiAuth/webDavAuth.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ Feature: auth
When a user requests "/remote.php/webdav" with "PROPFIND" and no authentication
kiranparajuli589 marked this conversation as resolved.
Show resolved Hide resolved
Then the HTTP status code should be "401"

@smokeTest @skipOnOcV10 @personalSpace
Scenario: using spaces WebDAV anonymously
When user "Alice" requests "/dav/spaces/%spaceid%" with "PROPFIND" and no authentication
Then the HTTP status code should be "401"

@smokeTest
Scenario: using WebDAV with basic auth
When user "Alice" requests "/remote.php/webdav" with "PROPFIND" using basic auth
Scenario Outline: using WebDAV with basic auth
When user "Alice" requests "<dav_path>" with "PROPFIND" using basic auth
Then the HTTP status code should be "207"
Examples:
| dav_path |
| /remote.php/webdav |

@skipOnOcV10 @personalSpace
Examples:
| dav_path |
| /dav/spaces/%spaceid% |

@smokeTest @notToImplementOnOCIS @issue-ocis-reva-28
Scenario: using WebDAV with token auth
Expand Down
16 changes: 16 additions & 0 deletions tests/acceptance/features/bootstrap/AuthContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ public function userRequestsURLWith(string $url, string $method):void {
$this->sendRequest($url, $method);
}

/**
* @When user :user requests :url with :method and no authentication
kiranparajuli589 marked this conversation as resolved.
Show resolved Hide resolved
*
* @param string $user
* @param string $url
* @param string $method
*
* @return void
* @throws JsonException
*/
public function userRequestsURLWithNoAuth(string $user, string $url, string $method):void {
$userRenamed = $this->featureContext->getActualUsername($user);
$url = $this->featureContext->substituteInLineCodes($url, $userRenamed);
$this->sendRequest($url, $method);
}

/**
* @Given a user has requested :url with :method and no authentication
*
Expand Down
25 changes: 25 additions & 0 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3090,6 +3090,14 @@ public function substituteInLineCodes(
"getEmailAddressForUser"
],
"parameter" => [$user]
],
[
"code" => "%spaceid%",
"function" => [
$this,
"getPersonalSpaceIdForUser",
],
"parameter" => [$user]
]
);
}
Expand Down Expand Up @@ -3122,6 +3130,23 @@ public function substituteInLineCodes(
return $value;
}

/**
* returns personal space id for user
*
* @param string $user
*
* @return string
* @throws GuzzleException
*/
public function getPersonalSpaceIdForUser(string $user):string {
return WebDavHelper::getPersonalSpaceIdForUser(
$this->getBaseUrl(),
$user,
$this->getPasswordForUser($user),
$this->getStepLineRef()
);
}

/**
* @return string
*/
Expand Down