diff --git a/.vib/ghost/cypress/cypress.json b/.vib/ghost/cypress/cypress.json index 8fe5cb5ce..6658e5fee 100644 --- a/.vib/ghost/cypress/cypress.json +++ b/.vib/ghost/cypress/cypress.json @@ -1,10 +1,11 @@ { "env": { - "email": "user@example.com", + "email": "vim-tests@example.com", + "username": "bitnamiTest", "password": "Complicated123!4" }, "hosts": { - "bitnami-ghost.my": "{{ TARGET_IP }}" + "vmware-ghost.my": "{{ TARGET_IP }}" }, "defaultCommandTimeout": 60000 } diff --git a/.vib/ghost/cypress/cypress/fixtures/images/post_image.png b/.vib/ghost/cypress/cypress/fixtures/images/post_image.png deleted file mode 100644 index 87ad739c0..000000000 Binary files a/.vib/ghost/cypress/cypress/fixtures/images/post_image.png and /dev/null differ diff --git a/.vib/ghost/cypress/cypress/fixtures/images/test_image.jpeg b/.vib/ghost/cypress/cypress/fixtures/images/test_image.jpeg new file mode 100644 index 000000000..1d2a61929 Binary files /dev/null and b/.vib/ghost/cypress/cypress/fixtures/images/test_image.jpeg differ diff --git a/.vib/ghost/cypress/cypress/fixtures/members.csv b/.vib/ghost/cypress/cypress/fixtures/members.csv deleted file mode 100644 index 1d1df6c2b..000000000 --- a/.vib/ghost/cypress/cypress/fixtures/members.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,products -624dbfbd02708a014290a2af,loic@example.com,Loic,Sample note,true,,,2022-04-06T16:28:45.000Z,,, -624dbfdb02708a014290a2b2,marina@example.com,Marina,Bitnami engineer,true,,,2022-04-06T16:29:15.000Z,,, \ No newline at end of file diff --git a/.vib/ghost/cypress/cypress/fixtures/pages.json b/.vib/ghost/cypress/cypress/fixtures/pages.json deleted file mode 100644 index 628756475..000000000 --- a/.vib/ghost/cypress/cypress/fixtures/pages.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "newPage": { - "title": "New trends", - "content": "Lorem ipsum dolor sit amet" - } -} \ No newline at end of file diff --git a/.vib/ghost/cypress/cypress/fixtures/posts.json b/.vib/ghost/cypress/cypress/fixtures/posts.json index ae1bd433f..17e13ccba 100644 --- a/.vib/ghost/cypress/cypress/fixtures/posts.json +++ b/.vib/ghost/cypress/cypress/fixtures/posts.json @@ -1,6 +1,6 @@ { "newPost": { - "title": "The beginning of a new journey", + "title": "journeys", "content": "I was amazed by the incredible views" } } \ No newline at end of file diff --git a/.vib/ghost/cypress/cypress/fixtures/user-settings.json b/.vib/ghost/cypress/cypress/fixtures/user-settings.json deleted file mode 100644 index 494a4dcdc..000000000 --- a/.vib/ghost/cypress/cypress/fixtures/user-settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "admin": { - "fullname": "Lars Sanchez", - "bio": "British and greek!" - } -} \ No newline at end of file diff --git a/.vib/ghost/cypress/cypress/integration/ghost_spec.js b/.vib/ghost/cypress/cypress/integration/ghost_spec.js index 95f7a1074..63b5aab6c 100644 --- a/.vib/ghost/cypress/cypress/integration/ghost_spec.js +++ b/.vib/ghost/cypress/cypress/integration/ghost_spec.js @@ -1,30 +1,21 @@ /// -import { - random, - getPageUrlFromTitle, - getUserFromEmail, -} from '../support/utils'; +import { random } from '../support/utils'; -it('allows to log in and out', () => { - cy.login(); - cy.get("div[class*='avatar']").click(); - cy.contains('Sign out').click(); - cy.contains('Sign in'); -}); - -it('allows to create and publish a new post', () => { +it('allows to create and publish a new post with an image', () => { cy.login(); cy.visit('/ghost/#/posts'); cy.contains('New post').click(); - cy.get('input[type="file"]').selectFile( - 'cypress/fixtures/images/post_image.png', + cy.get('[type="file"]').selectFile( + 'cypress/fixtures/images/test_image.jpeg', { force: true } ); - cy.fixture('posts').then(($posts) => { + cy.fixture('posts').then((posts) => { cy.get('textarea[placeholder="Post title"]').type( - `${$posts.newPost.title}-${random}` + `${posts.newPost.title}-${random}` ); - cy.get('article div[contenteditable="true"]').type(`${$posts.newPost.content}-${random}`, {force: true}); + cy.get('article div[contenteditable="true"]').type(posts.newPost.content, { + force: true, + }); }); // Publishing a post needs 3 steps // Step 1: Open drop-down menu @@ -37,86 +28,15 @@ it('allows to create and publish a new post', () => { cy.get('div[class=gh-publish-cta]').within(() => { cy.contains('Publish').click(); }); - cy.contains('It’s out there').should('be.visible'); - cy.visit('/'); - cy.fixture('posts').then(($posts) => { - cy.contains(`${$posts.newPost.title}-${random}`); - cy.get(`img[alt='${$posts.newPost.title}-${random}']`); - }); -}); - -it('allows to create a new page', () => { - cy.login(); - cy.visit('/ghost/#/pages'); - cy.contains('New page').click(); - cy.fixture('pages').then(($pages) => { - cy.get('textarea[placeholder="Page title"]').type( - `${$pages.newPage.title}-${random}` - ); - // Clicking a different element to trigger save event - cy.get('article').click() - cy.contains('div[class=gh-editor-post-status]', 'Saved'); - cy.get('article').type(`${$pages.newPage.content}-${random}`); - // Ensure content has been saved before publishing - cy.get('textarea[placeholder="Page title"]').click() - cy.contains('div[class=gh-editor-post-status]', 'Saved'); - }); - // Publishing a page needs 3 steps - // Step 1: Open drop down-menu - cy.contains('Publish').click(); - // Step 2: Select the option from the menu - cy.get('div[class=gh-publish-cta]').within(() => { - cy.contains('Continue').click(); - }); - // Step 3: Confirmation pop-up - cy.get('div[class=gh-publish-cta]').within(() => { - cy.contains('Publish').click(); - }); - cy.contains('It’s out there').should('be.visible'); - cy.fixture('pages').then(($pages) => { - cy.visit(getPageUrlFromTitle(`${$pages.newPage.title}-${random}`)); - cy.contains(`${$pages.newPage.title}-${random}`); - cy.contains(`${$pages.newPage.content}-${random}`); - }); -}); - -it('allows to import members', () => { - cy.login(); - cy.visit('/ghost/#/members/import'); - cy.contains('h1', 'Import members').should('be.visible'); - cy.get('input[type="file"]').selectFile('cypress/fixtures/members.csv', { - force: true, - }); - cy.contains('button', 'Import').click(); - cy.contains('Import complete'); - cy.visit('/ghost/#/members/'); - cy.fixture('members') - .then(($rawMembers) => { - // Get an arbitrary member from the collection - let membersArray = $rawMembers.split('\n'); - membersArray.shift(); // Delete CSV column header - return membersArray[Math.floor(Math.random() * membersArray.length)]; - }) - .then(($randomMember) => { - const EMAIL_COLUMN_CSV = 1; - cy.contains($randomMember.split(',')[EMAIL_COLUMN_CSV]); - }); -}); - -it('allows to change users settings', () => { - cy.login(); - cy.visit(`/ghost/#/settings/staff/${getUserFromEmail()}`); - cy.fixture('user-settings').then(($us) => { - cy.get('input#user-name') - .clear() - .type(`${$us.admin.fullname}-${random}`, { force: true }); - cy.get('textarea#user-bio') - .clear() - .type(`${$us.admin.bio}-${random}`, { force: true }); - cy.contains('button', 'Save').click(); - - cy.visit(`/author/${getUserFromEmail()}`); - cy.contains(`${$us.admin.fullname}-${random}`); - cy.contains(`${$us.admin.bio}-${random}`); + cy.fixture('posts').then((posts) => { + // Avoid new tab + cy.contains('a', `${posts.newPost.title}-${random}`) + .invoke('attr', 'href') + .then((url) => { + cy.visit(url); + cy.contains(Cypress.env('username')); + cy.contains(posts.newPost.content); + cy.get(`img[alt='${posts.newPost.title}-${random}']`); + }); }); }); diff --git a/.vib/ghost/cypress/cypress/support/commands.js b/.vib/ghost/cypress/cypress/support/commands.js index 85690c79f..df9927d15 100644 --- a/.vib/ghost/cypress/cypress/support/commands.js +++ b/.vib/ghost/cypress/cypress/support/commands.js @@ -1,5 +1,5 @@ const COMMAND_DELAY = 2000; -const BASE_URL = 'http://bitnami-ghost.my'; +const BASE_URL = 'http://vmware-ghost.my'; for (const command of ['click']) { Cypress.Commands.overwrite(command, (originalFn, ...args) => { @@ -19,20 +19,22 @@ for (const command of ['click']) { // // Further details: https://github.com/cypress-io/cypress/issues/20647 Cypress.Commands.overwrite('visit', (originalFn, url, options) => { - return originalFn(`${BASE_URL}${url}`, options); + // Only replace relative URLs + const targetUrl = url.includes('://') ? url : `${BASE_URL}${url}`; + return originalFn(targetUrl, options); }); Cypress.Commands.add( 'login', (email = Cypress.env('email'), password = Cypress.env('password')) => { cy.visit('/ghost/'); - cy.get('input[type="email"]').should('be.enabled').type(email); - cy.get('input[type="password"]').should('be.enabled').type(password); + cy.get('[type="email"]').type(email); + cy.get('[type="password"]').type(password); cy.contains('button', 'Sign in').click(); // In Ghost, logging is not considered as completed until the Dashboard view // is visible. Navigating to any other site before that will lead to an error // 500 - cy.contains('Dashboard').should('be.visible'); + cy.contains('h2', 'Dashboard').should('be.visible'); } ); diff --git a/.vib/ghost/cypress/cypress/support/utils.js b/.vib/ghost/cypress/cypress/support/utils.js index 7b80bf8e8..445a887ae 100644 --- a/.vib/ghost/cypress/cypress/support/utils.js +++ b/.vib/ghost/cypress/cypress/support/utils.js @@ -1,11 +1,3 @@ /// -export let random = (Math.random() + 1).toString(36).substring(7); - -export const getPageUrlFromTitle = (title) => { - return '/'.concat(title.toLocaleLowerCase().replace(' ', '-')); -}; - -export const getUserFromEmail = (email = Cypress.env('email')) => { - return email.substring(0, email.indexOf('@')); -}; +export let random = (Math.random() + 1).toString(36).substring(7); \ No newline at end of file diff --git a/.vib/ghost/goss/goss.yaml b/.vib/ghost/goss/goss.yaml index f95350f14..751508135 100644 --- a/.vib/ghost/goss/goss.yaml +++ b/.vib/ghost/goss/goss.yaml @@ -1,20 +1,27 @@ +http: + http://localhost:{{ .Vars.containerPorts.http }}: + status: 200 command: - which-ghost: - exec: which ghost +{{- $checkCmd := "ghost config get %s -d /opt/bitnami/ghost | grep -q %d" }} +{{- $dbCheck := printf $checkCmd "database.connection.database" .Vars.mysql.auth.database }} +{{- $userCheck := printf $checkCmd "database.connection.user" .Vars.mysql.auth.username }} +{{- $passCheck := printf $checkCmd "database.connection.password" .Vars.mysql.auth.password }} + check-db-config: + exec: ($dbCheck) && ($userCheck) && ($passCheck) + exit-status: 0 + check-user-info: + exec: id exit-status: 0 stdout: - - "/opt/bitnami/ghost/bin/ghost" - stderr: [ ] - timeout: 40000 + - uid={{ .Vars.containerSecurityContext.runAsUser }} + - /groups=.*{{ .Vars.podSecurityContext.fsGroup }}/ file: - /opt/bitnami/ghost/content: - filetype: symlink - linked-to: /bitnami/ghost/content - exists: true - /bitnami/ghost/config.production.json: - mode: "0644" - filetype: file - exists: true -user: - ghost: + /bitnami/ghost: exists: true + filetype: directory + mode: '2775' + owner: root + /var/run/secrets/kubernetes.io/serviceaccount: + exists: {{ .Vars.serviceAccount.automountServiceAccountToken }} + filetype: directory + mode: "3777" \ No newline at end of file diff --git a/.vib/ghost/goss/vars.yaml b/.vib/ghost/goss/vars.yaml new file mode 100644 index 000000000..d9073155f --- /dev/null +++ b/.vib/ghost/goss/vars.yaml @@ -0,0 +1,14 @@ +containerPorts: + http: 2369 +podSecurityContext: + fsGroup: 1002 +containerSecurityContext: + runAsUser: 1002 +mysql: + auth: + database: bitnami_test_ghost + username: bn_test_ghost + password: bitnami_test_password +serviceAccount: + create: true + automountServiceAccountToken: true \ No newline at end of file diff --git a/.vib/ghost/vib-publish.json b/.vib/ghost/vib-publish.json index 5242a06df..6eea7c23c 100644 --- a/.vib/ghost/vib-publish.json +++ b/.vib/ghost/vib-publish.json @@ -22,7 +22,7 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/ghost" }, - "runtime_parameters": "Z2hvc3RVc2VybmFtZTogdXNlcgpnaG9zdFBhc3N3b3JkOiBDb21wbGljYXRlZDEyMyE0Cmdob3N0RW1haWw6IHVzZXJAZXhhbXBsZS5jb20KZ2hvc3RIb3N0OiBiaXRuYW1pLWdob3N0Lm15CnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAo=", + "runtime_parameters": "Z2hvc3RVc2VybmFtZTogYml0bmFtaVRlc3QKZ2hvc3RQYXNzd29yZDogQ29tcGxpY2F0ZWQxMjMhNApnaG9zdEVtYWlsOiB2aW0tdGVzdHNAZXhhbXBsZS5jb20KZ2hvc3RIb3N0OiB2bXdhcmUtZ2hvc3QubXkKZ2hvc3RTa2lwSW5zdGFsbDogZmFsc2UKY29udGFpbmVyUG9ydHM6CiAgaHR0cDogMjM2OQpwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKc2VydmljZToKICB0eXBlOiBMb2FkQmFsYW5jZXIKICBwb3J0czoKICAgIGh0dHA6IDgwCm15c3FsOgogIGVuYWJsZWQ6IHRydWUKICBhdXRoOgogICAgZGF0YWJhc2U6IGJpdG5hbWlfdGVzdF9naG9zdAogICAgdXNlcm5hbWU6IGJuX3Rlc3RfZ2hvc3QKICAgIHBhc3N3b3JkOiBiaXRuYW1pX3Rlc3RfcGFzc3dvcmQKc2VydmljZUFjY291bnQ6CiAgY3JlYXRlOiB0cnVlCiAgYXV0b21vdW50U2VydmljZUFjY291bnRUb2tlbjogdHJ1ZQ==", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { @@ -44,6 +44,7 @@ "resources": { "path": "/.vib/ghost/goss" }, + "vars_file": "vars.yaml", "remote": { "workload": "deploy-ghost" } @@ -58,7 +59,8 @@ "endpoint": "lb-ghost-http", "app_protocol": "HTTP", "env": { - "email": "user@example.com", + "email": "vim-tests@example.com", + "username": "bitnamiTest", "password": "Complicated123!4" } } diff --git a/.vib/ghost/vib-verify.json b/.vib/ghost/vib-verify.json index 64e4adce7..c749d43e6 100644 --- a/.vib/ghost/vib-verify.json +++ b/.vib/ghost/vib-verify.json @@ -22,7 +22,7 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/ghost" }, - "runtime_parameters": "Z2hvc3RVc2VybmFtZTogdXNlcgpnaG9zdFBhc3N3b3JkOiBDb21wbGljYXRlZDEyMyE0Cmdob3N0RW1haWw6IHVzZXJAZXhhbXBsZS5jb20KZ2hvc3RIb3N0OiBiaXRuYW1pLWdob3N0Lm15CnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAo=", + "runtime_parameters": "Z2hvc3RVc2VybmFtZTogYml0bmFtaVRlc3QKZ2hvc3RQYXNzd29yZDogQ29tcGxpY2F0ZWQxMjMhNApnaG9zdEVtYWlsOiB2aW0tdGVzdHNAZXhhbXBsZS5jb20KZ2hvc3RIb3N0OiB2bXdhcmUtZ2hvc3QubXkKZ2hvc3RTa2lwSW5zdGFsbDogZmFsc2UKY29udGFpbmVyUG9ydHM6CiAgaHR0cDogMjM2OQpwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKc2VydmljZToKICB0eXBlOiBMb2FkQmFsYW5jZXIKICBwb3J0czoKICAgIGh0dHA6IDgwCm15c3FsOgogIGVuYWJsZWQ6IHRydWUKICBhdXRoOgogICAgZGF0YWJhc2U6IGJpdG5hbWlfdGVzdF9naG9zdAogICAgdXNlcm5hbWU6IGJuX3Rlc3RfZ2hvc3QKICAgIHBhc3N3b3JkOiBiaXRuYW1pX3Rlc3RfcGFzc3dvcmQKc2VydmljZUFjY291bnQ6CiAgY3JlYXRlOiB0cnVlCiAgYXV0b21vdW50U2VydmljZUFjY291bnRUb2tlbjogdHJ1ZQ==", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { @@ -44,6 +44,7 @@ "resources": { "path": "/.vib/ghost/goss" }, + "vars_file": "vars.yaml", "remote": { "workload": "deploy-ghost" } @@ -58,7 +59,8 @@ "endpoint": "lb-ghost-http", "app_protocol": "HTTP", "env": { - "email": "user@example.com", + "email": "vim-tests@example.com", + "username": "bitnamiTest", "password": "Complicated123!4" } }