mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-26 18:28:20 -04:00
Merge pull request #52 from owncloud/acceptanceTestsInfrastructure
[Tests-Only] Add tests infrastructure and tests for ocis-accounts
This commit is contained in:
177
.drone.star
177
.drone.star
@@ -1,6 +1,7 @@
|
||||
def main(ctx):
|
||||
before = [
|
||||
testing(ctx),
|
||||
UITests(ctx, 'master', '787c2443dd4ab977f69a2e34751dc27a8928da1e', 'master', 'b990689a83630baa83f4311718ff8c819fb95ef9')
|
||||
]
|
||||
|
||||
stages = [
|
||||
@@ -261,6 +262,182 @@ def docker(ctx, arch):
|
||||
},
|
||||
}
|
||||
|
||||
def UITests(ctx, ocisBranch, ocisCommitId, phoenixBranch, phoenixCommitId):
|
||||
return {
|
||||
'kind': 'pipeline',
|
||||
'type': 'docker',
|
||||
'name': 'UiTests',
|
||||
'platform': {
|
||||
'os': 'linux',
|
||||
'arch': 'amd64',
|
||||
},
|
||||
'steps': [
|
||||
{
|
||||
'name': 'build',
|
||||
'image': 'webhippie/golang:1.13',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'make build',
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'path': '/srv/app',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'build-ocis',
|
||||
'image': 'webhippie/golang:1.13',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'git clone -b %s --single-branch --no-tags https://github.com/owncloud/ocis /srv/app/ocis' % (ocisBranch),
|
||||
'cd /srv/app/ocis',
|
||||
'git checkout %s' % (ocisCommitId),
|
||||
'make build',
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'path': '/srv/app'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'ocis-server',
|
||||
'image': 'webhippie/golang:1.13',
|
||||
'pull': 'always',
|
||||
'detach': True,
|
||||
'environment' : {
|
||||
'REVA_LDAP_HOSTNAME': 'ldap',
|
||||
'REVA_LDAP_PORT': 636,
|
||||
'REVA_LDAP_BIND_PASSWORD': 'admin',
|
||||
'REVA_LDAP_BIND_DN': 'cn=admin,dc=owncloud,dc=com',
|
||||
'REVA_LDAP_BASE_DN': 'dc=owncloud,dc=com',
|
||||
'REVA_STORAGE_HOME_DATA_TEMP_FOLDER': '/srv/app/tmp/',
|
||||
'REVA_STORAGE_LOCAL_ROOT': '/srv/app/tmp/reva/root',
|
||||
'REVA_STORAGE_OWNCLOUD_DATADIR': '/srv/app/tmp/reva/data',
|
||||
'REVA_STORAGE_OC_DATA_TEMP_FOLDER': '/srv/app/tmp/',
|
||||
'REVA_STORAGE_OWNCLOUD_REDIS_ADDR': 'redis:6379',
|
||||
'REVA_OIDC_ISSUER': 'https://ocis-server:9200',
|
||||
'PHOENIX_WEB_CONFIG': '/drone/src/ui/tests/config/drone/ocis-config.json',
|
||||
'PHOENIX_ASSET_PATH': '/srv/app/phoenix/dist',
|
||||
'KONNECTD_IDENTIFIER_REGISTRATION_CONF': '/drone/src/ui/tests/config/drone/identifier-registration.yml',
|
||||
'KONNECTD_ISS': 'https://ocis-server:9200',
|
||||
'KONNECTD_TLS': 'true',
|
||||
'LDAP_URI': 'ldap://ldap',
|
||||
'LDAP_BINDDN': 'cn=admin,dc=owncloud,dc=com',
|
||||
'LDAP_BINDPW': 'admin',
|
||||
'LDAP_BASEDN': 'dc=owncloud,dc=com',
|
||||
'OCIS_CONFIG_FILE': '/drone/src/ui/tests/config/drone/proxy-config.json'
|
||||
},
|
||||
'commands': [
|
||||
'mkdir -p /srv/app/tmp/reva',
|
||||
# First run settings service because accounts need it to register the settings bundles
|
||||
'/srv/app/ocis/bin/ocis settings &',
|
||||
# Now start the accounts service
|
||||
'bin/ocis-accounts server &',
|
||||
# Now run all the ocis services except the accounts and settings because they are already running
|
||||
'/srv/app/ocis/bin/ocis server',
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'path': '/srv/app'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'WebUIAcceptanceTests',
|
||||
'image': 'owncloudci/nodejs:10',
|
||||
'pull': 'always',
|
||||
'environment': {
|
||||
'SERVER_HOST': 'https://ocis-server:9200',
|
||||
'BACKEND_HOST': 'https://ocis-server:9200',
|
||||
'RUN_ON_OCIS': 'true',
|
||||
'OCIS_REVA_DATA_ROOT': '/srv/app/tmp/reva',
|
||||
'OCIS_SKELETON_DIR': '/srv/app/testing/data/webUISkeleton',
|
||||
'PHOENIX_CONFIG': '/drone/src/ui/tests/config/drone/ocis-config.json',
|
||||
'LDAP_SERVER_URL': 'ldap://ldap',
|
||||
'TEST_TAGS': 'not @skipOnOCIS and not @skip',
|
||||
'LOCAL_UPLOAD_DIR': '/uploads',
|
||||
'PHOENIX_PATH': '/srv/app/phoenix',
|
||||
'FEATURE_PATH': 'ui/tests/acceptance/features',
|
||||
'NODE_TLS_REJECT_UNAUTHORIZED': '0'
|
||||
},
|
||||
'commands': [
|
||||
'git clone --depth=1 https://github.com/owncloud/testing.git /srv/app/testing',
|
||||
'git clone -b %s --single-branch https://github.com/owncloud/phoenix /srv/app/phoenix' % (phoenixBranch),
|
||||
'cd /srv/app/phoenix',
|
||||
'git checkout %s' % (phoenixCommitId),
|
||||
'cp -r /srv/app/phoenix/tests/acceptance/filesForUpload/* /uploads',
|
||||
'yarn install-all',
|
||||
'yarn dist',
|
||||
'cp -r /drone/src/ui/tests/config/drone/ocis-config.json /srv/app/phoenix/dist/config.json',
|
||||
'cd /drone/src',
|
||||
'yarn install --all',
|
||||
'make test-acceptance-webui'
|
||||
],
|
||||
'volumes': [{
|
||||
'name': 'gopath',
|
||||
'path': '/srv/app',
|
||||
},
|
||||
{
|
||||
'name': 'uploads',
|
||||
'path': '/uploads'
|
||||
}]
|
||||
},
|
||||
],
|
||||
'services': [
|
||||
{
|
||||
'name': 'ldap',
|
||||
'image': 'osixia/openldap:1.3.0',
|
||||
'pull': 'always',
|
||||
'environment': {
|
||||
'LDAP_DOMAIN': 'owncloud.com',
|
||||
'LDAP_ORGANISATION': 'ownCloud',
|
||||
'LDAP_ADMIN_PASSWORD': 'admin',
|
||||
'LDAP_TLS_VERIFY_CLIENT': 'never',
|
||||
'HOSTNAME': 'ldap'
|
||||
},
|
||||
},
|
||||
{
|
||||
'name': 'redis',
|
||||
'image': 'webhippie/redis',
|
||||
'pull': 'always',
|
||||
'environment': {
|
||||
'REDIS_DATABASES': 1
|
||||
},
|
||||
},
|
||||
{
|
||||
'name': 'selenium',
|
||||
'image': 'selenium/standalone-chrome-debug:3.141.59-20200326',
|
||||
'pull': 'always',
|
||||
'volumes': [{
|
||||
'name': 'uploads',
|
||||
'path': '/uploads'
|
||||
}],
|
||||
},
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'temp': {},
|
||||
},
|
||||
{
|
||||
'name': 'uploads',
|
||||
'temp': {}
|
||||
}
|
||||
],
|
||||
'trigger': {
|
||||
'ref': [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
'refs/pull/**',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
def binary(ctx, name):
|
||||
if ctx.build.event == "tag":
|
||||
settings = {
|
||||
|
||||
6
Makefile
6
Makefile
@@ -25,6 +25,8 @@ PACKAGES ?= $(shell go list ./...)
|
||||
SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*")
|
||||
GENERATE ?= $(IMPORT)/pkg/assets
|
||||
|
||||
FEATURE_PATH ?= "ui/tests/acceptance/features"
|
||||
|
||||
TAGS ?=
|
||||
|
||||
ifndef OUTPUT
|
||||
@@ -152,6 +154,10 @@ docs-build:
|
||||
.PHONY: docs
|
||||
docs: docs-copy docs-build
|
||||
|
||||
.PHONY: test-acceptance-webui
|
||||
test-acceptance-webui:
|
||||
./ui/tests/run-acceptance-test.sh $(FEATURE_PATH)
|
||||
|
||||
.PHONY: watch
|
||||
watch:
|
||||
go run github.com/cespare/reflex -c reflex.conf
|
||||
|
||||
11
nightwatch.conf.js
Normal file
11
nightwatch.conf.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const path = require('path')
|
||||
const PHOENIX_PATH = process.env.PHOENIX_PATH
|
||||
|
||||
const config = require(path.join(PHOENIX_PATH, 'nightwatch.conf.js'))
|
||||
|
||||
config.page_objects_path = [PHOENIX_PATH + '/tests/acceptance/pageObjects', 'ui/tests/acceptance/pageobjects']
|
||||
config.custom_commands_path = PHOENIX_PATH + '/tests/acceptance/customCommands'
|
||||
|
||||
module.exports = {
|
||||
...config
|
||||
}
|
||||
18
package.json
18
package.json
@@ -16,7 +16,8 @@
|
||||
"build": "rollup -c",
|
||||
"watch": "rollup -c -w",
|
||||
"test": "echo 'Not implemented'",
|
||||
"generate-api": "node node_modules/swagger-vue-generator/bin/generate-api.js --package-version v0 --source pkg/proto/v0/accounts.swagger.json --moduleName accounts --destination ui/client/accounts/index.js"
|
||||
"generate-api": "node node_modules/swagger-vue-generator/bin/generate-api.js --package-version v0 --source pkg/proto/v0/accounts.swagger.json --moduleName accounts --destination ui/client/accounts/index.js",
|
||||
"acceptance-tests": "cucumber-js --require-module @babel/register --require-module @babel/polyfill --require ${TEST_INFRA_DIRECTORY}/acceptance/setup.js --require ui/tests/acceptance/stepDefinitions --require ${TEST_INFRA_DIRECTORY}/acceptance/stepDefinitions --format node_modules/cucumber-pretty -t \"${TEST_TAGS:-not @skip and not @skipOnOC10}\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.7.7",
|
||||
@@ -25,14 +26,19 @@
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.7.7",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
|
||||
"@babel/plugin-transform-runtime": "^7.8.0",
|
||||
"@babel/polyfill": "^7.10.1",
|
||||
"@babel/preset-env": "^7.7.7",
|
||||
"@babel/register": "7.10.1",
|
||||
"@erquhart/rollup-plugin-node-builtins": "^2.1.5",
|
||||
"@rollup/plugin-commonjs": "^11.0.1",
|
||||
"@rollup/plugin-json": "^4.0.1",
|
||||
"@rollup/plugin-replace": "^2.3.0",
|
||||
"archiver": "^4.0.1",
|
||||
"axios": "^0.19.0",
|
||||
"core-js": "3",
|
||||
"cross-env": "^6.0.3",
|
||||
"cucumber": "^6.0.5",
|
||||
"cucumber-pretty": ">=6.0.0",
|
||||
"debounce": "^1.2.0",
|
||||
"easygettext": "^2.7.0",
|
||||
"eslint": "6.8.0",
|
||||
@@ -42,6 +48,12 @@
|
||||
"eslint-plugin-promise": "^4.1.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"eslint-plugin-vue": "^6.1.2",
|
||||
"fs-extra": "^9.0.1",
|
||||
"join-path": "^1.1.1",
|
||||
"ldap": "^0.7.1",
|
||||
"nightwatch": "^1.3.6",
|
||||
"nightwatch-api": "^3.0.1",
|
||||
"node-fetch": "^2.6.0",
|
||||
"qs": "^6.9.1",
|
||||
"rimraf": "^3.0.0",
|
||||
"rollup": "^1.28.0",
|
||||
@@ -53,7 +65,9 @@
|
||||
"rollup-plugin-terser": "^5.1.3",
|
||||
"rollup-plugin-vue": "^5.1.4",
|
||||
"swagger-vue-generator": "^1.0.6",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
"url-search-params-polyfill": "^8.1.0",
|
||||
"vue-template-compiler": "^2.6.11",
|
||||
"xml-js": "^1.6.11"
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
|
||||
13
ui/tests/acceptance/features/accounts.feature
Normal file
13
ui/tests/acceptance/features/accounts.feature
Normal file
@@ -0,0 +1,13 @@
|
||||
Feature: Accounts
|
||||
|
||||
Scenario: list accounts
|
||||
Given user "user1" has been created with default attributes
|
||||
And user "user1" has logged in using the webUI
|
||||
When the user browses to the accounts page
|
||||
Then user "einstein" should be displayed in the accounts list on the WebUI
|
||||
And user "konnectd" should be displayed in the accounts list on the WebUI
|
||||
And user "marie" should be displayed in the accounts list on the WebUI
|
||||
And user "reva" should be displayed in the accounts list on the WebUI
|
||||
And user "richard" should be displayed in the accounts list on the WebUI
|
||||
|
||||
|
||||
41
ui/tests/acceptance/pageobjects/accountsPage.js
Normal file
41
ui/tests/acceptance/pageobjects/accountsPage.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const util = require('util')
|
||||
|
||||
module.exports = {
|
||||
url: function () {
|
||||
return this.api.launchUrl + '/#/accounts'
|
||||
},
|
||||
|
||||
commands: {
|
||||
navigateAndWaitTillLoaded: async function () {
|
||||
const url = this.url()
|
||||
return this.navigate(url).waitForElementVisible('@accountsLabel')
|
||||
},
|
||||
accountsList: function () {
|
||||
return this.waitForElementVisible('@accountsListTable')
|
||||
},
|
||||
isUserListed: async function (username) {
|
||||
let user
|
||||
const usernameInTable = util.format(this.elements.userInAccountsList.selector, username)
|
||||
await this.useXpath().waitForElementVisible(usernameInTable)
|
||||
.getText(usernameInTable, (result) => {
|
||||
user = result
|
||||
})
|
||||
return user.value
|
||||
}
|
||||
},
|
||||
|
||||
elements: {
|
||||
accountsLabel: {
|
||||
selector: "//h1[normalize-space(.)='Accounts']",
|
||||
locateStrategy: 'xpath'
|
||||
},
|
||||
accountsListTable: {
|
||||
selector: "//table[@class='uk-table uk-table-middle uk-table-divider']",
|
||||
locateStrategy: 'xpath'
|
||||
},
|
||||
userInAccountsList: {
|
||||
selector: '//table//td[text()="%s"]',
|
||||
locateStrategy: 'xpath'
|
||||
}
|
||||
}
|
||||
}
|
||||
13
ui/tests/acceptance/stepDefinitions/accountsContext.js
Normal file
13
ui/tests/acceptance/stepDefinitions/accountsContext.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const assert = require('assert')
|
||||
const { client } = require('nightwatch-api')
|
||||
const { When, Then } = require('cucumber')
|
||||
|
||||
When('the user browses to the accounts page', function () {
|
||||
return client.page.accountsPage().navigateAndWaitTillLoaded()
|
||||
})
|
||||
|
||||
Then('user {string} should be displayed in the accounts list on the WebUI', async function (username) {
|
||||
await client.page.accountsPage().accountsList(username)
|
||||
const userListed = await client.page.accountsPage().isUserListed(username)
|
||||
return assert.strictEqual(userListed, username)
|
||||
})
|
||||
16
ui/tests/config/drone/identifier-registration.yml
Normal file
16
ui/tests/config/drone/identifier-registration.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
|
||||
# OpenID Connect client registry.
|
||||
clients:
|
||||
- id: phoenix
|
||||
name: OCIS
|
||||
application_type: web
|
||||
insecure: yes
|
||||
trusted: yes
|
||||
redirect_uris:
|
||||
- https://ocis-server:9200/oidc-callback.html
|
||||
- https://ocis-server:9200/
|
||||
origins:
|
||||
- https://ocis-server:9200
|
||||
|
||||
authorities:
|
||||
28
ui/tests/config/drone/ocis-config.json
Normal file
28
ui/tests/config/drone/ocis-config.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"server": "https://ocis-server:9200",
|
||||
"theme": "owncloud",
|
||||
"version": "0.1.0",
|
||||
"openIdConnect": {
|
||||
"metadata_url": "https://ocis-server:9200/.well-known/openid-configuration",
|
||||
"authority": "https://ocis-server:9200",
|
||||
"client_id": "phoenix",
|
||||
"response_type": "code",
|
||||
"scope": "openid profile email"
|
||||
},
|
||||
"apps": [
|
||||
"files",
|
||||
"draw-io",
|
||||
"pdf-viewer",
|
||||
"markdown-editor",
|
||||
"media-viewer"
|
||||
],
|
||||
"external_apps": [
|
||||
{
|
||||
"id": "accounts",
|
||||
"path": "https://ocis-server:9200/accounts.js",
|
||||
"config": {
|
||||
"url": "https://ocis-server:9200"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
73
ui/tests/config/drone/proxy-config.json
Normal file
73
ui/tests/config/drone/proxy-config.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"HTTP": {
|
||||
"Namespace": "com.owncloud"
|
||||
},
|
||||
"policy_selector": {
|
||||
"static": {
|
||||
"policy": "reva"
|
||||
}
|
||||
},
|
||||
"policies": [
|
||||
{
|
||||
"name": "reva",
|
||||
"routes": [
|
||||
{
|
||||
"endpoint": "/",
|
||||
"backend": "http://localhost:9100"
|
||||
},
|
||||
{
|
||||
"endpoint": "/.well-known/",
|
||||
"backend": "http://localhost:9130"
|
||||
},
|
||||
{
|
||||
"endpoint": "/konnect/",
|
||||
"backend": "http://localhost:9130"
|
||||
},
|
||||
{
|
||||
"endpoint": "/signin/",
|
||||
"backend": "http://localhost:9130"
|
||||
},
|
||||
{
|
||||
"endpoint": "/ocs/",
|
||||
"backend": "http://localhost:9140"
|
||||
},
|
||||
{
|
||||
"endpoint": "/remote.php/",
|
||||
"backend": "http://localhost:9140"
|
||||
},
|
||||
{
|
||||
"endpoint": "/dav/",
|
||||
"backend": "http://localhost:9140"
|
||||
},
|
||||
{
|
||||
"endpoint": "/data/",
|
||||
"backend": "http://localhost:9164"
|
||||
},
|
||||
{
|
||||
"endpoint": "/webdav/",
|
||||
"backend": "http://localhost:9140"
|
||||
},
|
||||
{
|
||||
"endpoint": "/status.php",
|
||||
"backend": "http://localhost:9140"
|
||||
},
|
||||
{
|
||||
"endpoint": "/index.php/",
|
||||
"backend": "http://localhost:9140"
|
||||
},
|
||||
{
|
||||
"endpoint": "/api/v0/greet",
|
||||
"backend": "http://hello:9105"
|
||||
},
|
||||
{
|
||||
"endpoint": "/api/v0/accounts",
|
||||
"backend": "http://localhost:9181"
|
||||
},
|
||||
{
|
||||
"endpoint": "/accounts.js",
|
||||
"backend": "http://localhost:9181"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
59
ui/tests/run-acceptance-test.sh
Executable file
59
ui/tests/run-acceptance-test.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$PHOENIX_PATH" ]
|
||||
then
|
||||
echo "PHOENIX_PATH env variable is not set, cannot find files for tests infrastructure"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$OCIS_SKELETON_DIR" ]
|
||||
then
|
||||
echo "OCIS_SKELETON_DIR env variable is not set, cannot find skeleton directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$PHOENIX_CONFIG" ]
|
||||
then
|
||||
echo "PHOENIX_CONFIG env variable is not set, cannot find phoenix config file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Features path not given, exiting test run"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trap clean_up SIGHUP SIGINT SIGTERM
|
||||
|
||||
if [ -z "$TEST_INFRA_DIRECTORY" ]
|
||||
then
|
||||
cleanup=true
|
||||
testFolder=$(< /dev/urandom tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
printf "creating folder $testFolder for Test infrastructure setup\n\n"
|
||||
export TEST_INFRA_DIRECTORY=$testFolder
|
||||
fi
|
||||
|
||||
clean_up() {
|
||||
if $cleanup
|
||||
then
|
||||
if [ -d "$testFolder" ]; then
|
||||
printf "\n\n\n\nDeleting folder $testFolder Test infrastructure setup..."
|
||||
rm -rf "$testFolder"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
trap clean_up SIGHUP SIGINT SIGTERM EXIT
|
||||
|
||||
cp -r "$PHOENIX_PATH"/tests ./"$testFolder"
|
||||
|
||||
export SERVER_HOST=${SERVER_HOST:-https://localhost:9200}
|
||||
export BACKEND_HOST=${BACKEND_HOST:-https://localhost:9200}
|
||||
export RUN_ON_OCIS='true'
|
||||
export TEST_TAGS=${TEST_TAGS:-"not @skip"}
|
||||
|
||||
yarn run acceptance-tests "$1"
|
||||
|
||||
status=$?
|
||||
exit $status
|
||||
Reference in New Issue
Block a user