Skip to content

Commit

Permalink
kubevirt: add mac spoof check for nad
Browse files Browse the repository at this point in the history
  • Loading branch information
gouyang committed Nov 16, 2021
1 parent 72f2a27 commit 1ada012
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare global {
selectProject(project: string): void;
createNAD(namespace: string): void;
waitForLoginPrompt(vmName: string, namespace: string): void;
visitNAD(): void;
visitNADPage(): void;
}
}
}
Expand Down Expand Up @@ -178,6 +178,6 @@ Cypress.Commands.add('waitForLoginPrompt', (vmName: string, namespace: string) =
});
});

Cypress.Commands.add('visitNAD', () => {
Cypress.Commands.add('visitNADPage', () => {
cy.clickNavLink(['Networking', 'NetworkAttachmentDefinitions']);
});
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
import { K8S_KIND } from '../../utils/const/index';
import { createNAD, deleteNAD } from '../../views/nad';

const name = 'test-nad';
const name1 = 'nad-uncheck-macspoof';
const bridge = 'br0';
// TODO: Don't use default project after bz2023560 is fixed.
const testName = 'default';

describe('Test network attachment definition', () => {
before(() => {
cy.Login();
cy.visit('/');
});

it('ID(CNV-3256) Create NAD', () => {
beforeEach(() => {
cy.visitNADPage();
});

after(() => {
cy.deleteResource(K8S_KIND.NAD, name, testName);
cy.deleteResource(K8S_KIND.NAD, name1, testName);
});

it('ID(CNV-3256) Create NAD with MAC Spoof checked', () => {
createNAD(name, bridge);
cy.exec(`oc get net-attach-def ${name} -n ${testName} -o jsonpath={.spec.config}`).then(
(output) => {
const res = JSON.parse(output.stdout);
expect(res.macspoofchk).toEqual(true);
},
);
});

it('ID(CNV-7522) Create NAD with MAC Spoof unchecked', () => {
createNAD(name1, bridge, true);
cy.exec(`oc get net-attach-def ${name1} -n ${testName} -o jsonpath={.spec.config}`).then(
(output) => {
const res = JSON.parse(output.stdout);
expect(res.macspoofchk).toEqual(false);
},
);
});

it('ID(CNV-4288) Delete NAD', () => {
deleteNAD(name);
deleteNAD(name1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ export const deleteAction = '[data-test-action="Delete Network Attachment Defini
export const confirmBtn = '[data-test="confirm-action"]';
export const heading = '[data-test-section-heading="NetworkAttachmentDefinition details"]';
export const createBtn = '#save-changes';
export const macSpoofCHK = '#network-type-params-macspoofchk-checkbox';

export const createNAD = (name: string, bridge: string) => {
cy.visitNAD();
export const createNAD = (name: string, bridge: string, uncheckmacspoof?: boolean) => {
cy.byTestID('item-create').click();
cy.get(nameID)
.type(name)
.should('have.value', name);
cy.get(type).click();
cy.get(cnvBridgeLink).click();
cy.get(bridgeName).type(bridge);
if (uncheckmacspoof) {
cy.get(macSpoofCHK).click();
}
cy.get(createBtn).click();
cy.get(heading).should('exist');
};

export const deleteNAD = (name: string) => {
cy.visitNAD();
cy.contains(row, name)
.find(kebabBtn)
.click();
Expand Down

0 comments on commit 1ada012

Please sign in to comment.