Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b3296f6
test(WebDav): add reusable DAV client helpers + standardize error han…
joshtrichards Apr 11, 2026
4824ecc
test(WebDAV): create central Guzzle client helper
joshtrichards Apr 11, 2026
ba8d6a0
test(WebDav): fixup typo
joshtrichards Apr 11, 2026
3b2a383
test(WebDav): fixup another typo
joshtrichards Apr 11, 2026
5bafd37
test(integration): refactor FilesDropContext to use new DAV helpers
joshtrichards Apr 11, 2026
461deb9
test(FilesDropContext): fix typo
joshtrichards Apr 11, 2026
a61cefc
test(FilesDropContext): fix typo
joshtrichards Apr 11, 2026
abdbd39
test(WebDav): make cs happy
joshtrichards Apr 11, 2026
19c8786
test(FilesDropContext): fixup for cs
joshtrichards Apr 12, 2026
a97c8d2
test(provisioning-v1.feature): fix broken (typod URL) subadmin scenario
joshtrichards Apr 12, 2026
670352f
test(integration): refactor BasicStructure to use new Guzzle helpers
joshtrichards Apr 12, 2026
bed0c32
test(integration): refactor CollaborationContext to use new Guzzle he…
joshtrichards Apr 12, 2026
31a6fba
test(integraiton): drop boilerplate from FilesRemindersContext
joshtrichards Apr 12, 2026
2a5d859
test(integration): refactor Auth to use new Guzzle helpers
joshtrichards Apr 12, 2026
1ea3e3e
test(integration): fixup Auth
joshtrichards Apr 12, 2026
d059fd1
test(integration): fixup BasicStructure
joshtrichards Apr 12, 2026
c1d7164
test(integration): drop var_dump from WebDav
joshtrichards Apr 12, 2026
9cc4f37
test(integration): refactor/align property typing in Sharing
joshtrichards Apr 12, 2026
a7f4dda
test(integration): refactor Provisioning to use helpers / streamline
joshtrichards Apr 12, 2026
ce2db7c
test(integration): align/modernize property typing in BasicStructure
joshtrichards Apr 12, 2026
b961911
test(integration): add inline typing to Mail properties
joshtrichards Apr 12, 2026
ae844c7
test(integration): align WebDav response property typing
joshtrichards Apr 12, 2026
8f18137
test(integration): fixup WebDav typo
joshtrichards Apr 12, 2026
75cdc06
test(integration): align/modernize AppConfiguration properties
joshtrichards Apr 12, 2026
86cac23
test(integration): fixup typing alignment in BasicStructure
joshtrichards Apr 12, 2026
ad4ccc2
test(integration): add "anonymous" user support to auth helper
joshtrichards Apr 12, 2026
a12b7cc
test(integration): fixup typos in CollaborationContext
joshtrichards Apr 12, 2026
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
6 changes: 2 additions & 4 deletions build/integration/features/bootstrap/AppConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
require __DIR__ . '/autoload.php';

