Add local API acceptance tests

This commit is contained in:
Phil Davis
2020-07-31 12:24:01 +05:45
parent 67861acd73
commit b36390e017
13 changed files with 387 additions and 3 deletions

View File

@@ -4,5 +4,6 @@ exclude_paths:
- changelog/**
- docs/**
- pkg/proto/**
- tests/acceptance/features/bootstrap/*
...

View File

@@ -194,7 +194,7 @@ def apiTests(ctx, coreBranch = 'master', coreCommit = ''):
build() +
ocisServer() + [
{
'name': 'oC10APIAcceptanceTests',
'name': 'clone-test-repos',
'image': 'owncloudci/php:7.2',
'pull': 'always',
'environment' : {
@@ -213,7 +213,49 @@ def apiTests(ctx, coreBranch = 'master', coreCommit = ''):
'cd /srv/app/testrunner',
] + ([
'git checkout %s' % (coreCommit)
] if coreCommit != '' else []) + [
] if coreCommit != '' else []),
'volumes': [{
'name': 'gopath',
'path': '/srv/app',
}]
},
{
'name': 'LocalAcceptanceTests',
'image': 'owncloudci/php:7.2',
'pull': 'always',
'environment' : {
'TEST_SERVER_URL': 'http://ocis-server:9140',
'OCIS_REVA_DATA_ROOT': '/srv/app/tmp/reva/',
'SKELETON_DIR': '/srv/app/tmp/testing/data/apiSkeleton',
'TEST_EXTERNAL_USER_BACKENDS':'true',
'REVA_LDAP_HOSTNAME':'ldap',
'TEST_OCIS':'true',
'PATH_TO_CORE': '/srv/app/testrunner'
},
'commands': [
'make test-acceptance-api',
],
'volumes': [{
'name': 'gopath',
'path': '/srv/app',
}]
},
{
'name': 'oC10APIAcceptanceTests',
'image': 'owncloudci/php:7.2',
'pull': 'always',
'environment' : {
'TEST_SERVER_URL': 'http://ocis-server:9140',
'OCIS_REVA_DATA_ROOT': '/srv/app/tmp/reva/',
'SKELETON_DIR': '/srv/app/tmp/testing/data/apiSkeleton',
'TEST_EXTERNAL_USER_BACKENDS':'true',
'REVA_LDAP_HOSTNAME':'ldap',
'TEST_OCIS':'true',
'BEHAT_FILTER_TAGS': '~@notToImplementOnOCIS&&~@toImplementOnOCIS',
'EXPECTED_FAILURES_FILE': '/drone/src/tests/acceptance/expected-failures.txt'
},
'commands': [
'cd /srv/app/testrunner',
'make test-acceptance-api',
],
'volumes': [{

9
.gitignore vendored
View File

@@ -6,4 +6,11 @@ coverage.out
*.key
*crt
/eos-docker
/eos-docker
# API acceptance tests
composer.lock
/vendor
vendor-bin/**/vendor
vendor-bin/**/composer.lock
tests/acceptance/output

View File

@@ -312,3 +312,21 @@ eos-install-go:
docker exec -i eos-cli1 curl https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz -O
docker exec -i eos-cli1 tar -C /usr/local -xzf go1.14.4.linux-amd64.tar.gz
# export PATH=$PATH:/usr/local/go/bin
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.
composer.lock: composer.json
@echo composer.lock is not up to date.

18
composer.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "owncloud/ocis",
"config" : {
"platform": {
"php": "7.2"
}
},
"require": {
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4"
},
"extra": {
"bamarni-bin": {
"bin-links": false
}
}
}

View File

@@ -0,0 +1,30 @@
default:
autoload:
'': '%paths.base%/../features/bootstrap'
suites:
apiOcisSpecific:
paths:
- '%paths.base%/../features/apiOcisSpecific'
context: &common_ldap_suite_context
parameters:
ldapAdminPassword: admin
ldapUsersOU: TestUsers
ldapGroupsOU: TestGroups
ldapInitialUserFilePath: /../../config/ldap-users.ldif
contexts:
- RevaContext:
- OccContext:
- FeatureContext: &common_feature_context_params
baseUrl: http://localhost:8080
adminUsername: admin
adminPassword: admin
regularUserPassword: 123456
ocPath: apps/testing/api/v1/occ
- FavoritesContext:
- WebDavPropertiesContext:
extensions:
jarnaiz\JUnitFormatter\JUnitFormatterExtension:
filename: report.xml
outputDir: '%paths.base%/../output/'

