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] Acceptance test changes pending for master #39514

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
07ed350
Improve checks in tests for disabling a user
phil-davis Nov 22, 2021
3e2e8df
Reduce use of range download in acceptance tests
phil-davis Nov 22, 2021
9a61739
Fix SetupHelper runOcc to use strings only in exception messages
phil-davis Nov 25, 2021
03c840f
Add tests to demonstrate group names with leading and trailing spaces
phil-davis Nov 25, 2021
8d0377d
Adjust group tests for issue-39533
phil-davis Nov 26, 2021
c152987
Refactor getGroups tests to not depend on the starting groups
phil-davis Nov 26, 2021
5905554
Fix missing HTTP status code in createPublicLinkShare test scenarios
phil-davis Nov 26, 2021
d2c9f69
Use when step for the test scenario with only Then.
kiranparajuli589 Dec 3, 2021
ee2b770
[tests-only]Fixed order dependent flaky test detected in files_classi…
Talank Dec 3, 2021
fcec0eb
add tests for db-convert occ command
saw-jan Oct 22, 2021
2987544
Do not allow white space at the start or end of a group name
phil-davis Nov 25, 2021
38ee68e
Add bug demonstration test for sending PUT request to other user's we…
SwikritiT Dec 15, 2021
4092397
refactor test helpers and contexts for parallel deployment tests
saw-jan Dec 15, 2021
112f2f2
Add spaces as a new webdav url type
kiranparajuli589 Dec 15, 2021
7a450af
skipOnEncryption dbConversion.feature as it needs special CI setup
phil-davis Dec 19, 2021
cf3e5a3
added tests for files_external occ command
sakshamgurung Nov 19, 2021
62511ca
Merge pull request #39599 from owncloud/space-as-new-webdav
phil-davis Dec 20, 2021
6080353
Add extra checks to getPersonalSpaceIdForUser
phil-davis Dec 21, 2021
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
22 changes: 21 additions & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ config = {
"chmod -R 0770 data/owncloud-keys",
],
},
"cliDbConversion": {
"suites": [
"cliDbConversion",
],
"databases": [
"sqlite",
],
"dbServices": [
"sqlite",
"mysql:8.0",
"postgres:10.3",
],
},
"cliExternalStorage": {
"suites": [
"cliExternalStorage",
Expand Down Expand Up @@ -1518,6 +1531,7 @@ def acceptance(ctx):
"coreTarball": "daily-master-qa",
"earlyFail": True,
"selUserNeeded": False,
"dbServices": [],
}

if "defaults" in config:
Expand Down Expand Up @@ -1676,6 +1690,12 @@ def acceptance(ctx):

federationDbSuffix = "fed"

# database services
dbServices = databaseService(db)
for dbService in params["dbServices"]:
if (dbService != db):
dbServices += databaseService(dbService)

result = {
"kind": "pipeline",
"type": "docker",
Expand Down Expand Up @@ -1722,7 +1742,7 @@ def acceptance(ctx):
}],
}),
] + buildGithubCommentForBuildStopped(name, params["earlyFail"]) + githubComment(params["earlyFail"]) + stopBuild(params["earlyFail"]),
"services": databaseService(db) +
"services": dbServices +
browserService(browser) +
emailService(params["emailNeeded"]) +
ldapService(params["ldapNeeded"]) +
Expand Down
4 changes: 4 additions & 0 deletions apps/provisioning_api/lib/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ public function addGroup($parameters) {
\OCP\Util::writeLog('provisioning_api', 'Group name not supplied', \OCP\Util::ERROR);
return new OC_OCS_Result(null, 101, 'Invalid group name');
}
if (\trim($groupId) !== $groupId) {
\OCP\Util::writeLog('provisioning_api', 'Group name must not start or end with white space', \OCP\Util::ERROR);
return new OC_OCS_Result(null, 101, 'Invalid group name');
}
// Check if it exists
if ($this->groupManager->groupExists($groupId)) {
return new OC_OCS_Result(null, 102);
Expand Down
19 changes: 17 additions & 2 deletions apps/provisioning_api/tests/GroupsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,26 @@ public function testGetSubAdminsOfGroupEmptyList() {
$this->assertEquals([], $result->getData());
}

public function testAddGroupEmptyGroup() {
public function dataAddGroupWithInvalidName() {
return [
[''],
[' '],
[' white-space-at-start'],
['white-space-at-end '],
[' white-space-at-both-ends '],
];
}

/**
* @dataProvider dataAddGroupWithInvalidName
*
* @param string $groupName
*/
public function testAddGroupWithInvalidName($groupName) {
$this->request
->method('getParam')
->with('groupid')
->willReturn('');
->willReturn($groupName);

$result = $this->api->addGroup([]);

Expand Down
3 changes: 3 additions & 0 deletions changelog/unreleased/39540
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Prevent group names starting or ending with white space

https://github.com/owncloud/core/pull/39540
2 changes: 1 addition & 1 deletion lib/private/Group/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function groupExists($gid) {
* @return \OC\Group\Group
*/
public function createGroup($gid) {
if ($gid === '' || $gid === null) {
if ($gid === '' || $gid === null || \trim($gid) !== $gid) {
return false;
} elseif ($group = $this->get($gid)) {
return $group;
Expand Down
38 changes: 38 additions & 0 deletions tests/TestHelpers/HttpRequestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@
* Helper for HTTP requests
*/
class HttpRequestHelper {

/**
* @var string
*/
private static $oCSelectorCookie = null;

/**
* @return string
*/
public static function getOCSelectorCookie(): string {
return self::$oCSelectorCookie;
}

/**
* @param string $oCSelectorCookie "owncloud-selector=oc10;path=/;"
*
* @return void
*/
public static function setOCSelectorCookie(string $oCSelectorCookie): void {
self::$oCSelectorCookie = $oCSelectorCookie;
}

/**
*
* @param string|null $url
Expand Down Expand Up @@ -296,6 +318,22 @@ public static function createRequest(
$body = \http_build_query($body, '', '&');
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
}

if (OcisHelper::isTestingParallelDeployment()) {
// oCIS cannot handle '/apps/testing' endpoints
// so those requests must be redirected to oC10 server
// change server to oC10 if the request url has `/apps/testing`
if (strpos($url, "/apps/testing") !== false) {
$oCISServerUrl = \getenv('TEST_SERVER_URL');
$oC10ServerUrl = \getenv('TEST_OC10_URL');

$url = str_replace($oCISServerUrl, $oC10ServerUrl, $url);
} else {
// set 'owncloud-server' selector cookie for oCIS requests
$headers['Cookie'] = self::getOCSelectorCookie();
}
}

$request = new Request(
$method,
$url,
Expand Down
7 changes: 7 additions & 0 deletions tests/TestHelpers/OcisHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public static function isTestingOnOc10():bool {
return (!self::isTestingOnOcisOrReva());
}

/**
* @return bool
*/
public static function isTestingParallelDeployment(): bool {
return (\getenv("TEST_PARALLEL_DEPLOYMENT") === "true");
}

/**
* @return bool|string false if no command given or the command as string
*/
Expand Down
19 changes: 10 additions & 9 deletions tests/TestHelpers/SetupHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ public static function runOcc(
?string $ocPath = null,
?array $envVariables = null
):array {
if (OcisHelper::isTestingOnOcisOrReva()) {
if (OcisHelper::isTestingOnOcisOrReva() && !OcisHelper::isTestingParallelDeployment()) {
return ['code' => '', 'stdOut' => '', 'stdErr' => '' ];
}
$baseUrl = self::checkBaseUrl($baseUrl, "runOcc");
Expand All @@ -885,7 +885,8 @@ public static function runOcc(
}

$body = [];
$body['command'] = \implode(' ', $args);
$argsString = \implode(' ', $args);
$body['command'] = $argsString;

if ($envVariables !== null) {
$body['env_variables'] = $envVariables;
Expand Down Expand Up @@ -917,7 +918,7 @@ public static function runOcc(

if ($resultXml === false) {
throw new Exception(
"Response is not valid XML after executing 'occ $args'. " .
"Response is not valid XML after executing 'occ $argsString'. " .
$isTestingAppEnabledText .
$contents
);
Expand All @@ -929,47 +930,47 @@ public static function runOcc(

if (!isset($return['code'][0])) {
throw new Exception(
"Return code not found after executing 'occ $args'. " .
"Return code not found after executing 'occ $argsString'. " .
$isTestingAppEnabledText .
$contents
);
}

if (!isset($return['stdOut'][0])) {
throw new Exception(
"Return stdOut not found after executing 'occ $args'. " .
"Return stdOut not found after executing 'occ $argsString'. " .
$isTestingAppEnabledText .
$contents
);
}

if (!isset($return['stdErr'][0])) {
throw new Exception(
"Return stdErr not found after executing 'occ $args'. " .
"Return stdErr not found after executing 'occ $argsString'. " .
$isTestingAppEnabledText .
$contents
);
}

if (!\is_a($return['code'][0], "SimpleXMLElement")) {
throw new Exception(
"Return code is not a SimpleXMLElement after executing 'occ $args'. " .
"Return code is not a SimpleXMLElement after executing 'occ $argsString'. " .
$isTestingAppEnabledText .
$contents
);
}

if (!\is_a($return['stdOut'][0], "SimpleXMLElement")) {
throw new Exception(
"Return stdOut is not a SimpleXMLElement after executing 'occ $args'. " .
"Return stdOut is not a SimpleXMLElement after executing 'occ $argsString'. " .
$isTestingAppEnabledText .
$contents
);
}

if (!\is_a($return['stdErr'][0], "SimpleXMLElement")) {
throw new Exception(
"Return stdErr is not a SimpleXMLElement after executing 'occ $args'. " .
"Return stdErr is not a SimpleXMLElement after executing 'occ $argsString'. " .
$isTestingAppEnabledText .
$contents
);
Expand Down
58 changes: 40 additions & 18 deletions tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use InvalidArgumentException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
Expand Down Expand Up @@ -363,6 +364,7 @@ public static function listFolder(
}

/**
* sends a DAV request
*
* @param string|null $baseUrl
* URL of owncloud e.g. http://localhost:8080
Expand All @@ -385,8 +387,11 @@ public static function listFolder(
* @param Client|null $client
* @param array|null $urlParameter to concatenate with path
* @param string|null $doDavRequestAsUser run the DAV as this user, if null its same as $user
* @param bool|null $usingSpacesDavPath to send request with spaces dav
* @param string|null $spaceId space id to perform action on
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function makeDavRequest(
?string $baseUrl,
Expand All @@ -397,22 +402,31 @@ public static function makeDavRequest(
?array $headers,
?string $xRequestId = '',
$body = null,
?int $davPathVersionToUse = 1,
?int $davPathVersionToUse = null,
?string $type = "files",
?string $sourceIpAddress = null,
?string $authType = "basic",
?bool $stream = false,
?int $timeout = 0,
?Client $client = null,
?array $urlParameter = [],
?string $doDavRequestAsUser = null
?string $doDavRequestAsUser = null,
?bool $usingSpacesDavPath = false,
?string $spaceId = null
):ResponseInterface {
$baseUrl = self::sanitizeUrl($baseUrl, true);

// set default dav version as 1
if (!$usingSpacesDavPath && !$davPathVersionToUse) {
$davPathVersionToUse = 1;
}

if ($doDavRequestAsUser === null) {
$davPath = self::getDavPath($user, $davPathVersionToUse, $type);
$davPath = self::getDavPath($user, $davPathVersionToUse, $type, $usingSpacesDavPath, $spaceId);
} else {
$davPath = self::getDavPath($doDavRequestAsUser, $davPathVersionToUse, $type);
$davPath = self::getDavPath($doDavRequestAsUser, $davPathVersionToUse, $type, $usingSpacesDavPath, $spaceId);
}

//replace %, # and ? and in the path, Guzzle will not encode them
$urlSpecialChar = [['%', '#', '?'], ['%25', '%23', '%3F']];
$path = \str_replace($urlSpecialChar[0], $urlSpecialChar[1], $path);
Expand Down Expand Up @@ -475,13 +489,17 @@ public static function makeDavRequest(
* @param string|null $user
* @param int|null $davPathVersionToUse (1|2)
* @param string|null $type
* @param bool $usingSpaces
* @param string|null $spaceId
*
* @return string
*/
public static function getDavPath(
?string $user,
?int $davPathVersionToUse = 1,
?string $type = "files"
?int $davPathVersionToUse = null,
?string $type = "files",
?bool $usingSpaces = false,
?string $spaceId = null
):string {
if ($type === "public-files" || $type === "public-files-old") {
return "public.php/webdav/";
Expand All @@ -495,20 +513,24 @@ public static function getDavPath(
if ($type === "customgroups") {
return "remote.php/dav/";
}
if ($davPathVersionToUse === 1) {
$path = "remote.php/webdav/";
return $path;
} elseif ($davPathVersionToUse === 2) {
if ($type === "files") {
$path = 'remote.php/dav/files/';
return $path . $user . '/';
if ($usingSpaces) {
return "dav/spaces/" . $spaceId . '/';
} else {
if ($davPathVersionToUse === 1) {
$path = "remote.php/webdav/";
return $path;
} elseif ($davPathVersionToUse === 2) {
if ($type === "files") {
$path = 'remote.php/dav/files/';
return $path . $user . '/';
} else {
return "remote.php/dav";
}
} else {
return "remote.php/dav";
throw new InvalidArgumentException(
"DAV path version $davPathVersionToUse is unknown"
);
}
} else {
throw new InvalidArgumentException(
"DAV path version $davPathVersionToUse is unknown"
);
}
}

Expand Down
9 changes: 9 additions & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,14 @@ default:
contexts:
- FeatureContext: *common_feature_context_params
- OccContext:

cliDbConversion:
paths:
- '%paths.base%/../features/cliDbConversion'
context: *common_ldap_suite_context
contexts:
- FeatureContext: *common_feature_context_params
- OccContext:

cliEncryption:
paths:
Expand All @@ -711,6 +719,7 @@ default:
- FederationContext:
- OccContext:
- WebDavPropertiesContext:
- PublicWebDavContext:

cliLocalStorage:
paths:
Expand Down
Loading