trait AppConfiguration {
/** @var string */
private $currentUser = '';

/** @var ResponseInterface */
private $response = null;
private string $currentUser = '';
private ?ResponseInterface $response = null;

abstract public function sendingTo(string $verb, string $url);
abstract public function sendingToWith(string $verb, string $url, ?TableNode $body);
Expand Down
129 changes: 42 additions & 87 deletions build/integration/features/bootstrap/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,20 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use GuzzleHttp\Client;
use GuzzleHttp\Client as GClient;
use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ServerException;

require __DIR__ . '/autoload.php';

trait Auth {
/** @var string */
private $unrestrictedClientToken;
/** @var string */
private $restrictedClientToken;
/** @var Client */
private $client;
/** @var string */
private $responseXml;
private ?string $unrestrictedClientToken;
private ?string $restrictedClientToken;
private ?GClient $client;
private ?string $responseXml;

/** @BeforeScenario */
public function setUpScenario() {
$this->client = new Client();
$this->client = $this->getGuzzleClient(null);
$this->responseXml = '';
$this->cookieJar = new CookieJar();
}
Expand All @@ -38,27 +32,15 @@ public function requestingWith($url, $method) {

private function sendRequest($url, $method, $authHeader = null, $useCookies = false) {
$fullUrl = substr($this->baseUrl, 0, -5) . $url;
try {
if ($useCookies) {
$options = [
'cookies' => $this->cookieJar,
];
} else {
$options = [];
}
if ($authHeader) {
$options['headers'] = [
'Authorization' => $authHeader
];
}
$options['headers']['OCS_APIREQUEST'] = 'true';
$options['headers']['requesttoken'] = $this->requestToken;
$this->response = $this->client->request($method, $fullUrl, $options);
} catch (ClientException $ex) {
$this->response = $ex->getResponse();
} catch (ServerException $ex) {
$this->response = $ex->getResponse();
if ($useCookies) {
$options['cookies'] = $this->cookieJar;
}
if ($authHeader) {
$options['headers'] = [ 'Authorization' => $authHeader ];
}
$options['headers']['OCS_APIREQUEST'] = 'true';
$options['headers']['requesttoken'] = $this->requestToken;
$this->response = $this->client->request($method, $fullUrl, $options);
}

/**
Expand All @@ -69,33 +51,18 @@ public function theCsrfTokenIsExtractedFromThePreviousResponse() {
}

/**
* @param bool $loginViaWeb
* @return object
*/
private function createClientToken($loginViaWeb = true) {
private function createClientToken(bool $loginViaWeb = true) {
if ($loginViaWeb) {
$this->loggingInUsingWebAs('user0');
}

$fullUrl = substr($this->baseUrl, 0, -5) . '/index.php/settings/personal/authtokens';
$client = new Client();
$options = [
'auth' => [
'user0',
$loginViaWeb ? '123456' : $this->restrictedClientToken,
],
'form_params' => [
'requesttoken' => $this->requestToken,
'name' => md5(microtime()),
],
'cookies' => $this->cookieJar,
];

try {
$this->response = $client->request('POST', $fullUrl, $options);
} catch (\GuzzleHttp\Exception\ServerException $e) {
$this->response = $e->getResponse();
}
$client = $this->getGuzzleClient(null);
$options['auth'] = [ 'user0', $loginViaWeb ? '123456' : $this->restrictedClientToken ];
$options['form_params'] = [ 'requesttoken' => $this->requestToken, 'name' => md5(microtime()) ];
$options['cookies'] = $this->cookieJar;
$this->response = $client->request('POST', $fullUrl, $options);
return json_decode($this->response->getBody()->getContents());
}

Expand All @@ -106,20 +73,14 @@ public function aNewRestrictedClientTokenIsAdded() {
$tokenObj = $this->createClientToken();
$newCreatedTokenId = $tokenObj->deviceToken->id;
$fullUrl = substr($this->baseUrl, 0, -5) . '/index.php/settings/personal/authtokens/' . $newCreatedTokenId;
$client = new Client();
$options = [
'auth' => ['user0', '123456'],
'headers' => [
'requesttoken' => $this->requestToken,
],
'json' => [
'name' => md5(microtime()),
'scope' => [
'filesystem' => false,
],
],
'cookies' => $this->cookieJar,
$client = $this->getGuzzleClient(null);
$options['auth'] = [ 'user0', '123456' ];
$options['headers'] = [ 'requesttoken' => $this->requestToken ];
$options['json'] = [
'name' => md5(microtime()),
'scope' => [ 'filesystem' => false ],
];
$options['cookies'] = $this->cookieJar;
$this->response = $client->request('PUT', $fullUrl, $options);
$this->restrictedClientToken = $tokenObj->token;
}
Expand Down Expand Up @@ -207,29 +168,23 @@ public function aNewBrowserSessionIsStarted($remember = false) {
$baseUrl = substr($this->baseUrl, 0, -5);
$loginUrl = $baseUrl . '/login';
// Request a new session and extract CSRF token
$client = new Client();
$response = $client->get($loginUrl, [
'cookies' => $this->cookieJar,
]);
$this->extracRequestTokenFromResponse($response);
$client = $this->getGuzzleClient(null);
$options['cookies'] = $this->cookieJar;
$response = $client->get($loginUrl, $options);
$this->extractRequestTokenFromResponse($response);

// Login and extract new token
$client = new Client();
$response = $client->post(
$loginUrl, [
'form_params' => [
'user' => 'user0',
'password' => '123456',
'rememberme' => $remember ? '1' : '0',
'requesttoken' => $this->requestToken,
],
'cookies' => $this->cookieJar,
'headers' => [
'Origin' => $baseUrl,
],
]
);
$this->extracRequestTokenFromResponse($response);
$client = $this->getGuzzleClient(null);
$options['form_params'] = [
'user' => 'user0',
'password' => '123456',
'rememberme' => $remember ? '1' : '0',
'requesttoken' => $this->requestToken,
];
$options['cookies'] = $this->cookieJar;
$options['headers'] = [ 'Origin' => $baseUrl ];
$response = $client->post($loginUrl, $options);
$this->extractRequestTokenFromResponse($response);
}

/**
Expand Down
Loading
Loading