View File

@@ -0,0 +1,27 @@
@api
Feature: auth
@issue-ocis-reva-30 @issue-ocis-reva-65
# after fixing all issues delete this Scenario and use the one from oC10 core
Scenario: send DELETE requests to OCS endpoints as admin with wrong password
When the administrator 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"

View File

@@ -0,0 +1,112 @@
@api
Feature: auth
Background:
Given user "Alice" has been created with default attributes and skeleton files
@issue-ocis-reva-29
@issue-ocis-reva-30
# after fixing all issues delete this Scenario and use the one from oC10 core
Scenario: using OCS anonymously
When a user requests these endpoints with "GET" and no authentication
| endpoint |
| /ocs/v1.php/apps/files_external/api/v1/mounts |
| /ocs/v2.php/apps/files_external/api/v1/mounts |
| /ocs/v1.php/apps/files_sharing/api/v1/remote_shares |
| /ocs/v2.php/apps/files_sharing/api/v1/remote_shares |
| /ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending |
| /ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending |
| /ocs/v1.php/apps/files_sharing/api/v1/shares |
| /ocs/v2.php/apps/files_sharing/api/v1/shares |
| /ocs/v1.php/cloud/apps |
| /ocs/v2.php/cloud/apps |
| /ocs/v1.php/cloud/groups |
| /ocs/v2.php/cloud/groups |
| /ocs/v1.php/cloud/users |
| /ocs/v2.php/cloud/users |
| /ocs/v1.php/config |
| /ocs/v2.php/config |
| /ocs/v1.php/privatedata/getattribute |
| /ocs/v2.php/privatedata/getattribute |
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"
@issue-ocis-reva-11
@issue-ocis-reva-30
@issue-ocis-reva-31
@issue-ocis-reva-32
@issue-ocis-reva-33
@issue-ocis-reva-34
@issue-ocis-reva-35
# after fixing all issues delete this Scenario and use the one from oC10 core
Scenario: using OCS with non-admin basic auth
When the user "Alice" requests these endpoints with "GET" with basic auth
| endpoint |
| /ocs/v1.php/apps/files_external/api/v1/mounts |
| /ocs/v1.php/apps/files_sharing/api/v1/remote_shares |
| /ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending |
| /ocs/v1.php/privatedata/getattribute |
| /ocs/v1.php/cloud/groups |
| /ocs/v1.php/cloud/apps |
Then the HTTP status code of responses on all endpoints should be "200"
And the OCS status code of responses on all endpoints should be "998"
When the user "Alice" requests these endpoints with "GET" with basic auth
| endpoint |
| /ocs/v1.php/config |
Then the HTTP status code of responses on all endpoints should be "200"
And the OCS status code of responses on all endpoints should be "100"
When the user "Alice" requests these endpoints with "GET" with basic auth
| endpoint |
| /ocs/v2.php/apps/files_external/api/v1/mounts |
| /ocs/v2.php/apps/files_sharing/api/v1/remote_shares |
| /ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending |
# | /ocs/v1.php/apps/files_sharing/api/v1/shares | 100 | 200 |
# | /ocs/v2.php/apps/files_sharing/api/v1/shares | 100 | 200 |
| /ocs/v2.php/cloud/apps |
| /ocs/v2.php/cloud/groups |
| /ocs/v2.php/privatedata/getattribute |
Then the HTTP status code of responses on all endpoints should be "404"
And the OCS status code of responses on all endpoints should be "998"
When the user "Alice" requests these endpoints with "GET" with basic auth
| endpoint |
| /ocs/v1.php/cloud/users |
Then the HTTP status code of responses on all endpoints should be "200"
And the OCS status code of responses on all endpoints should be "403"
When the user "Alice" requests these endpoints with "GET" with basic auth
| endpoint |
| /ocs/v2.php/cloud/users |
Then the HTTP status code of responses on all endpoints should be "403"
And the OCS status code of responses on all endpoints should be "403"
When the user "Alice" requests these endpoints with "GET" with basic auth
| endpoint |
| /ocs/v2.php/config |
Then the HTTP status code of responses on all endpoints should be "200"
And the OCS status code of responses on all endpoints should be "200"
@issue-ocis-reva-29
@issue-ocis-reva-30
# after fixing all issues delete this Scenario and use the one from oC10 core
Scenario: using OCS as normal user with wrong password
When user "Alice" requests these endpoints with "GET" using password "invalid"
| endpoint |
| /ocs/v1.php/apps/files_external/api/v1/mounts |
| /ocs/v2.php/apps/files_external/api/v1/mounts |
| /ocs/v1.php/apps/files_sharing/api/v1/remote_shares |
| /ocs/v2.php/apps/files_sharing/api/v1/remote_shares |
| /ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending |
| /ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending |
| /ocs/v1.php/apps/files_sharing/api/v1/shares |
| /ocs/v2.php/apps/files_sharing/api/v1/shares |
| /ocs/v1.php/cloud/apps |
| /ocs/v2.php/cloud/apps |
| /ocs/v1.php/cloud/groups |
| /ocs/v2.php/cloud/groups |
| /ocs/v1.php/cloud/users |
| /ocs/v2.php/cloud/users |
| /ocs/v1.php/config |
| /ocs/v2.php/config |
| /ocs/v1.php/privatedata/getattribute |
| /ocs/v2.php/privatedata/getattribute |
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"

