From 79ace2a5a494fbdaf63f25272de1a67f607d98ca Mon Sep 17 00:00:00 2001 From: Satyajit Bulage Date: Fri, 31 Jan 2025 17:56:13 +0530 Subject: [PATCH 1/2] Automate GitJob security context test Signed-off-by: Satyajit Bulage --- tests/cypress/e2e/unit_tests/p0_fleet.spec.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts b/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts index a9e049f5..1da9e406 100644 --- a/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts +++ b/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts @@ -393,3 +393,41 @@ if (!/\/2\.7/.test(Cypress.env('rancher_version')) && !/\/2\.8/.test(Cypress.env ); }) }; + +if (!/\/2\.8/.test(Cypress.env('rancher_version')) && !/\/2\.9/.test(Cypress.env('rancher_version'))) { + describe('Test GitJob security context', { tags: '@p0' }, () => { + qase(160, + it('FLEET-160: Test GitJob pod security context', { tags: '@fleet-160' }, () => { + // Check the GitJob pod for Security Context. + cy.accesMenuSelection('local', 'Workloads', 'Pods'); + cy.filterInSearchBox('gitjob'); + cy.verifyTableRow(0, 'Running', 'gitjob'); + cy.contains('gitjob').click(); + cy.clickButton('Config'); + cy.get('section#container-0') + .find('.side-tabs ul.tabs li') + .eq(3) + .should('have.id', 'securityContext') + .should("be.visible") + .click() + + // Check Run as Non-Root + cy.get('input[name="runasNonRoot"]:checked') + .should('have.value', 'false'); + + // Check Privilege Escalation + cy.get('input[name="allowPrivilegeEscalation"]:checked') + .should('have.value', 'false'); + + // Check Read Only Root File System + cy.get('input[name="readOnlyRootFilesystem"]:checked') + .should('have.value', 'true'); + + // Check Drop Capabilities + cy.get('[data-testid="input-security-drop"] .labeled-select .v-select span.vs__selected') + .contains('ALL') + .should('be.visible') + }) + ); + }); +}; From 7179c707ce768f866822ee96da60646760727a31 Mon Sep 17 00:00:00 2001 From: Satyajit Bulage Date: Fri, 31 Jan 2025 22:44:09 +0530 Subject: [PATCH 2/2] Updated based on review Signed-off-by: Satyajit Bulage --- tests/cypress/e2e/unit_tests/p0_fleet.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts b/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts index 1da9e406..8ce5d5a0 100644 --- a/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts +++ b/tests/cypress/e2e/unit_tests/p0_fleet.spec.ts @@ -408,6 +408,7 @@ if (!/\/2\.8/.test(Cypress.env('rancher_version')) && !/\/2\.9/.test(Cypress.env .find('.side-tabs ul.tabs li') .eq(3) .should('have.id', 'securityContext') + .contains('Security Context') .should("be.visible") .click()