Skip to content

Commit

Permalink
Merge pull request #5280 from owncloud/remove-ownCloud-core-test-depe…
Browse files Browse the repository at this point in the history
…ndency

[tests-only][full-ci] copy test dependencies from the ownCloud/core
  • Loading branch information
phil-davis authored Jan 5, 2023
2 parents b84f1f2 + 86814f7 commit c067409
Show file tree
Hide file tree
Showing 247 changed files with 76,731 additions and 1,095 deletions.
2 changes: 1 addition & 1 deletion .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ exclude_paths:
- 'tests/acceptance/expected-failures-*.md'
- 'tests/acceptance/features/bootstrap/**'
- 'tests/TestHelpers/**'

- 'tests/acceptance/run.sh'
...
4 changes: 0 additions & 4 deletions .drone.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# The test runner source for API tests
CORE_COMMITID=3d6c0aafd7710bee6a115c27742a7939b622079e
CORE_BRANCH=master

# The test runner source for UI tests
WEB_COMMITID=f2b928be7e6ce85265868660049a4ff15caa74bc
WEB_BRANCH=master
427 changes: 3 additions & 424 deletions .drone.star

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ help:
@echo -e "${GREEN}Testing with test suite natively installed:${RESET}\n"
@echo -e "${PURPLE}\tdocs: https://owncloud.dev/ocis/development/testing/#testing-with-test-suite-natively-installed${RESET}\n"
@echo -e "\tmake test-acceptance-api\t\t${BLUE}run API acceptance tests${RESET}"
@echo -e "\tmake test-acceptance-core-api\t\t${BLUE}run core API acceptance tests${RESET}"
@echo -e "\tmake test-paralleldeployment-api\t${BLUE}run API acceptance tests for parallel deployment${RESET}"
@echo -e "\tmake clean-tests\t\t\t${BLUE}delete API tests framework dependencies${RESET}"
@echo
Expand Down Expand Up @@ -103,14 +104,20 @@ clean-tests:
BEHAT_BIN=vendor-bin/behat/vendor/bin/behat
# behat config file for parallel deployment tests
PARALLEL_BEHAT_YML=tests/parallelDeployAcceptance/config/behat.yml
# behat config file for core api tests
CORE_BEHAT_YML=tests/acceptance/config/behat-core.yml

.PHONY: test-acceptance-api
test-acceptance-api: vendor-bin/behat/vendor
BEHAT_BIN=$(BEHAT_BIN) $(PATH_TO_CORE)/tests/acceptance/run.sh --remote --type api
BEHAT_BIN=$(BEHAT_BIN) $(PWD)/tests/acceptance/run.sh --type api

.PHONY: test-acceptance-core-api
test-acceptance-core-api: vendor-bin/behat/vendor
BEHAT_BIN=$(BEHAT_BIN) BEHAT_YML=$(CORE_BEHAT_YML) $(PWD)/tests/acceptance/run.sh --type core-api

.PHONY: test-paralleldeployment-api
test-paralleldeployment-api: vendor-bin/behat/vendor
BEHAT_BIN=$(BEHAT_BIN) BEHAT_YML=$(PARALLEL_BEHAT_YML) $(PATH_TO_CORE)/tests/acceptance/run.sh --type api
BEHAT_BIN=$(BEHAT_BIN) BEHAT_YML=$(PARALLEL_BEHAT_YML) $(PWD)/tests/acceptance/run.sh --type api

