From b398cb1b4b742797c29b316ba408c8f0fdc39a54 Mon Sep 17 00:00:00 2001 From: Prajwol Amatya Date: Wed, 21 Aug 2024 16:44:55 +0545 Subject: [PATCH 1/8] add test coverage for /app/ endpoint --- tests/acceptance/config/behat.yml | 7 +++ .../apiAppProvider/appProvider.feature | 43 +++++++++++++++++++ .../features/bootstrap/SpacesContext.php | 22 ++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/acceptance/features/apiAppProvider/appProvider.feature diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index a587cc2474..7bcecc6b35 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -414,6 +414,13 @@ default: - TagContext: - TrashbinContext: + apiAppProvider: + paths: + - "%paths.base%/../features/apiAppProvider" + context: *common_ldap_suite_context + contexts: + - FeatureContext: *common_feature_context_params + extensions: rdx\behatvars\BehatVariablesExtension: ~ diff --git a/tests/acceptance/features/apiAppProvider/appProvider.feature b/tests/acceptance/features/apiAppProvider/appProvider.feature new file mode 100644 index 0000000000..1c39b9dee2 --- /dev/null +++ b/tests/acceptance/features/apiAppProvider/appProvider.feature @@ -0,0 +1,43 @@ +Feature: App Provider + + + Scenario: open file with Collabora + Given user "Alice" has been created with default attributes and without skeleton files + And user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt" + When user "Alice" opens file "simple.odt" with Collabora service + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "app_url", + "method", + "form_parameters" + ], + "properties": { + "app_url": { + "type": "string", + "pattern": "^https:\\/\\/host\\.docker\\.internal:9980\\/browser\\/8ec5fda\\/cool\\.html\\?WOPISrc=https%3A%2F%2Fhost\\.docker\\.internal%3A9300%2Fwopi%2Ffiles%2F[a-fA-F0-9]{64}$" + }, + "method": { + "const": "POST" + }, + "form_parameters": { + "type": "object", + "required": [ + "access_token", + "access_token_ttl" + ], + "properties": { + "access_token": { + "type": "string" + }, + "access_token_ttl": { + "type": "string" + } + } + } + } + } + """ diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 9cf94d8608..bbf0de5e78 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -4131,4 +4131,26 @@ class SpacesContext implements Context { ) ); } + + /** + * @When user :user opens file :filename with Collabora service + * + * @param string $user + * @param string $filename + * + * @return void + */ + public function userOpensFileWithCollaboraService(string $user, string $filename): void + { + $fileId = $this->getFileId($user, "Personal", $filename); + $url = $this->featureContext->getBaseUrl() . "/app/open?file_id=$fileId&app_name=Collabora"; + $this->featureContext->setResponse( + HttpRequestHelper::post( + $url, + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user) + ) + ); + } } From 964dfc62f00f4b9419b5b177981c911d306054bf Mon Sep 17 00:00:00 2001 From: Prajwol Amatya Date: Thu, 22 Aug 2024 11:31:12 +0545 Subject: [PATCH 2/8] setup fakeoffice for acceptance test --- .drone.star | 110 ++++++++++++++---- .../apiAppProvider/appProvider.feature | 2 +- .../features/bootstrap/SpacesContext.php | 41 ++++--- 3 files changed, 111 insertions(+), 42 deletions(-) diff --git a/.drone.star b/.drone.star index e278eae0db..1aa5acd83f 100644 --- a/.drone.star +++ b/.drone.star @@ -59,13 +59,13 @@ dirs = { # configuration config = { "cs3ApiTests": { - "skip": False, + "skip": True, }, "wopiValidatorTests": { - "skip": False, + "skip": True, }, "k6LoadTests": { - "skip": False, + "skip": True, }, "localApiTests": { "basic": { @@ -92,19 +92,20 @@ config = { "apiSharingNgLinkShareRoot", "apiActivities", ], - "skip": False, + "skip": True, }, "apiAccountsHashDifficulty": { "suites": [ "apiAccountsHashDifficulty", ], "accounts_hash_difficulty": "default", + "skip": True, }, "apiNotification": { "suites": [ "apiNotification", ], - "skip": False, + "skip": True, "emailNeeded": True, "extraEnvironment": { "EMAIL_HOST": "email", @@ -122,7 +123,7 @@ config = { "suites": [ "apiAntivirus", ], - "skip": False, + "skip": True, "antivirusNeeded": True, "extraServerEnvironment": { "ANTIVIRUS_SCANNER_TYPE": "clamav", @@ -136,14 +137,14 @@ config = { "suites": [ "apiSearchContent", ], - "skip": False, + "skip": True, "tikaNeeded": True, }, "apiOcm": { "suites": [ "apiOcm", ], - "skip": False, + "skip": True, "federationServer": True, "extraServerEnvironment": { "OCIS_ADD_RUN_SERVICES": "ocm", @@ -158,22 +159,36 @@ config = { "suites": [ "cliCommands", ], + "skip": True, + }, + "apiAppProvider": { + "suites": [ + "apiAppProvider", + ], "skip": False, + "collaborationServiceNeeded": True, + "extraCollaborationEnvironment": { + "COLLABORATION_APP_NAME": "FakeOffice", + "COLLABORATION_APP_ADDR": "http://fakeoffice:8080", + }, + "extraServerEnvironment": { + "GATEWAY_GRPC_ADDR": "0.0.0.0:9142", + }, }, }, "apiTests": { "numberOfParts": 10, - "skip": False, + "skip": True, "skipExceptParts": [], }, "e2eTests": { "part": { - "skip": False, + "skip": True, "totalParts": 4, # divide and run all suites in parts (divide pipelines) "xsuites": ["search", "app-provider", "oidc"], # suites to skip }, "search": { - "skip": False, + "skip": True, "suites": ["search"], # suites to run "tikaNeeded": True, }, @@ -189,7 +204,7 @@ config = { "dockerReleases": { "architectures": ["arm64", "amd64"], }, - "litmus": True, + "litmus": False, "codestyle": True, } @@ -280,15 +295,9 @@ def main(ctx): licenseCheck(ctx) test_pipelines = \ - codestyle(ctx) + \ - checkGherkinLint(ctx) + \ - checkTestSuitesInExpectedFailures(ctx) + \ buildWebCache(ctx) + \ getGoBinForTesting(ctx) + \ buildOcisBinaryForTesting(ctx) + \ - checkStarlark() + \ - build_release_helpers + \ - testOcisAndUploadResults(ctx) + \ testPipelines(ctx) build_release_pipelines = \ @@ -302,7 +311,7 @@ def main(ctx): ), ) - pipelines = test_pipelines + build_release_pipelines + pipelines = test_pipelines if ctx.build.event == "cron": pipelines = \ @@ -855,6 +864,8 @@ def localApiTestPipeline(ctx): "antivirusNeeded": False, "tikaNeeded": False, "federationServer": False, + "collaborationServiceNeeded": False, + "extraCollaborationEnvironment": {}, } if "localApiTests" in config: @@ -880,9 +891,10 @@ def localApiTestPipeline(ctx): (waitForClamavService() if params["antivirusNeeded"] else []) + (waitForEmailService() if params["emailNeeded"] else []) + (ocisServer(storage, params["accounts_hash_difficulty"], deploy_type = "federation", extra_server_environment = params["extraServerEnvironment"]) if params["federationServer"] else []) + + (collaborationService(extra_environment = params["extraCollaborationEnvironment"]) if params["collaborationServiceNeeded"] else []) + localApiTests(suite, storage, params["extraEnvironment"]) + logRequests(), - "services": emailService() if params["emailNeeded"] else [] + clamavService() if params["antivirusNeeded"] else [], + "services": emailService() if params["emailNeeded"] else [] + clamavService() if params["antivirusNeeded"] else [] + fakeOffice() if params["collaborationServiceNeeded"] else [], "depends_on": getPipelineNames(buildOcisBinaryForTesting(ctx)), "trigger": { "ref": [ @@ -2894,6 +2906,64 @@ def waitForClamavService(): ], }] +def fakeOffice(): + return [ + { + "name": "fakeoffice", + "image": OC_CI_ALPINE, + "detach": True, + "environment": {}, + "commands": [ + "sh %s/tests/config/drone/serve-hosting-discovery.sh" % (dirs["base"]), + ], + }, + { + "name": "wait-for-fakeoffice", + "image": OC_CI_WAIT_FOR, + "commands": [ + "wait-for -it fakeoffice:8080 -t 300", + ], + }, + ] + +def collaborationService(extra_environment = {}): + environment = { + "MICRO_REGISTRY": "nats-js-kv", + "MICRO_REGISTRY_ADDRESS": "ocis-server:9233", + "COLLABORATION_LOG_LEVEL": "debug", + "COLLABORATION_HTTP_ADDR": "0.0.0.0:9300", + "COLLABORATION_GRPC_ADDR": "0.0.0.0:9301", + # no proof keys available in the FakeOffice + "COLLABORATION_APP_PROOF_DISABLE": "true", + "COLLABORATION_APP_INSECURE": "true", + "COLLABORATION_WOPI_SRC": "http://wopiserver:9300", + "COLLABORATION_WOPI_SECRET": "some-wopi-secret", + "COLLABORATION_CS3API_DATAGATEWAY_INSECURE": "true", + "OCIS_JWT_SECRET": "some-ocis-jwt-secret", + } + + for item in extra_environment: + environment[item] = extra_environment[item] + + return [ + { + "name": "wopiserver", + "image": OC_CI_GOLANG, + "detach": True, + "environment": environment, + "commands": [ + "ocis/bin/ocis collaboration server", + ], + }, + { + "name": "wait-for-wopi-server", + "image": OC_CI_WAIT_FOR, + "commands": [ + "wait-for -it wopiserver:9300 -t 300", + ], + }, + ] + def tikaService(): return [{ "name": "tika", diff --git a/tests/acceptance/features/apiAppProvider/appProvider.feature b/tests/acceptance/features/apiAppProvider/appProvider.feature index 1c39b9dee2..84515fda8b 100644 --- a/tests/acceptance/features/apiAppProvider/appProvider.feature +++ b/tests/acceptance/features/apiAppProvider/appProvider.feature @@ -4,7 +4,7 @@ Feature: App Provider Scenario: open file with Collabora Given user "Alice" has been created with default attributes and without skeleton files And user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt" - When user "Alice" opens file "simple.odt" with Collabora service + When user "Alice" opens file "simple.odt" with collaboration service Then the HTTP status code should be "200" And the JSON data of the response should match """ diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index bbf0de5e78..3a224d9610 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -4132,25 +4132,24 @@ class SpacesContext implements Context { ); } - /** - * @When user :user opens file :filename with Collabora service - * - * @param string $user - * @param string $filename - * - * @return void - */ - public function userOpensFileWithCollaboraService(string $user, string $filename): void - { - $fileId = $this->getFileId($user, "Personal", $filename); - $url = $this->featureContext->getBaseUrl() . "/app/open?file_id=$fileId&app_name=Collabora"; - $this->featureContext->setResponse( - HttpRequestHelper::post( - $url, - $this->featureContext->getStepLineRef(), - $user, - $this->featureContext->getPasswordForUser($user) - ) - ); - } + /** + * @When user :user opens file :filename with collaboration service + * + * @param string $user + * @param string $filename + * + * @return void + */ + public function userOpensFileWithCollaborationService(string $user, string $filename): void { + $fileId = $this->getFileId($user, "Personal", $filename); + $url = $this->featureContext->getBaseUrl() . "/app/open?file_id=$fileId&app_name=FakeOffice"; + $this->featureContext->setResponse( + HttpRequestHelper::post( + $url, + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user) + ) + ); + } } From f79f8bb17deb305bd883e4b68ae31213b2843b61 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Thu, 22 Aug 2024 16:50:31 +0545 Subject: [PATCH 3/8] ci: check requests --- .drone.star | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.drone.star b/.drone.star index 1aa5acd83f..2a48cd30ac 100644 --- a/.drone.star +++ b/.drone.star @@ -2962,6 +2962,24 @@ def collaborationService(extra_environment = {}): "wait-for -it wopiserver:9300 -t 300", ], }, + { + "name": "prepare-test-file", + "image": OC_CI_ALPINE, + "environment": {}, + "commands": [ + "curl -v -X PUT 'https://ocis-server:9200/remote.php/webdav/test.wopitest' -k --fail --retry-connrefused --retry 7 --retry-all-errors -u admin:admin -D headers.txt", + "cat headers.txt", + "export FILE_ID=$(cat headers.txt | sed -n -e 's/^.*Oc-Fileid: //p')", + "export URL=\"https://ocis-server:9200/app/open?app_name=FakeOffice&file_id=$FILE_ID\"", + "export URL=$(echo $URL | tr -d '[:cntrl:]')", + "curl -v -X POST \"$URL\" -k --fail --retry-connrefused --retry 7 --retry-all-errors -u admin:admin > open.json", + "cat open.json", + "cat open.json | jq .form_parameters.access_token | tr -d '\"' > accesstoken", + "cat open.json | jq .form_parameters.access_token_ttl | tr -d '\"' > accesstokenttl", + "echo -n 'http://wopiserver:9300/wopi/files/' > wopisrc", + "cat open.json | jq .app_url | sed -n -e 's/^.*files%2F//p' | tr -d '\"' >> wopisrc", + ], + }, ] def tikaService(): From 330952733b989df16251010743b86d4a2a20e09f Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Thu, 22 Aug 2024 17:45:20 +0545 Subject: [PATCH 4/8] test: allow FakeOffice to work with other file extensions --- .drone.star | 21 --------------------- tests/config/drone/hosting-discovery.xml | 18 +++++++++++------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/.drone.star b/.drone.star index 2a48cd30ac..935694f4fd 100644 --- a/.drone.star +++ b/.drone.star @@ -295,8 +295,6 @@ def main(ctx): licenseCheck(ctx) test_pipelines = \ - buildWebCache(ctx) + \ - getGoBinForTesting(ctx) + \ buildOcisBinaryForTesting(ctx) + \ testPipelines(ctx) @@ -2933,7 +2931,6 @@ def collaborationService(extra_environment = {}): "COLLABORATION_LOG_LEVEL": "debug", "COLLABORATION_HTTP_ADDR": "0.0.0.0:9300", "COLLABORATION_GRPC_ADDR": "0.0.0.0:9301", - # no proof keys available in the FakeOffice "COLLABORATION_APP_PROOF_DISABLE": "true", "COLLABORATION_APP_INSECURE": "true", "COLLABORATION_WOPI_SRC": "http://wopiserver:9300", @@ -2962,24 +2959,6 @@ def collaborationService(extra_environment = {}): "wait-for -it wopiserver:9300 -t 300", ], }, - { - "name": "prepare-test-file", - "image": OC_CI_ALPINE, - "environment": {}, - "commands": [ - "curl -v -X PUT 'https://ocis-server:9200/remote.php/webdav/test.wopitest' -k --fail --retry-connrefused --retry 7 --retry-all-errors -u admin:admin -D headers.txt", - "cat headers.txt", - "export FILE_ID=$(cat headers.txt | sed -n -e 's/^.*Oc-Fileid: //p')", - "export URL=\"https://ocis-server:9200/app/open?app_name=FakeOffice&file_id=$FILE_ID\"", - "export URL=$(echo $URL | tr -d '[:cntrl:]')", - "curl -v -X POST \"$URL\" -k --fail --retry-connrefused --retry 7 --retry-all-errors -u admin:admin > open.json", - "cat open.json", - "cat open.json | jq .form_parameters.access_token | tr -d '\"' > accesstoken", - "cat open.json | jq .form_parameters.access_token_ttl | tr -d '\"' > accesstokenttl", - "echo -n 'http://wopiserver:9300/wopi/files/' > wopisrc", - "cat open.json | jq .app_url | sed -n -e 's/^.*files%2F//p' | tr -d '\"' >> wopisrc", - ], - }, ] def tikaService(): diff --git a/tests/config/drone/hosting-discovery.xml b/tests/config/drone/hosting-discovery.xml index f663da91da..9dbe99100b 100644 --- a/tests/config/drone/hosting-discovery.xml +++ b/tests/config/drone/hosting-discovery.xml @@ -1,8 +1,12 @@ - - - - - - - + + + + + + + + + + + \ No newline at end of file From c0173c3ebf8b6f0791a6ce9f510152f0eae7e9e5 Mon Sep 17 00:00:00 2001 From: Prajwol Amatya Date: Fri, 23 Aug 2024 11:36:51 +0545 Subject: [PATCH 5/8] add test to open file with collaboration app --- .../apiAppProvider/appProvider.feature | 14 ++++++++++--- .../features/bootstrap/SpacesContext.php | 21 ------------------- .../acceptance/features/bootstrap/WebDav.php | 3 ++- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/tests/acceptance/features/apiAppProvider/appProvider.feature b/tests/acceptance/features/apiAppProvider/appProvider.feature index 84515fda8b..5d8f180930 100644 --- a/tests/acceptance/features/apiAppProvider/appProvider.feature +++ b/tests/acceptance/features/apiAppProvider/appProvider.feature @@ -1,10 +1,14 @@ Feature: App Provider + As a user + I want to access files with collaboration service apps + So that I can get the content of the file - Scenario: open file with Collabora + Scenario Outline: open file with .odt extension with collaboration app Given user "Alice" has been created with default attributes and without skeleton files And user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt" - When user "Alice" opens file "simple.odt" with collaboration service + And we save it into "FILEID" + When user "Alice" sends HTTP method "POST" to URL "" Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -18,7 +22,7 @@ Feature: App Provider "properties": { "app_url": { "type": "string", - "pattern": "^https:\\/\\/host\\.docker\\.internal:9980\\/browser\\/8ec5fda\\/cool\\.html\\?WOPISrc=https%3A%2F%2Fhost\\.docker\\.internal%3A9300%2Fwopi%2Ffiles%2F[a-fA-F0-9]{64}$" + "pattern": "^https:\\/\\/fakeoffice\\.owncloud\\.test\\/not\\/relevant\\?WOPISrc=http%3A%2F%2Fwopiserver%3A9300%2Fwopi%2Ffiles%2F[a-fA-F0-9]{64}$" }, "method": { "const": "POST" @@ -41,3 +45,7 @@ Feature: App Provider } } """ + Examples: + | endpoint | + | /app/open?file_id=<>&app_name=FakeOffice | + | /app/open?file_id=<> | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 3a224d9610..9cf94d8608 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -4131,25 +4131,4 @@ class SpacesContext implements Context { ) ); } - - /** - * @When user :user opens file :filename with collaboration service - * - * @param string $user - * @param string $filename - * - * @return void - */ - public function userOpensFileWithCollaborationService(string $user, string $filename): void { - $fileId = $this->getFileId($user, "Personal", $filename); - $url = $this->featureContext->getBaseUrl() . "/app/open?file_id=$fileId&app_name=FakeOffice"; - $this->featureContext->setResponse( - HttpRequestHelper::post( - $url, - $this->featureContext->getStepLineRef(), - $user, - $this->featureContext->getPasswordForUser($user) - ) - ); - } } diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index be822278bf..70f2ac38fb 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -1745,13 +1745,14 @@ trait WebDav { * * @return void */ - public function userHasUploadedAFileTo(string $user, string $source, string $destination):void { + public function userHasUploadedAFileTo(string $user, string $source, string $destination):array { $response = $this->uploadFile($user, $source, $destination, true); $this->theHTTPStatusCodeShouldBe( ["201", "204"], "HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination' for user '$user'", $response ); + return $response->getHeader('oc-fileid'); } /** From 4489ea637bcae02a42994fd64e47f2daed26d91b Mon Sep 17 00:00:00 2001 From: Prajwol Amatya Date: Fri, 23 Aug 2024 11:57:49 +0545 Subject: [PATCH 6/8] add app registry config --- .drone.star | 37 +++++++++++-------- .../apiAppProvider/appProvider.feature | 4 +- tests/config/drone/app-registry.yaml | 9 +++++ 3 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 tests/config/drone/app-registry.yaml diff --git a/.drone.star b/.drone.star index 935694f4fd..bb4287ee79 100644 --- a/.drone.star +++ b/.drone.star @@ -59,13 +59,13 @@ dirs = { # configuration config = { "cs3ApiTests": { - "skip": True, + "skip": False, }, "wopiValidatorTests": { - "skip": True, + "skip": False, }, "k6LoadTests": { - "skip": True, + "skip": False, }, "localApiTests": { "basic": { @@ -92,20 +92,19 @@ config = { "apiSharingNgLinkShareRoot", "apiActivities", ], - "skip": True, + "skip": False, }, "apiAccountsHashDifficulty": { "suites": [ "apiAccountsHashDifficulty", ], "accounts_hash_difficulty": "default", - "skip": True, }, "apiNotification": { "suites": [ "apiNotification", ], - "skip": True, + "skip": False, "emailNeeded": True, "extraEnvironment": { "EMAIL_HOST": "email", @@ -123,7 +122,7 @@ config = { "suites": [ "apiAntivirus", ], - "skip": True, + "skip": False, "antivirusNeeded": True, "extraServerEnvironment": { "ANTIVIRUS_SCANNER_TYPE": "clamav", @@ -137,14 +136,14 @@ config = { "suites": [ "apiSearchContent", ], - "skip": True, + "skip": False, "tikaNeeded": True, }, "apiOcm": { "suites": [ "apiOcm", ], - "skip": True, + "skip": False, "federationServer": True, "extraServerEnvironment": { "OCIS_ADD_RUN_SERVICES": "ocm", @@ -159,7 +158,6 @@ config = { "suites": [ "cliCommands", ], - "skip": True, }, "apiAppProvider": { "suites": [ @@ -178,17 +176,17 @@ config = { }, "apiTests": { "numberOfParts": 10, - "skip": True, + "skip": False, "skipExceptParts": [], }, "e2eTests": { "part": { - "skip": True, + "skip": False, "totalParts": 4, # divide and run all suites in parts (divide pipelines) "xsuites": ["search", "app-provider", "oidc"], # suites to skip }, "search": { - "skip": True, + "skip": False, "suites": ["search"], # suites to run "tikaNeeded": True, }, @@ -204,7 +202,7 @@ config = { "dockerReleases": { "architectures": ["arm64", "amd64"], }, - "litmus": False, + "litmus": True, "codestyle": True, } @@ -295,7 +293,15 @@ def main(ctx): licenseCheck(ctx) test_pipelines = \ + codestyle(ctx) + \ + checkGherkinLint(ctx) + \ + checkTestSuitesInExpectedFailures(ctx) + \ + buildWebCache(ctx) + \ + getGoBinForTesting(ctx) + \ buildOcisBinaryForTesting(ctx) + \ + checkStarlark() + \ + build_release_helpers + \ + testOcisAndUploadResults(ctx) + \ testPipelines(ctx) build_release_pipelines = \ @@ -309,7 +315,7 @@ def main(ctx): ), ) - pipelines = test_pipelines + pipelines = test_pipelines + build_release_pipelines if ctx.build.event == "cron": pipelines = \ @@ -2186,6 +2192,7 @@ def ocisServer(storage, accounts_hash_difficulty = 4, volumes = [], depends_on = "commands": [ "%s init --insecure true" % ocis_bin, "cat $OCIS_CONFIG_DIR/ocis.yaml", + "cp tests/config/drone/app-registry.yaml /root/.ocis/config/app-registry.yaml", ] + (wrapper_commands), "volumes": volumes, "depends_on": depends_on, diff --git a/tests/acceptance/features/apiAppProvider/appProvider.feature b/tests/acceptance/features/apiAppProvider/appProvider.feature index 5d8f180930..840b874bc4 100644 --- a/tests/acceptance/features/apiAppProvider/appProvider.feature +++ b/tests/acceptance/features/apiAppProvider/appProvider.feature @@ -8,7 +8,7 @@ Feature: App Provider Given user "Alice" has been created with default attributes and without skeleton files And user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt" And we save it into "FILEID" - When user "Alice" sends HTTP method "POST" to URL "" + When user "Alice" sends HTTP method "POST" to URL "" Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -46,6 +46,6 @@ Feature: App Provider } """ Examples: - | endpoint | + | app-endpoint | | /app/open?file_id=<>&app_name=FakeOffice | | /app/open?file_id=<> | diff --git a/tests/config/drone/app-registry.yaml b/tests/config/drone/app-registry.yaml new file mode 100644 index 0000000000..674829a89c --- /dev/null +++ b/tests/config/drone/app-registry.yaml @@ -0,0 +1,9 @@ +app_registry: + mimetypes: + - mime_type: application/vnd.oasis.opendocument.text + extension: odt + name: FakeOffice + description: FakeOffice text document + icon: "" + default_app: FakeOffice + allow_creation: true From df34b917ff84a874eb35ac5a1728319db8756036 Mon Sep 17 00:00:00 2001 From: Prajwol Amatya Date: Mon, 26 Aug 2024 10:00:58 +0545 Subject: [PATCH 7/8] update url pattern regex --- tests/acceptance/features/apiAppProvider/appProvider.feature | 4 ++-- tests/acceptance/features/bootstrap/WebDav.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/features/apiAppProvider/appProvider.feature b/tests/acceptance/features/apiAppProvider/appProvider.feature index 840b874bc4..859d9fb74d 100644 --- a/tests/acceptance/features/apiAppProvider/appProvider.feature +++ b/tests/acceptance/features/apiAppProvider/appProvider.feature @@ -1,7 +1,7 @@ Feature: App Provider As a user I want to access files with collaboration service apps - So that I can get the content of the file + So that I can collaborate with other users Scenario Outline: open file with .odt extension with collaboration app @@ -22,7 +22,7 @@ Feature: App Provider "properties": { "app_url": { "type": "string", - "pattern": "^https:\\/\\/fakeoffice\\.owncloud\\.test\\/not\\/relevant\\?WOPISrc=http%3A%2F%2Fwopiserver%3A9300%2Fwopi%2Ffiles%2F[a-fA-F0-9]{64}$" + "pattern": "^https:\\/\\/(.*?)\\?WOPISrc=http%3A%2F%2F(.*?)%3A9300%2Fwopi%2Ffiles%2F[a-fA-F0-9]{64}$" }, "method": { "const": "POST" diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 70f2ac38fb..cbdadefa9f 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -1743,7 +1743,7 @@ trait WebDav { * @param string $source * @param string $destination * - * @return void + * @return array */ public function userHasUploadedAFileTo(string $user, string $source, string $destination):array { $response = $this->uploadFile($user, $source, $destination, true); From 3b6eaf52714cbcf05d1337724440cf98f6f4f0f7 Mon Sep 17 00:00:00 2001 From: Prajwol Amatya Date: Mon, 26 Aug 2024 16:37:50 +0545 Subject: [PATCH 8/8] change suite name to apiCollaboration --- .drone.star | 82 ++++++------------- tests/acceptance/config/behat.yml | 14 ++-- .../wopi.feature} | 6 +- tests/config/drone/app-registry.yaml | 4 +- 4 files changed, 35 insertions(+), 71 deletions(-) rename tests/acceptance/features/{apiAppProvider/appProvider.feature => apiCollaboration/wopi.feature} (86%) diff --git a/.drone.star b/.drone.star index bb4287ee79..657952abef 100644 --- a/.drone.star +++ b/.drone.star @@ -154,14 +154,9 @@ config = { "OCM_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE": "%s" % dirs["ocmProviders"], }, }, - "cli": { + "apiWopi": { "suites": [ - "cliCommands", - ], - }, - "apiAppProvider": { - "suites": [ - "apiAppProvider", + "apiCollaboration", ], "skip": False, "collaborationServiceNeeded": True, @@ -173,6 +168,12 @@ config = { "GATEWAY_GRPC_ADDR": "0.0.0.0:9142", }, }, + "cli": { + "suites": [ + "cliCommands", + ], + "skip": False, + }, }, "apiTests": { "numberOfParts": 10, @@ -895,7 +896,7 @@ def localApiTestPipeline(ctx): (waitForClamavService() if params["antivirusNeeded"] else []) + (waitForEmailService() if params["emailNeeded"] else []) + (ocisServer(storage, params["accounts_hash_difficulty"], deploy_type = "federation", extra_server_environment = params["extraServerEnvironment"]) if params["federationServer"] else []) + - (collaborationService(extra_environment = params["extraCollaborationEnvironment"]) if params["collaborationServiceNeeded"] else []) + + (collaborationService(params["extraCollaborationEnvironment"]) if params["collaborationServiceNeeded"] else []) + localApiTests(suite, storage, params["extraEnvironment"]) + logRequests(), "services": emailService() if params["emailNeeded"] else [] + clamavService() if params["antivirusNeeded"] else [] + fakeOffice() if params["collaborationServiceNeeded"] else [], @@ -1003,38 +1004,25 @@ def wopiValidatorTests(ctx, storage, wopiServerType, accounts_hash_difficulty = "/app/wopiserver.py", ], }, + { + "name": "wait-for-wopi-server", + "image": OC_CI_WAIT_FOR, + "commands": [ + "wait-for -it wopiserver:9300 -t 300", + ], + }, ] else: extra_server_environment = { "OCIS_EXCLUDE_RUN_SERVICES": "app-provider", } - wopiServer = [ - { - "name": "wopiserver", - "image": OC_CI_GOLANG, - "detach": True, - "environment": { - "MICRO_REGISTRY": "nats-js-kv", - "MICRO_REGISTRY_ADDRESS": "ocis-server:9233", - "COLLABORATION_LOG_LEVEL": "debug", - "COLLABORATION_HTTP_ADDR": "0.0.0.0:9300", - "COLLABORATION_GRPC_ADDR": "0.0.0.0:9301", - # no proof keys available in the FakeOffice - "COLLABORATION_APP_PROOF_DISABLE": "true", - "COLLABORATION_APP_NAME": "FakeOffice", - "COLLABORATION_APP_ADDR": "http://fakeoffice:8080", - "COLLABORATION_APP_INSECURE": "true", - "COLLABORATION_WOPI_SRC": "http://wopiserver:9300", - "COLLABORATION_WOPI_SECRET": "some-wopi-secret", - "COLLABORATION_CS3API_DATAGATEWAY_INSECURE": "true", - "OCIS_JWT_SECRET": "some-ocis-jwt-secret", - }, - "commands": [ - "%s collaboration server" % ocis_bin, - ], - }, - ] + extra_environment = { + "COLLABORATION_APP_NAME": "FakeOffice", + "COLLABORATION_APP_ADDR": "http://fakeoffice:8080", + } + + wopiServer = collaborationService(extra_environment) wopiTestCases = dirs["base"] + "/tests/config/drone/wopiValidatorCustomTestCases.xml" for testgroup in testgroups: @@ -1079,34 +1067,10 @@ def wopiValidatorTests(ctx, storage, wopiServerType, accounts_hash_difficulty = }, "steps": skipIfUnchanged(ctx, "acceptance-tests") + restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin") + - [ - { - "name": "fakeoffice", - "image": OC_CI_ALPINE, - "detach": True, - "environment": {}, - "commands": [ - "sh %s/tests/config/drone/serve-hosting-discovery.sh" % (dirs["base"]), - ], - }, - { - "name": "wait-for-fakeoffice", - "image": OC_CI_WAIT_FOR, - "commands": [ - "wait-for -it fakeoffice:8080 -t 300", - ], - }, - ] + + fakeOffice() + ocisServer(storage, accounts_hash_difficulty, deploy_type = "wopi_validator", extra_server_environment = extra_server_environment) + wopiServer + [ - { - "name": "wait-for-wopi-server", - "image": OC_CI_WAIT_FOR, - "commands": [ - "wait-for -it wopiserver:9300 -t 300", - ], - }, { "name": "prepare-test-file", "image": OC_CI_ALPINE, diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 7bcecc6b35..930e5861a5 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -400,6 +400,13 @@ default: - SharingNgContext: - GraphContext: + apiCollaboration: + paths: + - "%paths.base%/../features/apiCollaboration" + context: *common_ldap_suite_context + contexts: + - FeatureContext: *common_feature_context_params + cliCommands: paths: - "%paths.base%/../features/cliCommands" @@ -414,13 +421,6 @@ default: - TagContext: - TrashbinContext: - apiAppProvider: - paths: - - "%paths.base%/../features/apiAppProvider" - context: *common_ldap_suite_context - contexts: - - FeatureContext: *common_feature_context_params - extensions: rdx\behatvars\BehatVariablesExtension: ~ diff --git a/tests/acceptance/features/apiAppProvider/appProvider.feature b/tests/acceptance/features/apiCollaboration/wopi.feature similarity index 86% rename from tests/acceptance/features/apiAppProvider/appProvider.feature rename to tests/acceptance/features/apiCollaboration/wopi.feature index 859d9fb74d..4584b52594 100644 --- a/tests/acceptance/features/apiAppProvider/appProvider.feature +++ b/tests/acceptance/features/apiCollaboration/wopi.feature @@ -1,10 +1,10 @@ -Feature: App Provider +Feature: collaboration (wopi) As a user I want to access files with collaboration service apps So that I can collaborate with other users - Scenario Outline: open file with .odt extension with collaboration app + Scenario Outline: open file with .odt extension Given user "Alice" has been created with default attributes and without skeleton files And user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt" And we save it into "FILEID" @@ -22,7 +22,7 @@ Feature: App Provider "properties": { "app_url": { "type": "string", - "pattern": "^https:\\/\\/(.*?)\\?WOPISrc=http%3A%2F%2F(.*?)%3A9300%2Fwopi%2Ffiles%2F[a-fA-F0-9]{64}$" + "pattern": "^.*\\?WOPISrc=.*wopi%2Ffiles%2F[a-fA-F0-9]{64}$" }, "method": { "const": "POST" diff --git a/tests/config/drone/app-registry.yaml b/tests/config/drone/app-registry.yaml index 674829a89c..a1042ec45f 100644 --- a/tests/config/drone/app-registry.yaml +++ b/tests/config/drone/app-registry.yaml @@ -2,8 +2,8 @@ app_registry: mimetypes: - mime_type: application/vnd.oasis.opendocument.text extension: odt - name: FakeOffice - description: FakeOffice text document + name: OpenDocument + description: OpenDocument text document icon: "" default_app: FakeOffice allow_creation: true