diff --git a/.drone.star b/.drone.star index 766da04..c2e505b 100644 --- a/.drone.star +++ b/.drone.star @@ -92,7 +92,7 @@ def apiTests(ctx, coreBranch = 'master', coreCommit = ''): ] }, { - 'name': 'acceptance-tests', + 'name': 'core-acceptance-tests', 'image': 'owncloudci/php:7.2', 'pull': 'always', 'environment' : { @@ -121,6 +121,37 @@ def apiTests(ctx, coreBranch = 'master', coreCommit = ''): }, ] }, + { + 'name': 'local-acceptance-tests', + 'image': 'owncloudci/php:7.2', + 'pull': 'always', + 'environment' : { + 'TEST_SERVER_URL': 'http://reva-server:9140', + 'BEHAT_FILTER_TAGS': '~@skipOnOcis&&~@skipOnOcis-OC-Storage', + 'REVA_LDAP_HOSTNAME':'ldap', + 'TEST_EXTERNAL_USER_BACKENDS':'true', + 'TEST_OCIS':'true', + 'OCIS_REVA_DATA_ROOT': '/srv/app/tmp/reva/', + 'SKELETON_DIR': '/srv/app/tmp/testing/data/apiSkeleton', + 'PATH_TO_CORE': '/srv/app/testrunner' + }, + 'commands': [ + 'git clone -b master --depth=1 https://github.com/owncloud/testing.git /srv/app/tmp/testing', + 'git clone -b %s --single-branch --no-tags https://github.com/owncloud/core.git /srv/app/testrunner' % (coreBranch), + 'cd /srv/app/testrunner', + ] + ([ + 'git checkout %s' % (coreCommit) + ] if coreCommit != '' else []) + [ + 'cd /drone/src', + 'make test-acceptance-api' + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ] + }, ], 'services': [ { diff --git a/.gitignore b/.gitignore index 6067678..4899c12 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,10 @@ coverage.out /node_modules /assets + +# API acceptance tests +composer.lock +/vendor +vendor-bin/**/vendor +vendor-bin/**/composer.lock +tests/acceptance/output diff --git a/Makefile b/Makefile index 511c344..3bd8fcb 100644 --- a/Makefile +++ b/Makefile @@ -159,3 +159,18 @@ docs: config-docs-generate docs-copy docs-build .PHONY: watch watch: go run github.com/cespare/reflex -c reflex.conf + +BEHAT_BIN=vendor-bin/behat/vendor/bin/behat + +.PHONY: test-acceptance-api +test-acceptance-api: vendor-bin/behat/vendor + BEHAT_BIN=$(BEHAT_BIN) $(PATH_TO_CORE)/tests/acceptance/run.sh --remote --type api + +vendor/bamarni/composer-bin-plugin: composer.lock + composer install + +vendor-bin/behat/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/behat/composer.lock + composer bin behat install --no-progress + +vendor-bin/behat/composer.lock: vendor-bin/behat/composer.json + @echo behat composer.lock is not up to date. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..53c0a9c --- /dev/null +++ b/composer.json @@ -0,0 +1,18 @@ +{ + "name": "owncloud/ocis-reva", + "config" : { + "platform": { + "php": "7.2" + } + }, + "require": { + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4" + }, + "extra": { + "bamarni-bin": { + "bin-links": false + } + } +} diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml new file mode 100644 index 0000000..dae2bdd --- /dev/null +++ b/tests/acceptance/config/behat.yml @@ -0,0 +1,32 @@ +default: + autoload: + '': '%paths.base%/../features/bootstrap' + + suites: + apiSpecial1: + paths: + - '%paths.base%/../features/apiSpecial1' + contexts: + - RevaContext: + - OccContext: + - FeatureContext: &common_feature_context_params + baseUrl: http://localhost:8080 + adminUsername: admin + adminPassword: admin + regularUserPassword: 123456 + ocPath: apps/testing/api/v1/occ + + apiSpecial2: + paths: + - '%paths.base%/../features/apiSpecial2' + contexts: + - RevaContext: + - OccContext: + - FeatureContext: *common_feature_context_params + - FavoritesContext: + - WebDavPropertiesContext: + + extensions: + jarnaiz\JUnitFormatter\JUnitFormatterExtension: + filename: report.xml + outputDir: '%paths.base%/../output/' diff --git a/tests/acceptance/features/apiSpecial1/ocsDELETEAuth.feature b/tests/acceptance/features/apiSpecial1/ocsDELETEAuth.feature new file mode 100644 index 0000000..9ddda42 --- /dev/null +++ b/tests/acceptance/features/apiSpecial1/ocsDELETEAuth.feature @@ -0,0 +1,31 @@ +@api +Feature: auth + + Background: + Given user "another-admin" has been created with default attributes and without skeleton files + And user "another-admin" has been added to group "admin" + + @issue-ocis-reva-30 @issue-ocis-reva-65 + #after fixing all issues delete this Scenario and use the core scenario + Scenario: send DELETE requests to OCS endpoints as admin with wrong password + When user "another-admin" requests these endpoints with "DELETE" using password "invalid" about user "Alice" + | endpoint | + | /ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending/123 | + | /ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/123 | + | /ocs/v1.php/apps/files_sharing/api/v1/remote_shares/123 | + | /ocs/v2.php/apps/files_sharing/api/v1/remote_shares/123 | + | /ocs/v2.php/apps/files_sharing/api/v1/shares/123 | + | /ocs/v1.php/apps/files_sharing/api/v1/shares/pending/123 | + | /ocs/v2.php/apps/files_sharing/api/v1/shares/pending/123 | + | /ocs/v1.php/cloud/apps/testing | + | /ocs/v2.php/cloud/apps/testing | + | /ocs/v1.php/cloud/groups/group1 | + | /ocs/v2.php/cloud/groups/group1 | + | /ocs/v1.php/cloud/users/%username% | + | /ocs/v2.php/cloud/users/%username% | + | /ocs/v1.php/cloud/users/%username%/groups | + | /ocs/v2.php/cloud/users/%username%/groups | + | /ocs/v1.php/cloud/users/%username%/subadmins | + | /ocs/v2.php/cloud/users/%username%/subadmins | + Then the HTTP status code of responses on all endpoints should be "401" + And the OCS status code of responses on all endpoints should be "notset" diff --git a/tests/acceptance/features/apiSpecial2/favorites.feature b/tests/acceptance/features/apiSpecial2/favorites.feature new file mode 100644 index 0000000..daf471b --- /dev/null +++ b/tests/acceptance/features/apiSpecial2/favorites.feature @@ -0,0 +1,25 @@ +@api +Feature: favorite + + Background: + Given using OCS API version "1" + And user "Alice" has been created with default attributes and without skeleton files + And user "Alice" has uploaded file with content "some data" to "/textfile0.txt" + And user "Alice" has uploaded file with content "some data" to "/textfile1.txt" + And user "Alice" has uploaded file with content "some data" to "/textfile2.txt" + And user "Alice" has uploaded file with content "some data" to "/textfile3.txt" + And user "Alice" has uploaded file with content "some data" to "/textfile4.txt" + And user "Alice" has created folder "/FOLDER" + And user "Alice" has created folder "/PARENT" + And user "Alice" has uploaded file with content "some data" to "/PARENT/parent.txt" + + @skipOnOcis-OC-Storage @issue-ocis-reva-276 + #after fixing the issues delete this Scenario and use the core scenario + Scenario Outline: Favorite a folder + Given using DAV path + When user "Alice" favorites element "/FOLDER" using the WebDAV API + Then the HTTP status code should be "500" + Examples: + | dav_version | + | old | + | new | diff --git a/tests/acceptance/features/bootstrap/RevaContext.php b/tests/acceptance/features/bootstrap/RevaContext.php new file mode 100644 index 0000000..6b6405c --- /dev/null +++ b/tests/acceptance/features/bootstrap/RevaContext.php @@ -0,0 +1,42 @@ +getEnvironment(); + // Get all the contexts you need in this context + $this->featureContext = $environment->getContext('FeatureContext'); + SetupHelper::init( + $this->featureContext->getAdminUsername(), + $this->featureContext->getAdminPassword(), + $this->featureContext->getBaseUrl(), + $this->featureContext->getOcPath() + ); + } +} diff --git a/tests/acceptance/features/bootstrap/bootstrap.php b/tests/acceptance/features/bootstrap/bootstrap.php new file mode 100644 index 0000000..8690302 --- /dev/null +++ b/tests/acceptance/features/bootstrap/bootstrap.php @@ -0,0 +1,14 @@ +addPsr4( + "", $pathToCore . "/tests/acceptance/features/bootstrap", true +); + +$classLoader->register(); diff --git a/vendor-bin/behat/composer.json b/vendor-bin/behat/composer.json new file mode 100644 index 0000000..71272d4 --- /dev/null +++ b/vendor-bin/behat/composer.json @@ -0,0 +1,21 @@ +{ + "config" : { + "platform": { + "php": "7.2" + } + }, + "require": { + "behat/behat": "^3.6", + "behat/mink": "1.7.1", + "behat/mink-extension": "^2.3", + "behat/mink-goutte-driver": "^1.2", + "behat/mink-selenium2-driver": "^1.4", + "jarnaiz/behat-junit-formatter": "^1.3", + "rdx/behat-variables": "^1.2", + "sensiolabs/behat-page-object-extension": "^2.3", + "symfony/translation": "^4.4", + "sabre/xml": "^2.2", + "guzzlehttp/guzzle": "^6.5", + "phpunit/phpunit": "^8.5" + } +}