vendor/bamarni/composer-bin-plugin: composer.lock
composer install
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
"bamarni/composer-bin-plugin": true
}
},
"require": {
},
"require-dev": {
"ext-simplexml": "*",
"bamarni/composer-bin-plugin": "^1.4"
},
"extra": {
Expand Down
200 changes: 200 additions & 0 deletions tests/TestHelpers/Asserts/WebDav.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
<?php declare(strict_types=1);
/**
* ownCloud
*
* @author Artur Neumann <[email protected]>
* @copyright Copyright (c) 2018 Artur Neumann [email protected]
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License,
* as published by the Free Software Foundation;
* either version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace TestHelpers\Asserts;

use Exception;
use SimpleXMLElement;
use TestHelpers\DownloadHelper;
use TestHelpers\SetupHelper;

/**
* WebDAV related asserts
*/
class WebDav extends \PHPUnit\Framework\Assert {
/**
*
* @param string|null $element exception|message|reason
* @param string|null $expectedValue
* @param array|null $responseXml
* @param string|null $extraErrorText
*
* @return void
*/
public static function assertDavResponseElementIs(
?string $element,
?string $expectedValue,
?array $responseXml,
?string $extraErrorText = ''
):void {
if ($extraErrorText !== '') {
$extraErrorText = $extraErrorText . " ";
}
self::assertArrayHasKey(
'value',
$responseXml,
$extraErrorText . "responseXml does not have key 'value'"
);
if ($element === "exception") {
$result = $responseXml['value'][0]['value'];
} elseif ($element === "message") {
$result = $responseXml['value'][1]['value'];
} elseif ($element === "reason") {
$result = $responseXml['value'][3]['value'];
}

self::assertEquals(
$expectedValue,
$result,
__METHOD__ . " " . $extraErrorText . "Expected '$expectedValue' in element $element got '$result'"
);
}

/**
*
* @param SimpleXMLElement $responseXmlObject
* @param array|null $expectedShareTypes
*
* @return void
*/
public static function assertResponseContainsShareTypes(
SimpleXMLElement $responseXmlObject,
?array $expectedShareTypes
):void {
foreach ($expectedShareTypes as $row) {
$xmlPart = $responseXmlObject->xpath(
"//d:prop/oc:share-types/oc:share-type[.=" . $row[0] . "]"
);
self::assertNotEmpty(
$xmlPart,
"cannot find share-type '" . $row[0] . "'"
);
}
}

/**
* Asserts that the content of a remote and a local file is the same
* or is different
*
* @param string|null $baseUrl
* @param string|null $username
* @param string|null $password
* @param string|null $remoteFile
* @param string|null $localFile
* @param string|null $xRequestId
* @param bool $shouldBeSame (default true) if true then check that the file contents are the same
* otherwise check that the file contents are different
*
* @return void
*/
public static function assertContentOfRemoteAndLocalFileIsSame(
?string $baseUrl,
?string $username,
?string $password,
?string $remoteFile,
?string $localFile,
?string $xRequestId = '',
?bool $shouldBeSame = true
):void {
$result = DownloadHelper::download(
$baseUrl,
$username,
$password,
$remoteFile,
$xRequestId
);

$localContent = \file_get_contents($localFile);
$downloadedContent = $result->getBody()->getContents();

if ($shouldBeSame) {
self::assertSame(
$localContent,
$downloadedContent
);
} else {
self::assertNotSame(
$localContent,
$downloadedContent
);
}
}

/**
* Asserts that the content of a remote file (downloaded by DAV)
* and a file in the skeleton folder of the system under test is the same
* or is different
*
* @param string|null $baseUrl
* @param string|null $username
* @param string|null $password
* @param string|null $adminUsername
* @param string|null $adminPassword
* @param string|null $remoteFile
* @param string|null $fileInSkeletonFolder
* @param string|null $xRequestId
* @param bool $shouldBeSame (default true) if true then check that the file contents are the same
* otherwise check that the file contents are different
*
* @return void
* @throws Exception
*/
public static function assertContentOfDAVFileAndSkeletonFileOnSUT(
?string $baseUrl,
?string $username,
?string $password,
?string $adminUsername,
?string $adminPassword,
?string $remoteFile,
?string $fileInSkeletonFolder,
?string $xRequestId = '',
?bool $shouldBeSame = true
):void {
$result = DownloadHelper::download(
$baseUrl,
$username,
$password,
$remoteFile,
$xRequestId
);
$downloadedContent = $result->getBody()->getContents();

$localContent = SetupHelper::readSkeletonFile(
$fileInSkeletonFolder,
$xRequestId,
$baseUrl,
$adminUsername,
$adminPassword
);

if ($shouldBeSame) {
self::assertSame(
$localContent,
$downloadedContent
);
} else {
self::assertNotSame(
$localContent,
$downloadedContent
);
}
}
}
Loading

0 comments on commit c067409

Please sign in to comment.