Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

Commit

Permalink
Run local API acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jul 23, 2020
1 parent 9cf71f0 commit 54a7c10
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 1 deletion.
33 changes: 32 additions & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -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' : {
Expand Down Expand Up @@ -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': [
{
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
32 changes: 32 additions & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
@@ -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/'
31 changes: 31 additions & 0 deletions tests/acceptance/features/apiSpecial1/ocsDELETEAuth.feature
Original file line number Diff line number Diff line change
@@ -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"
25 changes: 25 additions & 0 deletions tests/acceptance/features/apiSpecial2/favorites.feature
Original file line number Diff line number Diff line change
@@ -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_version> 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 |
42 changes: 42 additions & 0 deletions tests/acceptance/features/bootstrap/RevaContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\AfterScenarioScope;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use PHPUnit\Framework\Assert;
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()
);
}
}
14 changes: 14 additions & 0 deletions tests/acceptance/features/bootstrap/bootstrap.php
Original file line number Diff line number Diff line change
@@ -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();
21 changes: 21 additions & 0 deletions vendor-bin/behat/composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 54a7c10

Please sign in to comment.