From 3b422d06ac20815e226ac1cfa5672fb0d3d078d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20de=20Paz=20Gal=C3=A1n?= Date: Tue, 2 Aug 2022 16:41:53 +0200 Subject: [PATCH] [bitnami/harbor] Revisit Goss/Cypress tests (#11502) * [bitnami/harbor] Revisit Goss/Cypress tests Signed-off-by: FraPazGal * Remove local testing folder Signed-off-by: FraPazGal * Modify goss tests and update runtime_params Signed-off-by: FraPazGal --- .../cypress/integration/harbor_spec.js | 35 +++++++----------- .vib/harbor/goss/goss-portal/goss.yaml | 36 ------------------- .vib/harbor/goss/goss-registry/goss.yaml | 27 -------------- .vib/harbor/goss/goss.yaml | 20 +++++++++++ .vib/harbor/goss/vars.yaml | 9 +++++ .vib/harbor/vib-publish.json | 18 +++------- .vib/harbor/vib-verify.json | 18 +++------- 7 files changed, 49 insertions(+), 114 deletions(-) delete mode 100644 .vib/harbor/goss/goss-portal/goss.yaml delete mode 100644 .vib/harbor/goss/goss-registry/goss.yaml create mode 100644 .vib/harbor/goss/goss.yaml create mode 100644 .vib/harbor/goss/vars.yaml diff --git a/.vib/harbor/cypress/cypress/integration/harbor_spec.js b/.vib/harbor/cypress/cypress/integration/harbor_spec.js index 9f4ce77581..853b7a190e 100644 --- a/.vib/harbor/cypress/cypress/integration/harbor_spec.js +++ b/.vib/harbor/cypress/cypress/integration/harbor_spec.js @@ -1,20 +1,12 @@ /// import { random } from '../support/utils'; -it('allows user to log in and log out', () => { - cy.login(); - cy.contains('Invalid user name or password').should('not.exist'); - cy.contains('button', 'admin').click(); - cy.contains('Log Out').click(); - cy.get('#login_username'); -}); - it('allows creating a project', () => { cy.login(); cy.visit('/harbor/projects'); cy.fixture('projects').then((project) => { - cy.contains('button', 'New Project').click(); - cy.get('#create_project_name').type(`${project.newProject.name}-${random}`); + cy.contains('New Project').click(); + cy.get('[id*="project_name"]').type(`${project.newProject.name}-${random}`); cy.contains('button', 'OK').should('not.be.disabled').click(); cy.contains('Created project successfully'); }); @@ -24,28 +16,31 @@ it('allows creating a registry', () => { cy.login(); cy.visit('/harbor/registries'); cy.fixture('registries').then((registry) => { - cy.contains('button', 'New Endpoint').click(); + cy.contains('New Endpoint').click(); cy.get('#adapter').select(`${registry.newRegistry.provider}`); cy.get('#destination_name').type(`${registry.newRegistry.name}-${random}`); + cy.contains('Test Connection').should('not.be.disabled').click(); + cy.contains('Connection tested successfully'); cy.contains('button', 'OK').should('not.be.disabled').click(); cy.contains('.datagrid-table', `${registry.newRegistry.name}-${random}`); }); }); it('allows launching a vulnerability scan', () => { - const IMAGE_SCANNER = 'Trivy'; cy.login(); cy.visit('/harbor/interrogation-services/scanners'); - cy.contains('.datagrid-table', IMAGE_SCANNER); - cy.contains('a', 'Vulnerability').click(); + cy.contains('.datagrid-row', 'Trivy').within(() => { + cy.contains('Enabled'); + }); + cy.contains('Vulnerability').click(); cy.contains('SCAN NOW').click(); cy.contains('Trigger scan all successfully'); }); -it('checks system configurations endpoint', () => { +it('checks every subcomponent status', () => { cy.request({ method: 'GET', - url: '/api/v2.0/configurations', + url: '/api/v2.0/health', form: true, auth: { username: Cypress.env('username'), @@ -53,12 +48,6 @@ it('checks system configurations endpoint', () => { }, }).then((response) => { expect(response.status).to.eq(200); - expect(response.body).to.include.all.keys( - 'auth_mode', - 'email_host', - 'project_creation_restriction', - 'scan_all_policy', - 'self_registration' - ); + expect(response.body.status).to.eq('healthy'); }); }); diff --git a/.vib/harbor/goss/goss-portal/goss.yaml b/.vib/harbor/goss/goss-portal/goss.yaml deleted file mode 100644 index d02209d035..0000000000 --- a/.vib/harbor/goss/goss-portal/goss.yaml +++ /dev/null @@ -1,36 +0,0 @@ -file: - # Checks basic index.html exists - /opt/bitnami/harbor/index.html: - exists: true - filetype: file - mode: "0644" - owner: root - group: root - # Checks server configuration exists - /opt/bitnami/nginx/conf/nginx.conf: - exists: true - filetype: file - mode: "0644" - owner: root - # Checks API documentation exists - /opt/bitnami/harbor/swagger.json: - exists: true - filetype: file - mode: "0644" - owner: root - group: root -http: - # Checks Harbor Portal and every subcomponent status - http://localhost:8080/api/v2.0/health: - method: GET - status: 200 - body: - - "!unhealthy" -command: - # Checks the user running the container is non-root - user-id-test: - exec: id -u - exit-status: 0 - stdout: - - 1001 - stderr: [] diff --git a/.vib/harbor/goss/goss-registry/goss.yaml b/.vib/harbor/goss/goss-registry/goss.yaml deleted file mode 100644 index 5c91e8a8e4..0000000000 --- a/.vib/harbor/goss/goss-registry/goss.yaml +++ /dev/null @@ -1,27 +0,0 @@ -file: - # Checks basic filesystem and binary related to registry management exists - /var/lib/registry: - exists: true - filetype: directory - mode: "0775" - owner: root - group: root - /storage: - exists: true - filetype: directory - mode: "2775" - owner: root - /opt/bitnami/harbor-registry/bin/registry: - exists: true - filetype: file - mode: "0755" - owner: root - group: root -command: - # Checks the user running the container is non-root - user-id-test: - exec: id -u - exit-status: 0 - stdout: - - 1001 - stderr: [] diff --git a/.vib/harbor/goss/goss.yaml b/.vib/harbor/goss/goss.yaml new file mode 100644 index 0000000000..e49ac757bb --- /dev/null +++ b/.vib/harbor/goss/goss.yaml @@ -0,0 +1,20 @@ +file: + /etc/registry/config.yml: + exists: true + filetype: file + mode: "0644" + owner: root + contains: + - "level: {{ .Vars.logLevel }}" + - "rootdirectory: {{ .Vars.persistence.imageChartStorage.filesystem.rootdirectory }}" + - "addr: localhost:{{ .Vars.registry.server.containerPorts.debug }}" + {{ .Vars.persistence.imageChartStorage.filesystem.rootdirectory }}: + exists: true + filetype: directory + mode: "2775" + owner: root + /etc/registry/root.crt: + exists: true + filetype: file + mode: "0644" + owner: root diff --git a/.vib/harbor/goss/vars.yaml b/.vib/harbor/goss/vars.yaml new file mode 100644 index 0000000000..3183d9a67c --- /dev/null +++ b/.vib/harbor/goss/vars.yaml @@ -0,0 +1,9 @@ +logLevel: debug +persistence: + imageChartStorage: + filesystem: + rootdirectory: /storage +registry: + server: + containerPorts: + debug: 5001 diff --git a/.vib/harbor/vib-publish.json b/.vib/harbor/vib-publish.json index 3fd1328b9e..6101a8d7ac 100644 --- a/.vib/harbor/vib-publish.json +++ b/.vib/harbor/vib-publish.json @@ -22,7 +22,7 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/harbor" }, - "runtime_parameters": "ImFkbWluUGFzc3dvcmQiOiAiQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0IgoiZXhwb3N1cmVUeXBlIjogInByb3h5IgoicG9zdGdyZXNxbCI6CiAgImF1dGgiOgogICAgInBvc3RncmVzUGFzc3dvcmQiOiAiN2RNeExmY3F4TiIKInNlcnZpY2UiOgogICJwb3J0cyI6CiAgICAiaHR0cCI6IDgwCiAgInR5cGUiOiAiTG9hZEJhbGFuY2VyIgo=", + "runtime_parameters": "YWRtaW5QYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0CmV4cG9zdXJlVHlwZTogcHJveHkKc2VydmljZToKICBwb3J0czoKICAgIGh0dHBzOiA0NDMKICB0eXBlOiBMb2FkQmFsYW5jZXIKbG9nTGV2ZWw6IGRlYnVnCnBlcnNpc3RlbmNlOgogIGltYWdlQ2hhcnRTdG9yYWdlOgogICAgZmlsZXN5c3RlbToKICAgICAgcm9vdGRpcmVjdG9yeTogL3N0b3JhZ2UKcmVnaXN0cnk6CiAgc2VydmVyOgogICAgY29udGFpbmVyUG9ydHM6CiAgICAgIGRlYnVnOiA1MDAx", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { @@ -42,22 +42,12 @@ "action_id": "goss", "params": { "resources": { - "path": "/.vib/harbor/goss/goss-portal" - }, - "remote": { - "workload": "deploy-harbor-portal" - } - } - }, - { - "action_id": "goss", - "params": { - "resources": { - "path": "/.vib/harbor/goss/goss-registry" + "path": "/.vib/harbor/goss" }, "remote": { "workload": "deploy-harbor-registry" - } + }, + "vars_file": "vars.yaml" } }, { diff --git a/.vib/harbor/vib-verify.json b/.vib/harbor/vib-verify.json index 8ddac48564..3276f4b3de 100644 --- a/.vib/harbor/vib-verify.json +++ b/.vib/harbor/vib-verify.json @@ -22,7 +22,7 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/harbor" }, - "runtime_parameters": "ImFkbWluUGFzc3dvcmQiOiAiQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0IgoiZXhwb3N1cmVUeXBlIjogInByb3h5IgoicG9zdGdyZXNxbCI6CiAgImF1dGgiOgogICAgInBvc3RncmVzUGFzc3dvcmQiOiAiN2RNeExmY3F4TiIKInNlcnZpY2UiOgogICJwb3J0cyI6CiAgICAiaHR0cCI6IDgwCiAgInR5cGUiOiAiTG9hZEJhbGFuY2VyIgo=", + "runtime_parameters": "YWRtaW5QYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0CmV4cG9zdXJlVHlwZTogcHJveHkKc2VydmljZToKICBwb3J0czoKICAgIGh0dHBzOiA0NDMKICB0eXBlOiBMb2FkQmFsYW5jZXIKbG9nTGV2ZWw6IGRlYnVnCnBlcnNpc3RlbmNlOgogIGltYWdlQ2hhcnRTdG9yYWdlOgogICAgZmlsZXN5c3RlbToKICAgICAgcm9vdGRpcmVjdG9yeTogL3N0b3JhZ2UKcmVnaXN0cnk6CiAgc2VydmVyOgogICAgY29udGFpbmVyUG9ydHM6CiAgICAgIGRlYnVnOiA1MDAx", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { @@ -42,22 +42,12 @@ "action_id": "goss", "params": { "resources": { - "path": "/.vib/harbor/goss/goss-portal" - }, - "remote": { - "workload": "deploy-harbor-portal" - } - } - }, - { - "action_id": "goss", - "params": { - "resources": { - "path": "/.vib/harbor/goss/goss-registry" + "path": "/.vib/harbor/goss" }, "remote": { "workload": "deploy-harbor-registry" - } + }, + "vars_file": "vars.yaml" } }, {