Skip to content

Commit

Permalink
Merge pull request #35562 from owncloud/accceptance-tests-for-release…
Browse files Browse the repository at this point in the history
…-10-2-1

Acceptance tests for release 10.2.1
  • Loading branch information
micbar authored Jun 18, 2019
2 parents 597b6e8 + b71b326 commit cf1a31a
Show file tree
Hide file tree
Showing 256 changed files with 6,148 additions and 1,914 deletions.
97 changes: 96 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,17 @@ matrix:
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiAuthOcs
DB_TYPE: mariadb
USE_SERVER: true
SERVER_PROTOCOL: https
INSTALL_SERVER: true
CHOWN_SERVER: true
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiCapabilities
Expand Down Expand Up @@ -893,6 +904,28 @@ matrix:
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiProvisioningGroups-v1
DB_TYPE: mariadb
USE_SERVER: true
SERVER_PROTOCOL: https
INSTALL_SERVER: true
CHOWN_SERVER: true
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiProvisioningGroups-v2
DB_TYPE: mariadb
USE_SERVER: true
SERVER_PROTOCOL: https
INSTALL_SERVER: true
CHOWN_SERVER: true
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiSharees
Expand All @@ -915,6 +948,17 @@ matrix:
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiShareManagementBasic
DB_TYPE: mariadb
USE_SERVER: true
SERVER_PROTOCOL: https
INSTALL_SERVER: true
CHOWN_SERVER: true
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiShareOperations
Expand Down Expand Up @@ -982,6 +1026,17 @@ matrix:
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiWebdavLocks2
DB_TYPE: mariadb
USE_SERVER: true
SERVER_PROTOCOL: https
INSTALL_SERVER: true
CHOWN_SERVER: true
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiWebdavMove
Expand Down Expand Up @@ -1117,7 +1172,7 @@ matrix:
- PHP_VERSION: 7.1
TEST_SUITE: selenium
BROWSER: chrome
BEHAT_SUITE: webUIEncryptionUserKeysType
BEHAT_SUITE: webUIUserKeysType
DB_TYPE: mariadb
USE_SERVER: true
SERVER_PROTOCOL: https
Expand Down Expand Up @@ -1236,6 +1291,18 @@ matrix:
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BROWSER: chrome
BEHAT_SUITE: webUISharingAutocompletion
DB_TYPE: mariadb
USE_SERVER: true
SERVER_PROTOCOL: https
INSTALL_SERVER: true
CHOWN_SERVER: true
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

- PHP_VERSION: 7.1
TEST_SUITE: selenium
BROWSER: chrome
Expand Down Expand Up @@ -1340,6 +1407,20 @@ matrix:
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

# This suite is part of the user_management app in later core versions
- PHP_VERSION: 7.1
TEST_SUITE: selenium
BROWSER: chrome
BEHAT_SUITE: webUIAddUsers
DB_TYPE: mariadb
USE_SERVER: true
SERVER_PROTOCOL: https
INSTALL_SERVER: true
CHOWN_SERVER: true
USE_EMAIL: true
OWNCLOUD_LOG: true
INSTALL_TESTING_APP: true

# This suite is part of the user_management app in later core versions
- PHP_VERSION: 7.1
TEST_SUITE: selenium
Expand Down Expand Up @@ -1526,3 +1607,17 @@ matrix:
CONFIGURE_ENCRYPTION: true
ENCRYPTION_TYPE: masterkey
INSTALL_TESTING_APP: true

## encryption WebUI acceptance tests master-keys encryption
- PHP_VERSION: 7.1
TEST_SUITE: webui
BEHAT_SUITE: webUIMasterKeyType
DB_TYPE: mariadb
USE_SERVER: true
SERVER_PROTOCOL: https
INSTALL_SERVER: true
CHOWN_SERVER: true
OWNCLOUD_LOG: true
CONFIGURE_ENCRYPTION: true
ENCRYPTION_TYPE: masterkey
INSTALL_TESTING_APP: true
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ TEST_DATABASE=sqlite
TEST_EXTERNAL_ENV=smb-silvershell
TEST_PHP_SUITE=

# Acceptance test flags (for shells supporting autocompletion of makefiles, eg: zsh)
TEST_SERVER_URL?=
TEST_SERVER_FED_URL?=
TEST_EXTERNAL_USER_BACKENDS?=
BEHAT_FEATURE?=
NORERUN?=
BEHAT_RERUN_TIMES?=

RELEASE_CHANNEL=git

# internal aliases
Expand Down
99 changes: 87 additions & 12 deletions tests/TestHelpers/HttpRequestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
use SimpleXMLElement;
use Sabre\Xml\LibXMLException;
use Sabre\Xml\Reader;
use GuzzleHttp\BatchResults;
use GuzzleHttp\Pool;

