diff --git a/.vib/owncloud/cypress/cypress.json b/.vib/owncloud/cypress/cypress.json new file mode 100644 index 0000000000..4b2a0bd890 --- /dev/null +++ b/.vib/owncloud/cypress/cypress.json @@ -0,0 +1,16 @@ +{ + "pageLoadTimeout": 240000, + "defaultCommandTimeout": 8000, + "viewportWidth": 1200, + "viewportHeight": 860, + "env": { + "username": "user", + "password": "ComplicatedPassword123!4", + "smtpHost": "smtptesthost", + "smtpUser": "smtpUser", + "owncloudEmail": "test@example.com" + }, + "hosts": { + "vmware-owncloud.my": "{{ TARGET_IP }}" + } +} diff --git a/.vib/owncloud/cypress/cypress/fixtures/domains.json b/.vib/owncloud/cypress/cypress/fixtures/domains.json new file mode 100644 index 0000000000..b9c3492ef7 --- /dev/null +++ b/.vib/owncloud/cypress/cypress/fixtures/domains.json @@ -0,0 +1,5 @@ +{ + "newDomain": { + "domain": "http://vmware.com" + } +} diff --git a/.vib/owncloud/cypress/cypress/fixtures/file_to_upload.json b/.vib/owncloud/cypress/cypress/fixtures/file_to_upload.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/.vib/owncloud/cypress/cypress/fixtures/file_to_upload.json @@ -0,0 +1 @@ +{} diff --git a/.vib/owncloud/cypress/cypress/fixtures/folders.json b/.vib/owncloud/cypress/cypress/fixtures/folders.json new file mode 100644 index 0000000000..cd47a40fb8 --- /dev/null +++ b/.vib/owncloud/cypress/cypress/fixtures/folders.json @@ -0,0 +1,5 @@ +{ + "newFolder": { + "name": "test-folder" + } +} diff --git a/.vib/owncloud/cypress/cypress/fixtures/groups.json b/.vib/owncloud/cypress/cypress/fixtures/groups.json new file mode 100644 index 0000000000..a88e6c9906 --- /dev/null +++ b/.vib/owncloud/cypress/cypress/fixtures/groups.json @@ -0,0 +1,5 @@ +{ + "newGroup": { + "name": "test-group" + } +} diff --git a/.vib/owncloud/cypress/cypress/fixtures/links.json b/.vib/owncloud/cypress/cypress/fixtures/links.json new file mode 100644 index 0000000000..cabd32ba64 --- /dev/null +++ b/.vib/owncloud/cypress/cypress/fixtures/links.json @@ -0,0 +1,5 @@ +{ + "newLink": { + "name": "very-cool-link" + } +} diff --git a/.vib/owncloud/cypress/cypress/fixtures/users.json b/.vib/owncloud/cypress/cypress/fixtures/users.json new file mode 100644 index 0000000000..23350780ef --- /dev/null +++ b/.vib/owncloud/cypress/cypress/fixtures/users.json @@ -0,0 +1,6 @@ +{ + "newUser": { + "name": "pug", + "email": "pugsemail@email.com" + } +} diff --git a/.vib/owncloud/cypress/cypress/integration/owncloud_spec.js b/.vib/owncloud/cypress/cypress/integration/owncloud_spec.js new file mode 100644 index 0000000000..6adac67801 --- /dev/null +++ b/.vib/owncloud/cypress/cypress/integration/owncloud_spec.js @@ -0,0 +1,80 @@ +/// +import { random } from './utils'; + +it('allows creating a folder and uploading a file ', () => { + cy.login(); + cy.get('.new').click(); + cy.get('[data-action="folder"]').click(); + cy.fixture('folders').then((folder) => { + cy.get('[value="New folder"]').type(`${folder.newFolder.name}.${random}`); + cy.contains('Create').click(); + cy.contains('.innernametext', `${folder.newFolder.name}.${random}`).click(); + }); + cy.get('.new').click(); + cy.get('[data-action="upload"]').click(); + cy.get('input[type="file"]').selectFile( + 'cypress/fixtures/file_to_upload.json', + { force: true } + ); + cy.contains('No files in here').should('not.be.visible'); +}); + +it('allows adding a group and a user', () => { + cy.login(); + cy.visit('/index.php/settings/users'); + cy.contains('Add Group').click(); + cy.fixture('groups').then((group) => { + cy.get('#newgroupname').type(`${group.newGroup.name}.${random}`); + cy.get('#newgroup-form').within(() => { + cy.get('[type="submit"]').click(); + }); + cy.contains('.groupname', `${group.newGroup.name}.${random}`); + }); + cy.fixture('users').then((user) => { + cy.get('#newusername').type(`${user.newUser.name}.${random}`); + cy.get('#newemail').type(`${user.newUser.email}.${random}`); + cy.contains('Create').click(); + cy.contains('.name', `${user.newUser.name}.${random}`); + }); +}); + +it('checks the SMTP configuration', () => { + cy.login(); + cy.visit('/index.php/settings/admin?sectionid=general'); + cy.get('#mail_smtphost').should('have.value', Cypress.env('smtpHost')); + cy.get('#mail_smtpname').should('have.value', Cypress.env('smtpUser')); + cy.get('#mail_to_address').should('have.value', Cypress.env('owncloudEmail')); +}); + +it('allows sharing a file by link', () => { + cy.login(); + cy.get('[data-file="ownCloud Manual.pdf"]').within(() => { + cy.get('[data-action="Share"]').click(); + }); + cy.get('[class="permalink"]').click(); + cy.get('.detailFileInfoContainer').within(() => { + cy.get('input') + .invoke('val') + .should('contain', 'vmware') + .then((link) => { + cy.request({ + method: 'GET', + url: link, + form: true, + }).then((response) => { + expect(response.status).to.eq(200); + }); + }); + }); +}); + +it('allows whitelisting a domain', () => { + cy.login(); + cy.visit('/index.php/settings/personal'); + cy.contains('Security').click(); + cy.fixture('domains').then((domain) => { + cy.get('#domain').type(`${domain.newDomain.domain}`); + cy.get('#corsAddNewDomain').click(); + cy.contains('.grid', `${domain.newDomain.domain}`); + }); +}); diff --git a/.vib/owncloud/cypress/cypress/integration/utils.js b/.vib/owncloud/cypress/cypress/integration/utils.js new file mode 100644 index 0000000000..f0217c9773 --- /dev/null +++ b/.vib/owncloud/cypress/cypress/integration/utils.js @@ -0,0 +1,3 @@ +/// + +export let random = (Math.random() + 1).toString(36).substring(7); diff --git a/.vib/owncloud/cypress/cypress/support/commands.js b/.vib/owncloud/cypress/cypress/support/commands.js new file mode 100644 index 0000000000..40e0ed8c1c --- /dev/null +++ b/.vib/owncloud/cypress/cypress/support/commands.js @@ -0,0 +1,34 @@ +const COMMAND_DELAY = 800; +const BASE_URL = 'http://vmware-owncloud.my'; + +for (const command of ['click']) { + Cypress.Commands.overwrite(command, (originalFn, ...args) => { + const origVal = originalFn(...args); + + return new Promise((resolve) => { + setTimeout(() => { + resolve(origVal); + }, COMMAND_DELAY); + }); + }); +} + +Cypress.Commands.overwrite('visit', (originalFn, url, options) => { + return originalFn(`${BASE_URL}${url}`, options); +}); + +Cypress.Commands.add( + 'login', + (username = Cypress.env('username'), password = Cypress.env('password')) => { + cy.visit('/'); + cy.get('.v-align'); + cy.get('#user').type(username); + cy.get('#password').type(password); + cy.get('#submit').click(); + cy.get('body').then(($body) => { + if ($body.text().includes('A safe home')) { + cy.get('#closeWizard').click(); + } + }); + } +); diff --git a/.vib/owncloud/cypress/cypress/support/index.js b/.vib/owncloud/cypress/cypress/support/index.js new file mode 100644 index 0000000000..37a498fb5b --- /dev/null +++ b/.vib/owncloud/cypress/cypress/support/index.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands'; + +// Alternatively you can use CommonJS syntax: +// require('./commands') diff --git a/.vib/owncloud/goss/goss.yaml b/.vib/owncloud/goss/goss.yaml new file mode 100644 index 0000000000..b30c5ba115 --- /dev/null +++ b/.vib/owncloud/goss/goss.yaml @@ -0,0 +1,26 @@ +command: + user-id-test: + exec: if [ "$(id -u)" -eq 0 ]; then exit 1; fi + exit-status: 0 + stdout: [] + stderr: [] +file: + /opt/bitnami/apache/conf/extra/httpd-manual.conf: + mode: "0664" + filetype: file + exists: true + /opt/bitnami/mysql: + mode: "0755" + filetype: directory + exists: true + /bitnami/owncloud/data: + mode: "0770" + filetype: directory + exists: true + /opt/bitnami/owncloud/config/config.php: + mode: "0777" + filetype: symlink + exists: true + contains: + - {{ printf "/dbuser.*%s/" .Env.OWNCLOUD_DATABASE_USER }} + - {{ printf "/dbpassword.*%s/" .Env.OWNCLOUD_DATABASE_PASSWORD }} diff --git a/.vib/owncloud/vib-publish.json b/.vib/owncloud/vib-publish.json index bc4bc28fb1..82cb9be3bf 100644 --- a/.vib/owncloud/vib-publish.json +++ b/.vib/owncloud/vib-publish.json @@ -17,14 +17,57 @@ ] }, "verify": { + "context": { + "resources": { + "url": "{SHA_ARCHIVE}", + "path": "/bitnami/owncloud" + }, + "runtime_parameters": "b3duY2xvdWRIb3N0OiB2bXdhcmUtb3duY2xvdWQubXkKb3duY2xvdWRVc2VybmFtZTogdXNlcgpvd25jbG91ZFBhc3N3b3JkOiBDb21wbGljYXRlZFBhc3N3b3JkMTIzITQKb3duY2xvdWRFbWFpbDogdGVzdEBleGFtcGxlLmNvbQpzZXJ2aWNlOgogIHR5cGU6IExvYWRCYWxhbmNlcgogIHBvcnRzOgogICAgaHR0cDogODAKc210cEhvc3Q6IHNtdHB0ZXN0aG9zdApzbXRwUG9ydDogOTgyMQpzbXRwVXNlcjogc210cFVzZXIKc210cFBhc3N3b3JkOiBzbXRwQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0", + "target_platform": { + "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", + "size": { + "name": "M4" + } + } + }, "actions": [ { "action_id": "trivy", "params": { "threshold": "CRITICAL", - "vuln_type": [ - "OS" - ] + "vuln_type": ["OS"] + } + }, + { + "action_id": "health-check", + "params": { + "endpoint": "lb-owncloud-http", + "app_protocol": "HTTP" + } + }, + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib/owncloud/goss" + }, + "remote": { + "workload": "deploy-owncloud" + } + } + }, + { + "action_id": "cypress", + "params": { + "resources": { + "path": "/.vib/owncloud/cypress" + }, + "endpoint": "lb-owncloud-http", + "app_protocol": "HTTP", + "env": { + "username": "user", + "password": "ComplicatedPassword123!4" + } } } ] diff --git a/.vib/owncloud/vib-verify.json b/.vib/owncloud/vib-verify.json index 49782fc04a..e5cd795d3a 100644 --- a/.vib/owncloud/vib-verify.json +++ b/.vib/owncloud/vib-verify.json @@ -17,6 +17,19 @@ ] }, "verify": { + "context": { + "resources": { + "url": "{SHA_ARCHIVE}", + "path": "/bitnami/owncloud" + }, + "runtime_parameters": "b3duY2xvdWRIb3N0OiB2bXdhcmUtb3duY2xvdWQubXkKb3duY2xvdWRVc2VybmFtZTogdXNlcgpvd25jbG91ZFBhc3N3b3JkOiBDb21wbGljYXRlZFBhc3N3b3JkMTIzITQKb3duY2xvdWRFbWFpbDogdGVzdEBleGFtcGxlLmNvbQpzZXJ2aWNlOgogIHR5cGU6IExvYWRCYWxhbmNlcgogIHBvcnRzOgogICAgaHR0cDogODAKc210cEhvc3Q6IHNtdHB0ZXN0aG9zdApzbXRwUG9ydDogOTgyMQpzbXRwVXNlcjogc210cFVzZXIKc210cFBhc3N3b3JkOiBzbXRwQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0", + "target_platform": { + "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", + "size": { + "name": "M4" + } + } + }, "actions": [ { "action_id": "trivy", @@ -24,6 +37,38 @@ "threshold": "CRITICAL", "vuln_type": ["OS"] } + }, + { + "action_id": "health-check", + "params": { + "endpoint": "lb-owncloud-http", + "app_protocol": "HTTP" + } + }, + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib/owncloud/goss" + }, + "remote": { + "workload": "deploy-owncloud" + } + } + }, + { + "action_id": "cypress", + "params": { + "resources": { + "path": "/.vib/owncloud/cypress" + }, + "endpoint": "lb-owncloud-http", + "app_protocol": "HTTP", + "env": { + "username": "user", + "password": "ComplicatedPassword123!4" + } + } } ] }