Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Blue team test updates (#123)
Browse files Browse the repository at this point in the history
* Added blue team tests to verify that comments cannot be favorited, that presentation mode navigation works, and that the redacted toggle works. Added another test to hide-show-beacon test to check hiding beacon from kebab menu.

* Add blue and red team tests to verify redacted mode. Add blue team test to verify fields in Meta tab are disabled. Add associated data selectors and commands.

* Update blue team Meta tab test.

* Update timeline and mult-command comment tests to address GitHub test failures.

* Add new test to check raw logs in blue team mode.

* Update hide-show-beacon test to separate different functionality being tested.

* Update "hide-last-server" red team test to streamline.
  • Loading branch information
ccarpenter28 authored and GoldingAustin committed Apr 12, 2023
1 parent a1cb5f5 commit a27798d
Show file tree
Hide file tree
Showing 11 changed files with 374 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const BeaconMeta = observer((props) => {
fill
>
<Button
cy-test="type-dropdown"
disabled={!!store.appMeta.blueTeam}
text={state.selectedItem}
alignText="left"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// <reference types="cypress" />

describe('Cannot add comments to Favorites', () => {
const camp = 'favcomments';
const fileName = 'gt.redeye';

it('Favorite comment button should be disabled', () => {
cy.uploadCampaignBlue(camp, fileName);

cy.selectCampaign(camp);

cy.clickCommentsTab();

cy.get('[cy-test=fav-comment]').should('be.disabled');
});

after(() => {
cy.deleteCampaignGraphQL(camp);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,49 @@ describe('Hide a beacon', () => {
const camp = 'hideshowbeacon';
const fileName = 'gt.redeye';

it('Hide beacon using toggle in left nav panel', () => {
it('Toggle hide/show switch using left nav panel', () => {
cy.uploadCampaignBlue(camp, fileName);

// Search for new campaign by name
cy.selectCampaign(camp);

// Toggle off switch for hidden beacons
cy.get('[cy-test=settings]').click();
cy.doNotShowHiddenItems();

cy.get('[cy-test=show-hide-beacons]').uncheck({ force: true });
// Toggle switch back on
cy.showHiddenItems();
});

cy.closeRawLogs();
it('Toggle hide/show switch from main page', () => {
// Toggle off switch for hidden beacons
cy.doNotShowHiddenItems();

cy.clickBeaconsTab();
// Toggle switch back on
cy.showHiddenItems();
});

// Verify unable to hide/show new beacons/host
cy.get('[data-test-id=virtuoso-item-list] [cy-test=beacons-row]').eq(0).click();
it('Verify Hide button is disabled in Meta tab', () => {
// Search for new campaign by name
cy.selectCampaign(camp);

// Go to Beacons tab; open first beacon; go to Meta tab
cy.clickBeaconsTab();
cy.get('[cy-test=beacons-row]').eq(0).click();
cy.clickMetaTab();

// Verify unable to hide/show new beacons/host
cy.get('[cy-test=show-hide-this-beacon]').should('be.disabled');
});

it('Hide beacon using toggle on main page', () => {
// Toggle off switch for hidden beacons
cy.get('[cy-test=settings]').click();

cy.get('[cy-test=show-hide-beacons]').check({ force: true });

cy.closeRawLogs();

cy.get('[cy-test=settings]').click();
// THIS TEST IS PENDING A BUG FIX (TICKET #580)
it.skip('Verify Hide option is disabled in kebab menu', () => {
// Open campaign
cy.selectCampaign(camp);

cy.get('[cy-test=show-hide-beacons]').uncheck({ force: true });
// Navigate to the Beacons tab and open kebab menu for first beacon
cy.clickBeaconsTab();
cy.get('[cy-test=quick-meta-button]').eq(0).click();
cy.get('[cy-test=show-hide-item]').should('be.disabled');
});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// <reference types="cypress" />

describe('Meta tab fields disabled', () => {
const camp = 'metatab';
const fileName = 'gt.redeye';

it('Cannot update beacon info via Meta tab', () => {
// Upload campaign and open
cy.uploadCampaignBlue(camp, fileName);

cy.selectCampaign(camp);

// Go to Beacons tab
cy.clickBeaconsTab();

// Select beacon and go to Meta tab
cy.get('[cy-test=beacons-row]').eq(0).click();
cy.clickMetaTab();

// Verify Display Name, TOD, and Type fields are disabled
cy.get('[cy-test=beacon-display-name]').should('be.disabled');
cy.get('[cy-test=save-beacon-time-of-death]').should('be.disabled');
cy.get('[cy-test=type-dropdown]').should('be.disabled');
});

after(() => {
cy.deleteCampaignGraphQL(camp);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/// <reference types="cypress" />

describe('Presentation Mode Navigation', () => {
const camp = 'presentationmode';
const fileName = 'gt.redeye';

it('Can navigate forward and backward in Presentation Mode', () => {
// Upload and open campaign
cy.uploadCampaignBlue(camp, fileName);
cy.selectCampaign(camp);

// Go to Presentation Mode
cy.clickPresentationMode();

// Click "All Comments" to open presentation
cy.get('[cy-test=all]').click();

// Verify back button is disabled, Next button is enabled
cy.get('[cy-test=previous-slide]').should('be.disabled');
cy.get('[cy-test=next-slide]').should('be.enabled');

// Verify slide count starts at 1; log comment text
cy.get('[cy-test=slide-selector]').invoke('text').should('equal', '1');
cy.get('[cy-test=presentation-item]')
.invoke('text')
.then((slide1) => {
// Click "Next" three times
cy.get('[cy-test=next-slide]').click().click().click();

// Verify now on slide 4; previous/next buttons are enabled; verify comment text changed
cy.get('[cy-test=slide-selector]').invoke('text').should('equal', '4');
cy.get('[cy-test=previous-slide]').should('be.enabled');
cy.get('[cy-test=next-slide]').should('be.enabled');
cy.get('[cy-test=presentation-item]')
.invoke('text')
.then((slide4) => {
expect(slide4).to.not.equal(slide1);

// Click back button twice
cy.get('[cy-test=previous-slide]').click().click();

// Verify now on slide 2; previous/next buttons are enabled; verify comment text changed
cy.get('[cy-test=slide-selector]').invoke('text').should('equal', '2');
cy.get('[cy-test=previous-slide]').should('be.enabled');
cy.get('[cy-test=next-slide]').should('be.enabled');
cy.get('[cy-test=presentation-item]')
.invoke('text')
.then((slide2) => {
expect(slide2).to.not.equal(slide4);
});
});
});
});

it('Last slide takes user back to Presentation list', () => {
// Open campaign
cy.selectCampaign(camp);

// Go to Presentation Mode
cy.clickPresentationMode();

// Click "All Comments" to open presentation
cy.get('[cy-test=all]').click();

// Get total number of slides; go to last slide
cy.get('[cy-test=total-slides]')
.invoke('text')
.then((text) => {
const totalSlides = text.split(' ')[1];
cy.get('[cy-test=slide-selector]').click();
cy.get('[cy-test=slide-number-selector]')
.eq(totalSlides - 1)
.click();
});

// Verify "Next" button now says "Finish"; click button
cy.get('[cy-test=next-slide]').should('contain', 'Finish');
cy.get('[cy-test=next-slide]').click();

// Verify you are taken back to Presentation list
cy.get('[cy-test=presentation-header-bar]').should('contain', 'Select a comment topic to present');
});

it('Can navigate to a specific slide using dropdown', () => {
// Open campaign
cy.selectCampaign(camp);

// Go to Presentation Mode
cy.clickPresentationMode();

// Click "All Comments" to open presentation
cy.get('[cy-test=all]').click();

// Select slide #3 from the dropdown options
cy.get('[cy-test=slide-selector]').click();
cy.get('[cy-test=slide-number-selector]').eq(2).click();

// Verify you are on slide #3
cy.get('[cy-test=slide-selector]').invoke('text').should('equal', '3');
});

it('Can switch between presentations using the back arrow', () => {
// Open campaign
cy.selectCampaign(camp);

// Go to Presentation Mode
cy.clickPresentationMode();

// Click "All Comments" to open presentation
cy.get('[cy-test=all]').click();

// Navigate through a few slides
cy.get('[cy-test=next-slide]').click().click().click();

// Click Back button to exit presentation
cy.get('[cy-test=back-to-presentations]').click();

// Open #PrivilegeEscalation presentation
cy.get('[cy-test=PrivilegeEscalation]').click();

// Verify correct presentation opened, starts at slide 1, and can navigate through slides
cy.get('[cy-test=presentation-name]').should('contain', '#PrivilegeEscalation');
cy.get('[cy-test=slide-selector]').invoke('text').should('equal', '1');
cy.get('[cy-test=next-slide]').click();
cy.get('[cy-test=slide-selector]').invoke('text').should('equal', '2');
cy.get('[cy-test=next-slide]').click();
cy.get('[cy-test=slide-selector]').invoke('text').should('equal', '3');
});

after(() => {
cy.deleteCampaignGraphQL(camp);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/// <reference types="cypress" />

describe('Redacted mode toggle', () => {
const camp = 'toggleredactedmode';
const fileName = 'gt.redeye';

it('Toggle Redacted mode within a campaign', () => {
cy.uploadCampaignBlue(camp, fileName);

cy.selectCampaign(camp);

cy.toggleRedacted();

cy.get('#root').should('have.css', 'font', '14px / 18.2px "Redacted Script"');

cy.toggleUnredacted();

cy.get('#root').should(
'have.css',
'font',
'14px / 18.2px "IBM Plex Sans", "Helvetica Neue", -apple-system, "Segoe UI", Arial, sans-serif'
);
});

it('Toggle Redacted mode from campaign menu', () => {
cy.toggleRedacted();

cy.get('#root').should('have.css', 'font', '14px / 18.2px "Redacted Script"');

cy.toggleUnredacted();

cy.get('#root').should(
'have.css',
'font',
'14px / 18.2px "IBM Plex Sans", "Helvetica Neue", -apple-system, "Segoe UI", Arial, sans-serif'
);
});

after(() => {
cy.deleteCampaignGraphQL(camp);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/// <reference types="cypress" />

function verifyRawLogs() {
cy.get('[cy-test=log-title]').should('be.visible');
cy.get('[cy-test=scroll-to-top]').should('be.visible');
cy.get('[cy-test=copyLogs]').should('be.visible');
cy.get('[cy-test=log]').should('be.visible');
cy.get('[cy-test=close-log]').should('be.visible');
}

describe('View Raw Logs', () => {
const camp = 'viewrawlogs';
const fileName = 'gt.redeye';

it('Can open/view raw logs from Commands', () => {
cy.uploadCampaignBlue(camp, fileName);

// Open campaign, go to Commands, select command
cy.selectCampaign(camp);
cy.clickCommandTypesTab();
cy.selectCommandType('ps');

// Expand first command
cy.get('[cy-test=info-row]').eq(0).click();
cy.wait(500);
cy.get('[cy-test=openRawLogs]').should('be.visible');

// Click "Show Raw Logs" link; verify log appears
cy.get('[cy-test=openRawLogs]').click();
verifyRawLogs();
});

it('Can open/view raw logs from Comments', () => {
// Open campaign; go to Comments
cy.selectCampaign(camp);
cy.clickCommentsTab();

// Click expandable row under first comment
cy.get('[cy-test=command-info]').eq(0).click();
cy.wait(500);
cy.get('[cy-test=openRawLogs]').should('be.visible');

// Click "Show Raw Logs" link; verify log appears
cy.get('[cy-test=openRawLogs]').click();
verifyRawLogs();
});

after(() => {
cy.deleteCampaignGraphQL(camp);
});
});
Loading

0 comments on commit a27798d

Please sign in to comment.