[tests-only][full-ci] Make graph api default in test (#8290)

* make graph api default in test

* skip quota test in reva
This commit is contained in:
Nalem7
2024-01-30 17:14:56 +05:45
committed by GitHub
parent c8d102351e
commit d73351af89
7 changed files with 48 additions and 310 deletions

View File

@@ -822,7 +822,6 @@ def localApiTestPipeline(ctx):
def localApiTests(suite, storage, extra_environment = {}):
environment = {
"TEST_WITH_GRAPH_API": "true",
"PATH_TO_OCIS": dirs["base"],
"TEST_SERVER_URL": "https://ocis-server:9200",
"OCIS_REVA_DATA_ROOT": "%s" % (dirs["ocisRevaDataRoot"] if storage == "owncloud" else ""),
@@ -1006,7 +1005,6 @@ def coreApiTests(ctx, part_number = 1, number_of_parts = 1, storage = "ocis", ac
"name": "oC10ApiTests-%s-storage-%s" % (storage, part_number),
"image": OC_CI_PHP % DEFAULT_PHP_VERSION,
"environment": {
"TEST_WITH_GRAPH_API": "true",
"PATH_TO_OCIS": "%s" % dirs["base"],
"TEST_SERVER_URL": "https://ocis-server:9200",
"OCIS_REVA_DATA_ROOT": "%s" % (dirs["ocisRevaDataRoot"] if storage == "owncloud" else ""),

View File

@@ -223,7 +223,6 @@ ocis/bin/ocis server
```bash
make test-acceptance-api \
TEST_SERVER_URL=https://localhost:9200 \
TEST_WITH_GRAPH_API=true \
```
#### Run Tests Transferred From ownCloud Core (prefix `coreApi`)
@@ -231,7 +230,6 @@ TEST_WITH_GRAPH_API=true \
```bash
make test-acceptance-from-core-api \
TEST_SERVER_URL=https://localhost:9200 \
TEST_WITH_GRAPH_API=true \
```
Useful environment variables:
@@ -289,7 +287,6 @@ If you want to work on a specific issue
```bash
make test-acceptance-from-core-api \
TEST_SERVER_URL=https://localhost:9200 \
TEST_WITH_GRAPH_API=true \
STORAGE_DRIVER=OCIS \
BEHAT_FEATURE='tests/acceptance/features/coreApiVersions/fileVersions.feature:147'
```
@@ -326,7 +323,6 @@ PROXY_ENABLE_BASIC_AUTH=true \
```bash
OCIS_WRAPPER_URL=http://localhost:5200 \
TEST_WITH_GRAPH_API=true \
TEST_SERVER_URL="https://localhost:9200" \
BEHAT_FEATURE=tests/acceptance/features/apiAsyncUpload/delayPostprocessing.feature \
make test-acceptance-api
@@ -374,7 +370,6 @@ ocis/bin/ocis server
Run the acceptance test with the following command:
```bash
TEST_WITH_GRAPH_API=true \
TEST_SERVER_URL="https://localhost:9200" \
EMAIL_HOST="localhost" \
EMAIL_PORT=9000 \
@@ -417,7 +412,6 @@ ocis/bin/ocis server
Run the acceptance test with the following command:
```bash
TEST_WITH_GRAPH_API=true \
TEST_SERVER_URL="https://localhost:9200" \
BEHAT_FEATURE="tests/acceptance/features/apiSearch/contentSearch.feature" \
make test-acceptance-api
@@ -539,7 +533,6 @@ For antivirus running with docker, use `ANTIVIRUS_CLAMAV_SOCKET= "tcp://host.doc
Run the acceptance test with the following command:
```bash
TEST_WITH_GRAPH_API=true \
TEST_SERVER_URL="https://localhost:9200" \
BEHAT_FEATURE="tests/acceptance/features/apiAntivirus/antivirus.feature" \
make test-acceptance-api

View File

@@ -47,13 +47,6 @@ class OcisHelper {
return (\getenv("TEST_PARALLEL_DEPLOYMENT") === "true");
}
/**
* @return bool
*/
public static function isTestingWithGraphApi(): bool {
return \getenv('TEST_WITH_GRAPH_API') === 'true';
}
/**
* @return bool|string false if no command given or the command as string
*/

View File

@@ -6,7 +6,6 @@ services:
environment:
OCIS_ROOT: /drone/src
TEST_SERVER_URL: https://ocis-server:9200
TEST_WITH_GRAPH_API: "true"
OCIS_WRAPPER_URL: http://ocis-server:5200
STORAGE_DRIVER: $STORAGE_DRIVER
TEST_SOURCE: $TEST_SOURCE

View File

@@ -3244,11 +3244,9 @@ class FeatureContext extends BehatVariablesContext {
$this->connectToLdap($suiteParameters);
}
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext = new GraphContext();
$this->graphContext->before($scope);
$environment->registerContext($this->graphContext);
}
$this->graphContext = new GraphContext();
$this->graphContext->before($scope);
$environment->registerContext($this->graphContext);
}
/**

View File

@@ -902,60 +902,6 @@ trait Provisioning {
}
}
/**
* @When the administrator changes the password of user :user to :password using the provisioning API
*
* @param string $user
* @param string $password
*
* @return void
* @throws Exception
*/
public function adminChangesPasswordOfUserToUsingTheProvisioningApi(
string $user,
string $password
):void {
$this->response = UserHelper::editUser(
$this->getBaseUrl(),
$user,
'password',
$password,
$this->getAdminUsername(),
$this->getAdminPassword(),
$this->getStepLineRef()
);
}
/**
* @Given the administrator has changed the password of user :user to :password
*
* @param string $user
* @param string $password
*
* @return void
* @throws Exception
*/
public function adminHasChangedPasswordOfUserTo(
string $user,
string $password
):void {
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->adminChangesPasswordOfUserToUsingTheGraphApi(
$user,
$password
);
} else {
$this->adminChangesPasswordOfUserToUsingTheProvisioningApi(
$user,
$password
);
}
$this->theHTTPStatusCodeShouldBe(
200,
"could not change password of user $user"
);
}
/**
* @When /^user "([^"]*)" (enables|disables) app "([^"]*)"$/
*
@@ -1472,53 +1418,6 @@ trait Provisioning {
$this->rememberUserEmailAddress($user, $email);
}
/**
* @Given /^the administrator has changed the email of user "([^"]*)" to "([^"]*)"$/
*
* @param string $user
* @param string $email
*
* @return void
* @throws Exception
*/
public function adminHasChangedTheEmailOfUserTo(string $user, string $email):void {
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->userHasBeenEditedUsingTheGraphApi(
$user,
null,
null,
$email
);
$updatedUserData = $this->getJsonDecodedResponse();
Assert::assertEquals(
$email,
$updatedUserData['mail']
);
} else {
$this->adminChangesTheEmailOfUserToUsingTheProvisioningApi(
$user,
$email
);
$this->theHTTPStatusCodeShouldBe(
200,
"could not change email of user $user"
);
}
}
/**
* @Given the administrator has changed their own email address to :email
*
* @param string|null $email
*
* @return void
* @throws Exception
*/
public function theAdministratorHasChangedTheirOwnEmailAddressTo(?string $email):void {
$admin = $this->getAdminUsername();
$this->adminHasChangedTheEmailOfUserTo($admin, $email);
}
/**
* @param string $requestingUser
* @param string $targetUser
@@ -1592,49 +1491,6 @@ trait Provisioning {
);
}
/**
* @Given /^user "([^"]*)" has changed the email of user "([^"]*)" to "([^"]*)"$/
*
* @param string $requestingUser
* @param string $targetUser
* @param string $email
*
* @return void
* @throws Exception
*/
public function userHasChangedTheEmailOfUserUsingTheProvisioningApi(
string $requestingUser,
string $targetUser,
string $email
):void {
$requestingUser = $this->getActualUsername($requestingUser);
$targetUser = $this->getActualUsername($targetUser);
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->userHasBeenEditedUsingTheGraphApi(
$targetUser,
null,
null,
$email,
null,
$requestingUser,
$this->getPasswordForUser($requestingUser)
);
$updatedUserData = $this->getJsonDecodedResponse();
Assert::assertEquals(
$email,
$updatedUserData['mail'],
);
} else {
$response = $this->userChangesUserEmailUsingProvisioningApi(
$requestingUser,
$targetUser,
$email
);
$this->theHTTPStatusCodeShouldBeBetween(200, 299, $response);
}
$this->rememberUserEmailAddress($targetUser, $email);
}
/**
* Edit the "display name" of a user by sending the key "displayname" to the API end point.
*
@@ -1663,60 +1519,6 @@ trait Provisioning {
$this->rememberUserDisplayName($user, $displayName);
}
/**
* @Given /^the administrator has changed the display name of user "([^"]*)" to "([^"]*)"$/
*
* @param string $user
* @param string $displayName
*
* @return void
* @throws Exception
*/
public function adminHasChangedTheDisplayNameOfUser(
string $user,
string $displayName
):void {
$user = $this->getActualUsername($user);
if ($this->isTestingWithLdap()) {
$this->editLdapUserDisplayName(
$user,
$displayName
);
} elseif (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->userHasBeenEditedUsingTheGraphApi(
$user,
null,
null,
null,
$displayName
);
$updatedUserData = $this->getJsonDecodedResponse();
Assert::assertEquals(
$displayName,
$updatedUserData['displayName']
);
} else {
$this->adminChangesTheDisplayNameOfUserUsingKey(
$user,
'displayname',
$displayName
);
$response = UserHelper::getUser(
$this->getBaseUrl(),
$user,
$this->getAdminUsername(),
$this->getAdminPassword(),
$this->getStepLineRef()
);
$actualDisplayName = $this->getDisplayNameFromResponse($response);
Assert::assertEquals(
$displayName,
$actualDisplayName
);
}
$this->rememberUserDisplayName($user, $displayName);
}
/**
* As the administrator, edit the "display name" of a user by sending the key "display" to the API end point.
*
@@ -1866,50 +1668,6 @@ trait Provisioning {
$this->pushToLastStatusCodesArrays();
}
/**
* @Given /^user "([^"]*)" has changed the display name of user "([^"]*)" to "([^"]*)"$/
*
* @param string $requestingUser
* @param string $targetUser
* @param string $displayName
*
* @return void
* @throws Exception
*/
public function userHasChangedTheDisplayNameOfUserUsingTheProvisioningApi(
string $requestingUser,
string $targetUser,
string $displayName
):void {
$requestingUser = $this->getActualUsername($requestingUser);
$targetUser = $this->getActualUsername($targetUser);
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->userHasBeenEditedUsingTheGraphApi(
$targetUser,
null,
null,
null,
$displayName,
$requestingUser,
$this->getPasswordForUser($requestingUser)
);
$updatedUserData = $this->getJsonDecodedResponse();
Assert::assertEquals(
$displayName,
$updatedUserData['displayName']
);
} else {
$response = $this->userChangesTheDisplayNameOfUserUsingKey(
$requestingUser,
$targetUser,
'displayname',
$displayName
);
$this->theHTTPStatusCodeShouldBeSuccess();
$this->theHTTPStatusCodeShouldBeBetween(200, 299, $response);
}
$this->rememberUserDisplayName($targetUser, $displayName);
}
/**
*
* @param string $requestingUser
@@ -2139,10 +1897,7 @@ trait Provisioning {
public function theseGroupsShouldNotExist(string $shouldOrNot, TableNode $table):void {
$should = ($shouldOrNot !== "not");
$this->verifyTableNodeColumns($table, ['groupname']);
$useGraph = OcisHelper::isTestingWithGraphApi();
if ($useGraph) {
$this->graphContext->theseGroupsShouldNotExist($shouldOrNot, $table);
} else {
if ($this->isTestingWithLdap()) {
$groups = $this->getArrayOfGroupsResponded($this->getAllGroups());
foreach ($table as $row) {
if (\in_array($row['groupname'], $groups, true) !== $should) {
@@ -2153,6 +1908,8 @@ trait Provisioning {
);
}
}
} else {
$this->graphContext->theseGroupsShouldNotExist($shouldOrNot, $table);
}
}
@@ -2622,12 +2379,7 @@ trait Provisioning {
*/
public function userShouldBelongToGroup(string $user, string $group):void {
$user = $this->getActualUsername($user);
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->userShouldBeMemberInGroupUsingTheGraphApi(
$user,
$group
);
} else {
if (OcisHelper::isTestingOnReva()) {
$this->theAdministratorGetsAllTheGroupsOfUser($user);
$respondedArray = $this->getArrayOfGroupsResponded($this->response);
\sort($respondedArray);
@@ -2646,6 +2398,11 @@ trait Provisioning {
. $this->response->getStatusCode()
. "'"
);
} else {
$this->graphContext->userShouldBeMemberInGroupUsingTheGraphApi(
$user,
$group
);
}
}
@@ -2688,9 +2445,7 @@ trait Provisioning {
*/
public function userShouldNotBelongToGroup(string $user, string $group):void {
$user = $this->getActualUsername($user);
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->userShouldNotBeMemberInGroupUsingTheGraphApi($user, $group);
} else {
if (OcisHelper::isTestingOnReva()) {
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/users/$user/groups";
$response = HttpRequestHelper::get(
$fullUrl,
@@ -2705,6 +2460,8 @@ trait Provisioning {
200,
$response->getStatusCode()
);
} else {
$this->graphContext->userShouldNotBeMemberInGroupUsingTheGraphApi($user, $group);
}
}
@@ -3240,10 +2997,10 @@ trait Provisioning {
*/
public function adminHasDisabledUserUsingTheProvisioningApi(?string $user):void {
$user = $this->getActualUsername($user);
if (OcisHelper::isTestingWithGraphApi()) {
$response = $this->graphContext->editUserUsingTheGraphApi($this->getAdminUsername(), $user, null, null, null, null, false);
} else {
if (OcisHelper::isTestingOnReva()) {
$response = $this->disableOrEnableUser($this->getAdminUsername(), $user, 'disable');
} else {
$response = $this->graphContext->editUserUsingTheGraphApi($this->getAdminUsername(), $user, null, null, null, null, false);
}
Assert::assertEquals(
200,
@@ -3335,10 +3092,7 @@ trait Provisioning {
*/
public function deleteUser(string $user):ResponseInterface {
// Always try to delete the user
if (OcisHelper::isTestingWithGraphApi()) {
// users can be deleted using the username in the GraphApi too
$response = $this->graphContext->adminDeletesUserUsingTheGraphApi($user);
} else {
if (OcisHelper::isTestingOnReva()) {
$response = UserHelper::deleteUser(
$this->getBaseUrl(),
$user,
@@ -3347,6 +3101,9 @@ trait Provisioning {
$this->getStepLineRef(),
$this->ocsApiVersion
);
} else {
// users can be deleted using the username in the GraphApi too
$response = $this->graphContext->adminDeletesUserUsingTheGraphApi($user);
}
return $response;
}
@@ -3414,7 +3171,7 @@ trait Provisioning {
&& \in_array($group, $this->ldapCreatedGroups)
) {
$this->removeUserFromLdapGroup($user, $group);
} elseif (OcisHelper::isTestingWithGraphApi()) {
} else {
$user = $this->getActualUsername($user);
$response = $this->graphContext->removeUserFromGroup($group, $user);
$this->TheHTTPStatusCodeShouldBe(204, '', $response);
@@ -3433,14 +3190,7 @@ trait Provisioning {
*/
public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group):void {
$user = $this->getActualUsername($user);
if (OcisHelper::isTestingWithGraphApi()) {
$this->setResponse(
$this->graphContext->removeUserFromGroup(
$group,
$user
)
);
} else {
if (OcisHelper::isTestingOnReva()) {
$this->response = UserHelper::removeUserFromGroup(
$this->getBaseUrl(),
$user,
@@ -3450,6 +3200,13 @@ trait Provisioning {
$this->getStepLineRef(),
$this->ocsApiVersion
);
} else {
$this->setResponse(
$this->graphContext->removeUserFromGroup(
$group,
$user
)
);
}
$this->pushToLastStatusCodesArrays();
@@ -3625,9 +3382,7 @@ trait Provisioning {
},
$this->simplifyArray($users)
);
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->theseUsersShouldBeInTheResponse($usersSimplified);
} else {
if ($this->isTestingWithLdap()) {
$respondedArray = $this->getArrayOfUsersResponded($this->response);
Assert::assertEqualsCanonicalizing(
$usersSimplified,
@@ -3635,6 +3390,8 @@ trait Provisioning {
__METHOD__
. " Provided users do not match the users returned in the response."
);
} else {
$this->graphContext->theseUsersShouldBeInTheResponse($usersSimplified);
}
}
@@ -3680,15 +3437,15 @@ trait Provisioning {
$groups = $groupsList->getRows();
$groupsSimplified = $this->simplifyArray($groups);
$respondedArray = $this->getArrayOfGroupsResponded($this->response);
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->theseGroupsShouldBeInTheResponse($groupsSimplified);
} else {
if ($this->isTestingWithLdap()) {
Assert::assertEqualsCanonicalizing(
$groupsSimplified,
$respondedArray,
__METHOD__
. " Provided groups do not match the groups returned in the response."
);
} else {
$this->graphContext->theseGroupsShouldBeInTheResponse($groupsSimplified);
}
}
@@ -3704,9 +3461,7 @@ trait Provisioning {
$this->verifyTableNodeColumnsCount($groupsList, 1);
$groups = $groupsList->getRows();
$groupsSimplified = $this->simplifyArray($groups);
if (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->theseGroupsShouldBeInTheResponse($groupsSimplified);
} else {
if ($this->isTestingWithLdap()) {
$expectedGroups = \array_merge($this->startingGroups, $groupsSimplified);
$respondedArray = $this->getArrayOfGroupsResponded($this->response);
Assert::assertEqualsCanonicalizing(
@@ -3715,6 +3470,8 @@ trait Provisioning {
__METHOD__
. " Provided groups do not match the groups returned in the response."
);
} else {
$this->graphContext->theseGroupsShouldBeInTheResponse($groupsSimplified);
}
}
@@ -4490,22 +4247,22 @@ trait Provisioning {
$previousServer = $this->currentServer;
$this->usingServer('LOCAL');
foreach ($this->createdGroups as $group => $groupData) {
if (OcisHelper::isTestingWithGraphApi()) {
if ($this->isTestingWithLdap()) {
$this->cleanupGroup((string)$group);
} else {
$this->graphContext->adminDeletesGroupWithGroupId(
$groupData['id']
);
} else {
$this->cleanupGroup((string)$group);
}
}
$this->usingServer('REMOTE');
foreach ($this->createdRemoteGroups as $remoteGroup => $groupData) {
if (OcisHelper::isTestingWithGraphApi()) {
if ($this->isTestingWithLdap()) {
$this->cleanupGroup((string)$remoteGroup);
} else {
$this->graphContext->adminDeletesGroupWithGroupId(
$groupData['id']
);
} else {
$this->cleanupGroup((string)$remoteGroup);
}
}
$this->usingServer($previousServer);

View File

@@ -87,7 +87,7 @@ Feature: upload to a public link share
Then the HTTP status code should be "201"
And the content of file "/FOLDER/test.txt" for user "Alice" should be "test-file"
@skipOnReva
Scenario: uploading file to a public shared folder with read/write permission when the sharer has insufficient quota does not work with public API
Given user "Alice" has created a public link share with settings
| path | FOLDER |
@@ -97,7 +97,7 @@ Feature: upload to a public link share
When the public uploads file "test.txt" with password "%public%" and content "test2" using the new public WebDAV API
Then the HTTP status code should be "507"
@skipOnReva
Scenario: uploading file to a public shared folder with upload-only permission when the sharer has insufficient quota does not work with public API
Given user "Alice" has created a public link share with settings
| path | FOLDER |