mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-09 05:39:52 -06:00
tests: error handling
tests: remove unnecessary logs
This commit is contained in:
@@ -1006,11 +1006,9 @@ def localApiTests(ctx, name, suites, storage = "ocis", extra_environment = {}, w
|
||||
expected_failures_file = "%s/expected-failures-localAPI-on-%s-storage.md" % (test_dir, storage.upper())
|
||||
|
||||
environment = {
|
||||
"PATH_TO_OCIS": dirs["base"],
|
||||
"TEST_SERVER_URL": OCIS_URL,
|
||||
"TEST_SERVER_FED_URL": OCIS_FED_URL,
|
||||
"OCIS_REVA_DATA_ROOT": "%s" % (dirs["ocisRevaDataRoot"] if storage == "owncloud" else ""),
|
||||
"OCIS_SKELETON_STRATEGY": "%s" % ("copy" if storage == "owncloud" else "upload"),
|
||||
"SEND_SCENARIO_LINE_REFERENCES": "true",
|
||||
"STORAGE_DRIVER": storage,
|
||||
"BEHAT_SUITES": ",".join(suites),
|
||||
@@ -1206,10 +1204,8 @@ def coreApiTests(ctx, part_number = 1, number_of_parts = 1, with_remote_php = Fa
|
||||
"name": "oC10ApiTests-%s" % part_number,
|
||||
"image": OC_CI_PHP % DEFAULT_PHP_VERSION,
|
||||
"environment": {
|
||||
"PATH_TO_OCIS": "%s" % dirs["base"],
|
||||
"TEST_SERVER_URL": OCIS_URL,
|
||||
"OCIS_REVA_DATA_ROOT": "%s" % (dirs["ocisRevaDataRoot"] if storage == "owncloud" else ""),
|
||||
"OCIS_SKELETON_STRATEGY": "%s" % ("copy" if storage == "owncloud" else "upload"),
|
||||
"SEND_SCENARIO_LINE_REFERENCES": "true",
|
||||
"STORAGE_DRIVER": storage,
|
||||
"BEHAT_FILTER_TAGS": filterTags,
|
||||
|
||||
@@ -42,7 +42,6 @@ class BehatHelper {
|
||||
try {
|
||||
return $environment->getContext($class);
|
||||
} catch (ContextNotFoundException $e) {
|
||||
print_r("[INFO] '$class' context not found. Registering...\n");
|
||||
$context = new $class();
|
||||
$environment->registerContext($context);
|
||||
if (\method_exists($context, 'before')) {
|
||||
|
||||
@@ -25,6 +25,19 @@ namespace TestHelpers;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
/**
|
||||
* Class StorageDriver
|
||||
*
|
||||
* @package TestHelpers
|
||||
*/
|
||||
abstract class StorageDriver {
|
||||
public const OCIS = "OCIS";
|
||||
public const EOS = "EOS";
|
||||
public const OWNCLOUD = "OWNCLOUD";
|
||||
public const S3NG = "S3NG";
|
||||
public const POSIX = "POSIX";
|
||||
}
|
||||
|
||||
/**
|
||||
* Class OcisHelper
|
||||
*
|
||||
@@ -33,6 +46,14 @@ use GuzzleHttp\Exception\GuzzleException;
|
||||
* @package TestHelpers
|
||||
*/
|
||||
class OcisHelper {
|
||||
public const STORAGE_DRIVERS = [
|
||||
StorageDriver::OCIS,
|
||||
StorageDriver::EOS,
|
||||
StorageDriver::OWNCLOUD,
|
||||
StorageDriver::S3NG,
|
||||
StorageDriver::POSIX
|
||||
];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -78,42 +99,52 @@ class OcisHelper {
|
||||
public static function getStorageDriver():string {
|
||||
$storageDriver = (\getenv("STORAGE_DRIVER"));
|
||||
if ($storageDriver === false) {
|
||||
return "OWNCLOUD";
|
||||
return StorageDriver::OWNCLOUD;
|
||||
}
|
||||
$storageDriver = \strtoupper($storageDriver);
|
||||
if ($storageDriver !== "OCIS" && $storageDriver !== "EOS" && $storageDriver !== "OWNCLOUD" && $storageDriver !== "S3NG" && $storageDriver !== "POSIX") {
|
||||
if (!\in_array($storageDriver, self::STORAGE_DRIVERS)) {
|
||||
throw new Exception(
|
||||
"Invalid storage driver. " .
|
||||
"STORAGE_DRIVER must be OCIS|EOS|OWNCLOUD|S3NG|POSIX"
|
||||
"STORAGE_DRIVER must be '" . \join(", ", self::STORAGE_DRIVERS) . "'"
|
||||
);
|
||||
}
|
||||
return $storageDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $user
|
||||
* @param array $users
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function deleteRevaUserData(?string $user = ""):void {
|
||||
public static function deleteRevaUserData(?array $users = []): void {
|
||||
$deleteCmd = self::getDeleteUserDataCommand();
|
||||
if ($deleteCmd === false) {
|
||||
if (self::getStorageDriver() === "OWNCLOUD") {
|
||||
self::recurseRmdir(self::getOcisRevaDataRoot() . $user);
|
||||
}
|
||||
|
||||
if (self::getStorageDriver() === StorageDriver::POSIX) {
|
||||
\exec($deleteCmd);
|
||||
return;
|
||||
}
|
||||
if (self::getStorageDriver() === "EOS") {
|
||||
$deleteCmd = \str_replace(
|
||||
"%s",
|
||||
$user[0] . '/' . $user,
|
||||
$deleteCmd
|
||||
);
|
||||
} else {
|
||||
$deleteCmd = \sprintf($deleteCmd, $user);
|
||||
|
||||
foreach ($users as $user) {
|
||||
if (\is_array($user)) {
|
||||
$user = $user["actualUsername"];
|
||||
}
|
||||
if ($deleteCmd === false) {
|
||||
if (self::getStorageDriver() === StorageDriver::OWNCLOUD) {
|
||||
self::recurseRmdir(self::getOcisRevaDataRoot() . $user);
|
||||
}
|
||||
continue;
|
||||
} elseif (self::getStorageDriver() === StorageDriver::EOS) {
|
||||
$deleteCmd = \str_replace(
|
||||
"%s",
|
||||
$user[0] . '/' . $user,
|
||||
$deleteCmd
|
||||
);
|
||||
} else {
|
||||
$deleteCmd = \sprintf($deleteCmd, $user);
|
||||
}
|
||||
\exec($deleteCmd);
|
||||
}
|
||||
\exec($deleteCmd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,13 +90,6 @@ trait Provisioning {
|
||||
return array_merge($this->createdUsers, $this->createdRemoteUsers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function someUsersHaveBeenCreated():bool {
|
||||
return (\count($this->createdUsers) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -353,7 +346,13 @@ trait Provisioning {
|
||||
|
||||
$ldifFile = __DIR__ . $suiteParameters['ldapInitialUserFilePath'];
|
||||
if (!$this->skipImportLdif) {
|
||||
$this->importLdifFile($ldifFile);
|
||||
try {
|
||||
$this->importLdifFile($ldifFile);
|
||||
} catch (LdapException $err) {
|
||||
if (!\str_contains($err->getMessage(), "Already exists")) {
|
||||
throw $err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,7 +450,17 @@ trait Provisioning {
|
||||
$entry['ownCloudUUID'] = WebDavHelper::generateUUIDv4();
|
||||
}
|
||||
|
||||
$this->ldap->add($newDN, $entry);
|
||||
try {
|
||||
$this->ldap->add($newDN, $entry);
|
||||
} catch (LdapException $e) {
|
||||
if (\str_contains($e->getMessage(), "Already exists")) {
|
||||
$this->ldap->delete(
|
||||
"uid=" . ldap_escape($entry['uid'], "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN,
|
||||
);
|
||||
OcisHelper::deleteRevaUserData([$entry['uid']]);
|
||||
$this->ldap->add($newDN, $entry);
|
||||
}
|
||||
}
|
||||
|
||||
$this->ldapCreatedUsers[] = $setting["userid"];
|
||||
}
|
||||
@@ -482,7 +491,16 @@ trait Provisioning {
|
||||
$entry['ownCloudUUID'] = WebDavHelper::generateUUIDv4();
|
||||
}
|
||||
|
||||
$this->ldap->add($newDN, $entry);
|
||||
try {
|
||||
$this->ldap->add($newDN, $entry);
|
||||
} catch (LdapException $e) {
|
||||
if (\str_contains($e->getMessage(), "Already exists")) {
|
||||
$this->ldap->delete(
|
||||
"cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN,
|
||||
);
|
||||
$this->ldap->add($newDN, $entry);
|
||||
}
|
||||
}
|
||||
$this->ldapCreatedGroups[] = $group;
|
||||
}
|
||||
|
||||
@@ -519,80 +537,6 @@ trait Provisioning {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually add skeleton files for a single user on OCIS and reva systems
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function manuallyAddSkeletonFilesForUser(string $user, string $password):void {
|
||||
$settings = [];
|
||||
$setting["userid"] = $user;
|
||||
$setting["password"] = $password;
|
||||
$settings[] = $setting;
|
||||
$this->manuallyAddSkeletonFiles($settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually add skeleton files on OCIS and reva systems
|
||||
*
|
||||
* @param array $usersAttributes
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function manuallyAddSkeletonFiles(array $usersAttributes):void {
|
||||
if ($this->isEmptySkeleton()) {
|
||||
// The empty skeleton has no files. There is nothing to do so return early.
|
||||
return;
|
||||
}
|
||||
$skeletonDir = \getenv("SKELETON_DIR");
|
||||
$revaRoot = \getenv("OCIS_REVA_DATA_ROOT");
|
||||
$skeletonStrategy = \getenv("OCIS_SKELETON_STRATEGY");
|
||||
if (!$skeletonStrategy) {
|
||||
$skeletonStrategy = 'upload'; //slower, but safer, so make it the default
|
||||
}
|
||||
if ($skeletonStrategy !== 'upload' && $skeletonStrategy !== 'copy') {
|
||||
throw new Exception(
|
||||
'Wrong OCIS_SKELETON_STRATEGY environment variable. ' .
|
||||
'OCIS_SKELETON_STRATEGY has to be set to "upload" or "copy"'
|
||||
);
|
||||
}
|
||||
if (!$skeletonDir) {
|
||||
throw new Exception('Missing SKELETON_DIR environment variable, cannot copy skeleton files for OCIS');
|
||||
}
|
||||
if ($skeletonStrategy === 'copy' && !$revaRoot) {
|
||||
throw new Exception(
|
||||
'OCIS_SKELETON_STRATEGY is set to "copy" ' .
|
||||
'but no "OCIS_REVA_DATA_ROOT" given'
|
||||
);
|
||||
}
|
||||
if ($skeletonStrategy === 'upload') {
|
||||
foreach ($usersAttributes as $userAttributes) {
|
||||
OcisHelper::recurseUpload(
|
||||
$this->getBaseUrl(),
|
||||
$skeletonDir,
|
||||
$userAttributes['userid'],
|
||||
$userAttributes['password'],
|
||||
$this->getStepLineRef()
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($skeletonStrategy === 'copy') {
|
||||
foreach ($usersAttributes as $userAttributes) {
|
||||
$user = $userAttributes['userid'];
|
||||
$dataDir = $revaRoot . "$user/files";
|
||||
if (!\file_exists($dataDir)) {
|
||||
\mkdir($dataDir, 0777, true);
|
||||
}
|
||||
OcisHelper::recurseCopy($skeletonDir, $dataDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates multiple users
|
||||
*
|
||||
@@ -717,56 +661,6 @@ trait Provisioning {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the administrator sends a user creation request for user "([^"]*)" password "([^"]*)" using the provisioning API$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function adminSendsUserCreationRequestUsingTheProvisioningApi(string $user, string $password):void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$password = $this->getActualPassword($password);
|
||||
$email = $user . '@owncloud.com';
|
||||
$bodyTable = new TableNode(
|
||||
[
|
||||
['userid', $user],
|
||||
['password', $password],
|
||||
['username', $user],
|
||||
['email', $email]
|
||||
]
|
||||
);
|
||||
$this->emptyLastHTTPStatusCodesArray();
|
||||
$this->emptyLastOCSStatusCodesArray();
|
||||
$this->ocsContext->sendRequestToOcsEndpoint(
|
||||
$this->getAdminUsername(),
|
||||
"POST",
|
||||
"/cloud/users",
|
||||
$bodyTable
|
||||
);
|
||||
$this->pushToLastStatusCodesArrays();
|
||||
$success = $this->theHTTPStatusCodeWasSuccess();
|
||||
$this->addUserToCreatedUsersList(
|
||||
$user,
|
||||
$password,
|
||||
null,
|
||||
$email,
|
||||
null,
|
||||
$success
|
||||
);
|
||||
if ($success) {
|
||||
OcisHelper::createEOSStorageHome(
|
||||
$this->getBaseUrl(),
|
||||
$user,
|
||||
$password,
|
||||
$this->getStepLineRef()
|
||||
);
|
||||
$this->manuallyAddSkeletonFilesForUser($user, $password);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @param string|null $password
|
||||
@@ -2065,10 +1959,8 @@ trait Provisioning {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function afterScenario():void {
|
||||
if ($this->someUsersHaveBeenCreated()) {
|
||||
foreach ($this->getCreatedUsers() as $user) {
|
||||
OcisHelper::deleteRevaUserData($user["actualUsername"]);
|
||||
}
|
||||
if (OcisHelper::isTestingOnReva()) {
|
||||
OcisHelper::deleteRevaUserData($this->getCreatedUsers());
|
||||
}
|
||||
|
||||
if ($this->isTestingWithLdap()) {
|
||||
@@ -2173,31 +2065,4 @@ trait Provisioning {
|
||||
$actualPassword
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the smallest available skeleton, to "simulate" without skeleton.
|
||||
*
|
||||
* In ownCloud 10 there is always a skeleton directory. If none is specified
|
||||
* then whatever is in core/skeleton is used. That contains different files
|
||||
* and folders depending on the build that is being tested. So for testing
|
||||
* we have "empty" skeleton that is created on-the-fly by the testing app.
|
||||
* That provides a consistent skeleton for test scenarios that specify
|
||||
* "without skeleton files"
|
||||
*
|
||||
* @return string name of the smallest skeleton folder
|
||||
*/
|
||||
private function getSmallestSkeletonDirName(): string {
|
||||
return "empty";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function isEmptySkeleton(): bool {
|
||||
$skeletonDir = \getenv("SKELETON_DIR");
|
||||
if (($skeletonDir !== false) && (\basename($skeletonDir) === $this->getSmallestSkeletonDirName() . "Skeleton")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,6 @@ class PublicWebDavContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicRenamesFileFromTheLastPublicShareUsingThePasswordPasswordAndOldPublicWebdavApi(string $fileName, string $toName, string $password):void {
|
||||
|
||||
$this->featureContext->setResponse(
|
||||
$this->renameFileFromPublicShare($fileName, $toName, $password)
|
||||
);
|
||||
@@ -496,7 +495,6 @@ class PublicWebDavContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicOverwritesFileWithContentUsingWebDavApi(string $filename, string $body):void {
|
||||
|
||||
$response = $this->publicUploadContent($filename, '', $body);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -544,7 +542,6 @@ class PublicWebDavContext implements Context {
|
||||
string $password,
|
||||
string $expectedContent
|
||||
):void {
|
||||
|
||||
$response = $this->downloadPublicFileWithRange(
|
||||
"",
|
||||
$password
|
||||
@@ -617,7 +614,6 @@ class PublicWebDavContext implements Context {
|
||||
string $password,
|
||||
string $content
|
||||
):void {
|
||||
|
||||
$response = $this->downloadFileFromPublicFolder(
|
||||
$path,
|
||||
$password,
|
||||
|
||||
@@ -7,20 +7,15 @@ git config --global advice.detachedHead false
|
||||
|
||||
## CONFIGURE TEST
|
||||
|
||||
if [ "$TEST_SOURCE" = "oc10" ]
|
||||
then
|
||||
if [ "$TEST_SOURCE" = "oc10" ]; then
|
||||
export ACCEPTANCE_TEST_TYPE='core-api'
|
||||
if [ "$STORAGE_DRIVER" = "ocis" ]
|
||||
then
|
||||
if [ "$STORAGE_DRIVER" = "ocis" ]; then
|
||||
export OCIS_REVA_DATA_ROOT=''
|
||||
export BEHAT_FILTER_TAGS='~@skipOnOcis-OCIS-Storage'
|
||||
export OCIS_SKELETON_STRATEGY='upload'
|
||||
export EXPECTED_FAILURES_FILE='/drone/src/tests/acceptance/expected-failures-API-on-OCIS-storage.md'
|
||||
elif [ "$STORAGE_DRIVER" = "s3ng" ]
|
||||
then
|
||||
elif [ "$STORAGE_DRIVER" = "s3ng" ]; then
|
||||
export BEHAT_FILTER_TAGS='~@skip&&~@skipOnOcis-S3NG-Storage'
|
||||
export OCIS_REVA_DATA_ROOT=''
|
||||
export OCIS_SKELETON_STRATEGY='upload'
|
||||
else
|
||||
echo "non existing STORAGE selected"
|
||||
exit 1
|
||||
@@ -28,19 +23,13 @@ then
|
||||
|
||||
unset BEHAT_SUITE
|
||||
|
||||
elif [ "$TEST_SOURCE" = "ocis" ]
|
||||
then
|
||||
|
||||
if [ "$STORAGE_DRIVER" = "ocis" ]
|
||||
then
|
||||
elif [ "$TEST_SOURCE" = "ocis" ]; then
|
||||
if [ "$STORAGE_DRIVER" = "ocis" ]; then
|
||||
export BEHAT_FILTER_TAGS='~@skip&&~@skipOnOcis-OCIS-Storage'
|
||||
export OCIS_REVA_DATA_ROOT=''
|
||||
export OCIS_SKELETON_STRATEGY='upload'
|
||||
elif [ "$STORAGE_DRIVER" = "s3ng" ]
|
||||
then
|
||||
elif [ "$STORAGE_DRIVER" = "s3ng" ]; then
|
||||
export BEHAT_FILTER_TAGS='~@skip&&~@skipOnOcis-S3NG-Storage'
|
||||
export OCIS_REVA_DATA_ROOT=''
|
||||
export OCIS_SKELETON_STRATEGY='upload'
|
||||
else
|
||||
echo "non existing storage selected"
|
||||
exit 1
|
||||
@@ -53,8 +42,7 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -z "$BEHAT_FEATURE" ]
|
||||
then
|
||||
if [ ! -z "$BEHAT_FEATURE" ]; then
|
||||
echo "feature selected: " + $BEHAT_FEATURE
|
||||
# allow running without filters if its a feature
|
||||
|
||||
@@ -68,8 +56,7 @@ fi
|
||||
|
||||
## RUN TEST
|
||||
|
||||
if [[ -z "$TEST_SOURCE" ]]
|
||||
then
|
||||
if [[ -z "$TEST_SOURCE" ]]; then
|
||||
echo "non existing TEST_SOURCE selected"
|
||||
exit 1
|
||||
else
|
||||
|
||||
@@ -178,7 +178,7 @@ Feature: files and folders exist in the trashbin after being deleted
|
||||
| new |
|
||||
| spaces |
|
||||
|
||||
@issue-3561
|
||||
@issue-3561 @skipOnReva
|
||||
Scenario Outline: listing other user's trashbin is prohibited for newly recreated user with same name
|
||||
Given using <dav-path-version> DAV path
|
||||
And user "testtrashbin102" has been created with default attributes and without skeleton files
|
||||
|
||||
Reference in New Issue
Block a user