View File

@@ -0,0 +1,35 @@
@api
Feature: auth
Background:
Given user "Alice" has been created with default attributes and skeleton files
@issue-ocis-reva-30
# after fixing all issues delete this Scenario and use the one from oC10 core
Scenario: send POST requests to OCS endpoints as normal user with wrong password
When user "Alice" requests these endpoints with "POST" including body "doesnotmatter" 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/shares |
| /ocs/v2.php/apps/files_sharing/api/v1/shares |
| /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 |
| /ocs/v2.php/cloud/groups |
| /ocs/v1.php/cloud/users |
| /ocs/v2.php/cloud/users |
| /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 |
| /ocs/v1.php/person/check |
| /ocs/v2.php/person/check |
| /ocs/v1.php/privatedata/deleteattribute/testing/test |
| /ocs/v2.php/privatedata/deleteattribute/testing/test |
| /ocs/v1.php/privatedata/setattribute/testing/test |
| /ocs/v2.php/privatedata/setattribute/testing/test |
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"

View File

@@ -0,0 +1,18 @@
@api
Feature: auth
@issue-ocis-reva-30
# after fixing all issues delete this Scenario and use the one from oC10 core
Scenario: send PUT request to OCS endpoints as admin with wrong password
When the administrator requests these endpoints with "PUT" with body "doesnotmatter" using password "invalid" about user "Alice"
| endpoint |
| /ocs/v1.php/cloud/users/%username% |
| /ocs/v2.php/cloud/users/%username% |
| /ocs/v1.php/cloud/users/%username%/disable |
| /ocs/v2.php/cloud/users/%username%/disable |
| /ocs/v1.php/cloud/users/%username%/enable |
| /ocs/v2.php/cloud/users/%username%/enable |
| /ocs/v1.php/apps/files_sharing/api/v1/shares/123 |
| /ocs/v2.php/apps/files_sharing/api/v1/shares/123 |
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"

View File

@@ -0,0 +1,40 @@
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use TestHelpers\AppConfigHelper;
use TestHelpers\SetupHelper;
require_once 'bootstrap.php';
/**
* Context for Reva specific steps
*/
class RevaContext implements Context {
/**
* @var FeatureContext
*/
private $featureContext;
/**
* @BeforeScenario
*
* @param BeforeScenarioScope $scope
*
* @return void
* @throws Exception
*/
public function setUpScenario(BeforeScenarioScope $scope) {
// Get the environment
$environment = $scope->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()
);
}
}

View File

@@ -0,0 +1,14 @@
<?php
$pathToCore = \getenv('PATH_TO_CORE');
if ($pathToCore === false) {
$pathToCore = "../core";
}
require_once $pathToCore . '/tests/acceptance/features/bootstrap/bootstrap.php';
$classLoader = new \Composer\Autoload\ClassLoader();
$classLoader->addPsr4(
"", $pathToCore . "/tests/acceptance/features/bootstrap", true
);
$classLoader->register();

View File

@@ -0,0 +1,22 @@
{
"config" : {
"platform": {
"php": "7.2"
}
},
"require": {
"behat/behat": "^3.7",
"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",
"laminas/laminas-ldap": "^2.10"
}
}