diff --git a/.drone.star b/.drone.star index e278eae0db..657952abef 100644 --- a/.drone.star +++ b/.drone.star @@ -154,6 +154,20 @@ config = { "OCM_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE": "%s" % dirs["ocmProviders"], }, }, + "apiWopi": { + "suites": [ + "apiCollaboration", + ], + "skip": False, + "collaborationServiceNeeded": True, + "extraCollaborationEnvironment": { + "COLLABORATION_APP_NAME": "FakeOffice", + "COLLABORATION_APP_ADDR": "http://fakeoffice:8080", + }, + "extraServerEnvironment": { + "GATEWAY_GRPC_ADDR": "0.0.0.0:9142", + }, + }, "cli": { "suites": [ "cliCommands", @@ -855,6 +869,8 @@ def localApiTestPipeline(ctx): "antivirusNeeded": False, "tikaNeeded": False, "federationServer": False, + "collaborationServiceNeeded": False, + "extraCollaborationEnvironment": {}, } if "localApiTests" in config: @@ -880,9 +896,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(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": [ @@ -987,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: @@ -1063,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, @@ -2176,6 +2156,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, @@ -2894,6 +2875,63 @@ 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", + "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/config/behat.yml b/tests/acceptance/config/behat.yml index a587cc2474..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" diff --git a/tests/acceptance/features/apiCollaboration/wopi.feature b/tests/acceptance/features/apiCollaboration/wopi.feature new file mode 100644 index 0000000000..4584b52594 --- /dev/null +++ b/tests/acceptance/features/apiCollaboration/wopi.feature @@ -0,0 +1,51 @@ +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 + 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 "" + 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": "^.*\\?WOPISrc=.*wopi%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" + } + } + } + } + } + """ + Examples: + | app-endpoint | + | /app/open?file_id=<>&app_name=FakeOffice | + | /app/open?file_id=<> | diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index be822278bf..cbdadefa9f 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -1743,15 +1743,16 @@ trait WebDav { * @param string $source * @param string $destination * - * @return void + * @return array */ - 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'); } /** diff --git a/tests/config/drone/app-registry.yaml b/tests/config/drone/app-registry.yaml new file mode 100644 index 0000000000..a1042ec45f --- /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: OpenDocument + description: OpenDocument text document + icon: "" + default_app: FakeOffice + allow_creation: true 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