diff --git a/.github/workflows/cd-pipeline.yaml b/.github/workflows/cd-pipeline.yaml index b6aa664e5..a9ad94ce7 100644 --- a/.github/workflows/cd-pipeline.yaml +++ b/.github/workflows/cd-pipeline.yaml @@ -11,6 +11,7 @@ on: # rebuild any PRs and main branch changes - 'bitnami/consul/**' - 'bitnami/discourse/**' - 'bitnami/dokuwiki/**' + - 'bitnami/drupal/**' - 'bitnami/elasticsearch/**' - 'bitnami/etcd/**' - 'bitnami/external-dns/**' diff --git a/.vib/drupal/cypress/cypress.json b/.vib/drupal/cypress/cypress.json new file mode 100644 index 000000000..de78431f7 --- /dev/null +++ b/.vib/drupal/cypress/cypress.json @@ -0,0 +1,8 @@ +{ + "baseUrl": "http://localhost", + "env": { + "username": "test_user", + "password": "ComplicatedPassword123!4" + }, + "defaultCommandTimeout": 30000 +} diff --git a/.vib/drupal/cypress/cypress/fixtures/articles.json b/.vib/drupal/cypress/cypress/fixtures/articles.json new file mode 100644 index 000000000..68c210822 --- /dev/null +++ b/.vib/drupal/cypress/cypress/fixtures/articles.json @@ -0,0 +1,6 @@ +{ + "newArticle": { + "title": "newarticle", + "altText": "Alternative image text" + } +} diff --git a/.vib/drupal/cypress/cypress/fixtures/images/test_image.jpeg b/.vib/drupal/cypress/cypress/fixtures/images/test_image.jpeg new file mode 100644 index 000000000..1d2a61929 Binary files /dev/null and b/.vib/drupal/cypress/cypress/fixtures/images/test_image.jpeg differ diff --git a/.vib/drupal/cypress/cypress/integration/drupal_spec.js b/.vib/drupal/cypress/cypress/integration/drupal_spec.js new file mode 100644 index 000000000..b84b4778f --- /dev/null +++ b/.vib/drupal/cypress/cypress/integration/drupal_spec.js @@ -0,0 +1,15 @@ +/// +import { random } from '../support/utils'; + +it('allows creating an article with an image', () => { + cy.login(); + cy.visit('/node/add/article'); + cy.fixture('articles').then((article) => { + cy.get('.text-full[name*=title]').type(`${article.newArticle.title} ${random}`); + cy.get('[type=file]').selectFile('cypress/fixtures/images/test_image.jpeg', { force: true }); + cy.get('input[id*="alt"]').type(`${article.newArticle.altText}`); + cy.contains('Save').click(); + cy.visit('/admin/content'); + cy.contains(`${article.newArticle.title} ${random}`); + }) +}); diff --git a/.vib/drupal/cypress/cypress/support/commands.js b/.vib/drupal/cypress/cypress/support/commands.js new file mode 100644 index 000000000..5e7f7a581 --- /dev/null +++ b/.vib/drupal/cypress/cypress/support/commands.js @@ -0,0 +1,24 @@ +const COMMAND_DELAY = 2000; + +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.add( + 'login', + (username = Cypress.env('username'), password = Cypress.env('password')) => { + cy.visit('/user/login'); + cy.get('#edit-name').type(username); + cy.get('#edit-pass').type(password); + cy.contains('input', 'Log in').click(); + } +); + diff --git a/.vib/drupal/cypress/cypress/support/index.js b/.vib/drupal/cypress/cypress/support/index.js new file mode 100644 index 000000000..37a498fb5 --- /dev/null +++ b/.vib/drupal/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/drupal/cypress/cypress/support/utils.js b/.vib/drupal/cypress/cypress/support/utils.js new file mode 100644 index 000000000..f0217c977 --- /dev/null +++ b/.vib/drupal/cypress/cypress/support/utils.js @@ -0,0 +1,3 @@ +/// + +export let random = (Math.random() + 1).toString(36).substring(7); diff --git a/.vib/drupal/goss/goss.yaml b/.vib/drupal/goss/goss.yaml new file mode 100644 index 000000000..af7e6fe12 --- /dev/null +++ b/.vib/drupal/goss/goss.yaml @@ -0,0 +1,31 @@ +http: + https://drupal:{{ .Vars.service.ports.https }}: + status: 200 + allow-insecure: true +command: + check-user-info: + exec: id + exit-status: 0 + stdout: + - uid={{ .Vars.containerSecurityContext.runAsUser }} + - /groups=.*{{ .Vars.podSecurityContext.fsGroup }}/ +file: + /bitnami/drupal: + exists: true + filetype: directory + mode: '2775' + owner: root + /var/run/secrets/kubernetes.io/serviceaccount: + exists: {{ .Vars.serviceAccount.automountServiceAccountToken }} + filetype: directory + mode: "3777" + /etc/hosts: + exists: true + filetype: file + contains: + {{ range .Vars.hostAliases }} + {{ $ip := .ip }} + {{ range $host := .hostnames }} + - /{{ $ip }}.*{{ $host }}/ + {{ end }} + {{ end }} diff --git a/.vib/drupal/goss/vars.yaml b/.vib/drupal/goss/vars.yaml new file mode 100644 index 000000000..1401ab6eb --- /dev/null +++ b/.vib/drupal/goss/vars.yaml @@ -0,0 +1,13 @@ +service: + ports: + https: 444 +podSecurityContext: + fsGroup: 1002 +containerSecurityContext: + runAsUser: 1002 +serviceAccount: + automountServiceAccountToken: true +hostAliases: + - ip: 127.0.0.1 + hostnames: + - status.testhost diff --git a/.vib/drupal/vib-publish.json b/.vib/drupal/vib-publish.json index c51c87aaa..e4bae80d8 100644 --- a/.vib/drupal/vib-publish.json +++ b/.vib/drupal/vib-publish.json @@ -22,7 +22,7 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/drupal" }, - "runtime_parameters": "ImRydXBhbFBhc3N3b3JkIjogIlMzOUJLV2pTa2gi", + "runtime_parameters": "ZHJ1cGFsVXNlcm5hbWU6IHRlc3RfdXNlcgpkcnVwYWxQYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0Cm1hcmlhZGI6CiAgYXV0aDoKICAgIGRhdGFiYXNlOiB0ZXN0X2RydXBhbF9kYXRhYmFzZQogICAgdXNlcm5hbWU6IHRlc3RfZHJ1cGFsX3VzZXJuYW1lCiAgICBwYXNzd29yZDogdGVzdF9kcnVwYWxfcGFzc3dvcmQKY29udGFpbmVyUG9ydHM6CiAgaHR0cDogODA4MQogIGh0dHBzOiA4NDQ0CnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAogICAgaHR0cHM6IDQ0NApwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKaG9zdEFsaWFzZXM6CiAgLSBpcDogMTI3LjAuMC4xCiAgICBob3N0bmFtZXM6CiAgICAgIC0gc3RhdHVzLnRlc3Rob3N0CnNlcnZpY2VBY2NvdW50OgogIGF1dG9tb3VudFNlcnZpY2VBY2NvdW50VG9rZW46IHRydWU=", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { @@ -37,6 +37,32 @@ "endpoint": "lb-drupal-http", "app_protocol": "HTTP" } + }, + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib/drupal/goss" + }, + "remote": { + "workload": "deploy-drupal" + }, + "vars_file": "vars.yaml" + } + }, + { + "action_id": "cypress", + "params": { + "resources": { + "path": "/.vib/drupal/cypress" + }, + "endpoint": "lb-drupal-http", + "app_protocol": "HTTP", + "env": { + "username": "test_user", + "password": "ComplicatedPassword123!4" + } + } } ] }, diff --git a/.vib/drupal/vib-verify.json b/.vib/drupal/vib-verify.json index 07b09df6e..026095ef4 100644 --- a/.vib/drupal/vib-verify.json +++ b/.vib/drupal/vib-verify.json @@ -22,7 +22,7 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/drupal" }, - "runtime_parameters": "ImRydXBhbFBhc3N3b3JkIjogIlMzOUJLV2pTa2gi", + "runtime_parameters": "ZHJ1cGFsVXNlcm5hbWU6IHRlc3RfdXNlcgpkcnVwYWxQYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0Cm1hcmlhZGI6CiAgYXV0aDoKICAgIGRhdGFiYXNlOiB0ZXN0X2RydXBhbF9kYXRhYmFzZQogICAgdXNlcm5hbWU6IHRlc3RfZHJ1cGFsX3VzZXJuYW1lCiAgICBwYXNzd29yZDogdGVzdF9kcnVwYWxfcGFzc3dvcmQKY29udGFpbmVyUG9ydHM6CiAgaHR0cDogODA4MQogIGh0dHBzOiA4NDQ0CnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAogICAgaHR0cHM6IDQ0NApwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKaG9zdEFsaWFzZXM6CiAgLSBpcDogMTI3LjAuMC4xCiAgICBob3N0bmFtZXM6CiAgICAgIC0gc3RhdHVzLnRlc3Rob3N0CnNlcnZpY2VBY2NvdW50OgogIGF1dG9tb3VudFNlcnZpY2VBY2NvdW50VG9rZW46IHRydWU=", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { @@ -37,6 +37,32 @@ "endpoint": "lb-drupal-http", "app_protocol": "HTTP" } + }, + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib/drupal/goss" + }, + "remote": { + "workload": "deploy-drupal" + }, + "vars_file": "vars.yaml" + } + }, + { + "action_id": "cypress", + "params": { + "resources": { + "path": "/.vib/drupal/cypress" + }, + "endpoint": "lb-drupal-http", + "app_protocol": "HTTP", + "env": { + "username": "test_user", + "password": "ComplicatedPassword123!4" + } + } } ] }