Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { visit } from '../../../helpers/visit';
import {
fillAndSubmitExceptionForm,
selectSingleCveForException,
verifyExceptionConfirmationDetails,
verifySelectedCvesInModal,
visitWorkloadCveOverview,
} from '../workloadCves/WorkloadCves.helpers';
import { selectors as workloadCVESelectors } from '../workloadCves/WorkloadCves.selectors';
import { selectors as vulnSelectors } from '../vulnerabilities.selectors';

const basePath = '/main/vulnerabilities/exception-management';
export const pendingRequestsPath = `${basePath}/pending-requests`;
Expand All @@ -9,3 +18,41 @@ export function visitExceptionManagement() {
cy.get('h1:contains("Exception management")');
cy.location('pathname').should('eq', pendingRequestsPath);
}

export function deferAndVisitRequestDetails({
comment,
expiry,
scope,
}: {
comment: string;
expiry: string;
scope: string;
}) {
visitWorkloadCveOverview();
cy.get(vulnSelectors.clearFiltersButton).click(); // Note: This is a workaround to prevent a lack of CVE data from causing the test to fail in CI

// defer a single cve
selectSingleCveForException('DEFERRAL').then((cveName) => {
verifySelectedCvesInModal([cveName]);
fillAndSubmitExceptionForm({
comment,
expiryLabel: expiry,
});
verifyExceptionConfirmationDetails({
expectedAction: 'Deferral',
cves: [cveName],
scope,
expiry,
});
cy.get(workloadCVESelectors.copyToClipboardButton).click();
cy.get(workloadCVESelectors.copyToClipboardTooltipText).contains('Copied');
// @TODO: Can make this into a custom cypress command (ie. getClipboardText)
cy.window()
.then((win) => {
return win.navigator.clipboard.readText();
})
.then((url) => {
visit(url);
});
});
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import withAuth from '../../../helpers/basicAuth';
import { hasFeatureFlag } from '../../../helpers/features';
import {
cancelAllCveExceptions,
fillAndSubmitExceptionForm,
selectSingleCveForException,
verifyExceptionConfirmationDetails,
verifySelectedCvesInModal,
visitWorkloadCveOverview,
} from '../workloadCves/WorkloadCves.helpers';
import { selectors as workloadCVESelectors } from '../workloadCves/WorkloadCves.selectors';
import { selectors as vulnSelectors } from '../vulnerabilities.selectors';
import { visit } from '../../../helpers/visit';
import { pendingRequestsPath } from './ExceptionManagement.helpers';
import { cancelAllCveExceptions } from '../workloadCves/WorkloadCves.helpers';
import { deferAndVisitRequestDetails, pendingRequestsPath } from './ExceptionManagement.helpers';

const deferralComment = 'Defer me';
const deferralExpiry = 'When all CVEs are fixable';
const deferralScope = 'All images';
const comment = 'Defer me';
const expiry = 'When all CVEs are fixable';
const scope = 'All images';

describe('Exception Management Request Details Page', () => {
withAuth();
Expand All @@ -37,33 +27,10 @@ describe('Exception Management Request Details Page', () => {
hasFeatureFlag('ROX_WORKLOAD_CVES_FIXABILITY_FILTERS')
) {
cancelAllCveExceptions();

visitWorkloadCveOverview();
cy.get(vulnSelectors.clearFiltersButton).click(); // Note: This is a workaround to prevent a lack of CVE data from causing the test to fail in CI

// defer a single cve
selectSingleCveForException('DEFERRAL').then((cveName) => {
verifySelectedCvesInModal([cveName]);
fillAndSubmitExceptionForm({
comment: deferralComment,
expiryLabel: deferralExpiry,
});
verifyExceptionConfirmationDetails({
expectedAction: 'Deferral',
cves: [cveName],
scope: deferralScope,
expiry: deferralExpiry,
});
cy.get(workloadCVESelectors.copyToClipboardButton).click();
cy.get(workloadCVESelectors.copyToClipboardTooltipText).contains('Copied');
// @TODO: Can make this into a custom cypress command (ie. getClipboardText)
cy.window()
.then((win) => {
return win.navigator.clipboard.readText();
})
.then((url) => {
visit(url);
});
deferAndVisitRequestDetails({
comment,
expiry,
scope,
});
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import withAuth from '../../../helpers/basicAuth';
import { hasFeatureFlag } from '../../../helpers/features';
import { getInputByLabel } from '../../../helpers/formHelpers';
import { cancelAllCveExceptions } from '../workloadCves/WorkloadCves.helpers';
import { deferAndVisitRequestDetails } from './ExceptionManagement.helpers';

const comment = 'Defer me';
const expiry = 'When all CVEs are fixable';
const scope = 'All images';

describe('Exception Management Request Details Page', () => {
withAuth();

before(function () {
if (
!hasFeatureFlag('ROX_VULN_MGMT_WORKLOAD_CVES') ||
!hasFeatureFlag('ROX_VULN_MGMT_UNIFIED_CVE_DEFERRAL') ||
!hasFeatureFlag('ROX_WORKLOAD_CVES_FIXABILITY_FILTERS')
) {
this.skip();
}
});

beforeEach(() => {
if (
hasFeatureFlag('ROX_VULN_MGMT_WORKLOAD_CVES') &&
hasFeatureFlag('ROX_VULN_MGMT_UNIFIED_CVE_DEFERRAL') &&
hasFeatureFlag('ROX_WORKLOAD_CVES_FIXABILITY_FILTERS')
) {
cancelAllCveExceptions();
deferAndVisitRequestDetails({
comment,
expiry,
scope,
});
}
});

after(() => {
if (
hasFeatureFlag('ROX_VULN_MGMT_WORKLOAD_CVES') &&
hasFeatureFlag('ROX_VULN_MGMT_UNIFIED_CVE_DEFERRAL') &&
hasFeatureFlag('ROX_WORKLOAD_CVES_FIXABILITY_FILTERS')
) {
cancelAllCveExceptions();
}
});

it('should be able to deny a request if approval permissions are granted', () => {
cy.get('button:contains("Deny request")').click();
cy.get('div[role="dialog"]').should('exist');
getInputByLabel('Denial rationale').type('Denied');
cy.get('div[role="dialog"] button:contains("Deny")').click();
cy.get('div[role="dialog"]').should('not.exist');
cy.get('div[aria-label="Success Alert"]').should(
'contain',
'The vulnerability request was successfully denied.'
);
});

it('should be able to see how many CVEs will be affected by a denial', () => {
cy.get('table tbody tr:not(".pf-c-table__expandable-row")').then((rows) => {
const numCVEs = rows.length;
cy.get('button:contains("Deny request")').click();
cy.get('div[role="dialog"]').should('exist');
cy.get(`div:contains("CVE count: ${numCVEs}")`).should('exist');
});
});
});