/**
* Helper for HTTP requests
Expand Down Expand Up @@ -68,6 +70,90 @@ public static function sendRequest(
if ($client === null) {
$client = new Client();
}
$request = self::createRequest(
$url,
$method,
$user,
$password,
$headers,
$body,
$config,
$cookies,
$stream,
$timeout,
$client
);

try {
$response = $client->send($request);
} catch (BadResponseException $ex) {
$response = $ex->getResponse();

//if the response was null for some reason do not return it but re-throw
if ($response === null) {
throw $ex;
}
}
return $response;
}

/**
* Send the requests to the server in parallel.
* This function takes an array of requests and an optional client.
* It will send all the requests to the server using the Pool object in guzzle.
*
* @param array $requests
* @param Client|null $client
*
* @return BatchResults
*/
public static function sendBatchRequest(
$requests,
$client = null
) {
if (!isset($client)) {
$client = new Client();
}
$results = Pool::batch($client, $requests);
return $results;
}

/**
* Create an http request based on given parameters.
* This creates an RequestInterface object before sending it to the server.
* This also enables to create multiple requests in advance so that we can send them to the server at once in parallel.
*
* @param string $url
* @param string $method
* @param string $user
* @param string $password
* @param array $headers ['X-MyHeader' => 'value']
* @param mixed $body
* @param array $config
* @param CookieJar $cookies
* @param bool $stream Set to true to stream a response rather
* than download it all up-front.
* @param int $timeout
* @param Client|null $client
*
* @return RequestInterface
*/
public static function createRequest(
$url,
$method = 'GET',
$user = null,
$password = null,
$headers = null,
$body = null,
$config = null,
$cookies = null,
$stream = false,
$timeout = 0,
$client = null
) {
if ($client === null) {
$client = new Client();
}

$options = [];
if ($user !== null) {
Expand Down Expand Up @@ -95,18 +181,7 @@ public static function sendRequest(
}
}
}

try {
$response = $client->send($request);
} catch (BadResponseException $ex) {
$response = $ex->getResponse();

//if the response was null for some reason do not return it but re-throw
if ($response === null) {
throw $ex;
}
}
return $response;
return $request;
}

/**
Expand Down
40 changes: 40 additions & 0 deletions tests/TestHelpers/OcsApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
*/
namespace TestHelpers;

use GuzzleHttp\BatchResults;
use GuzzleHttp\Message\ResponseInterface;
use GuzzleHttp\Client;
use GuzzleHttp\Pool;

/**
* Helper to make requests to the OCS API
Expand Down Expand Up @@ -53,4 +56,41 @@ public static function sendRequest(

return HttpRequestHelper::sendRequest($fullUrl, $method, $user, $password, $headers, $body);
}

/**
*
* @param string $baseUrl
* @param string $user if set to null no authentication header will be sent
* @param string $password
* @param string $method HTTP Method
* @param string $path
* @param array $body array of key, value pairs e.g ['value' => 'yes']
* @param Client|null $client
* @param int $ocsApiVersion (1|2) default 2
* @param array $headers
*
* @return RequestInterface
*/
public static function createOcsRequest(
$baseUrl, $user, $password, $method, $path, $body = [], $client = null, $ocsApiVersion = 2, $headers = []
) {
$fullUrl = $baseUrl;
if (\substr($fullUrl, -1) !== '/') {
$fullUrl .= '/';
}
$fullUrl .= "ocs/v{$ocsApiVersion}.php" . $path;
return HttpRequestHelper::createRequest(
$fullUrl,
$method,
$user,
$password,
$headers,
$body,
null,
null,
null,
null,
$client
);
}
}
40 changes: 40 additions & 0 deletions tests/TestHelpers/SetupHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,46 @@ public static function deleteFileOnServer(
}
}

/**
* @param string $fileInCore e.g. 'app2/myapp/appinfo/info.xml'
* @param string|null $baseUrl
* @param string|null $adminUsername
* @param string|null $adminPassword
*
* @return string
* @throws Exception
*/
public static function readFileFromServer(
$fileInCore,
$baseUrl = null,
$adminUsername = null,
$adminPassword = null
) {
$baseUrl = self::checkBaseUrl($baseUrl, "readFile");
$adminUsername = self::checkAdminUsername(
$adminUsername, "readFile"
);
$adminPassword = self::checkAdminPassword(
$adminPassword, "readFile"
);

$response = OcsApiHelper::sendRequest(
$baseUrl,
$adminUsername,
$adminPassword,
'GET',
"/apps/testing/api/v1/file?file={$fileInCore}"
);
self::assertSame(
200,
$response->getStatusCode(),
"Failed to read the file {$fileInCore}"
);
$localContent = HttpRequestHelper::getResponseXml($response);
$localContent = (string)$localContent->data->element->contentUrlEncoded;
return \urldecode($localContent);
}

/**
* returns the content of a file in a skeleton folder
*
Expand Down
Loading

0 comments on commit cf1a31a

Please sign in to comment.