From 7572187b79b989c2ca11c8a6e20f7d839e19b793 Mon Sep 17 00:00:00 2001
From: Courtney Carpenter <100231016+ccarpenter28@users.noreply.github.com>
Date: Tue, 11 Apr 2023 10:23:35 -0700
Subject: [PATCH] Blue team test updates (#123)
* 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.
---
.../Explore/Panels/Meta/BeaconMeta.tsx | 1 +
.../e2e/blueteam/favorite-comments.cy.js | 20 +++
.../e2e/blueteam/hide-show-beacon.cy.js | 43 +++---
.../integration/e2e/blueteam/meta-tab.cy.js | 29 ++++
.../presentation-mode-navigation.cy.js | 133 ++++++++++++++++++
.../e2e/blueteam/toggle-redacted.cy.js | 42 ++++++
.../e2e/blueteam/view-raw-logs.cy.js | 51 +++++++
.../e2e/redteam/hide-last-server.cy.js | 39 +++--
.../e2e/redteam/toggle-redacted.cy.js | 42 ++++++
.../redeye-e2e/src/support/campaignCard.js | 1 +
.../redeye-e2e/src/support/commands.js | 12 ++
11 files changed, 374 insertions(+), 39 deletions(-)
create mode 100644 applications/redeye-e2e/src/integration/e2e/blueteam/favorite-comments.cy.js
create mode 100644 applications/redeye-e2e/src/integration/e2e/blueteam/meta-tab.cy.js
create mode 100644 applications/redeye-e2e/src/integration/e2e/blueteam/presentation-mode-navigation.cy.js
create mode 100644 applications/redeye-e2e/src/integration/e2e/blueteam/toggle-redacted.cy.js
create mode 100644 applications/redeye-e2e/src/integration/e2e/blueteam/view-raw-logs.cy.js
create mode 100644 applications/redeye-e2e/src/integration/e2e/redteam/toggle-redacted.cy.js
diff --git a/applications/client/src/views/Campaign/Explore/Panels/Meta/BeaconMeta.tsx b/applications/client/src/views/Campaign/Explore/Panels/Meta/BeaconMeta.tsx
index 02ce26b9..ef857dcf 100644
--- a/applications/client/src/views/Campaign/Explore/Panels/Meta/BeaconMeta.tsx
+++ b/applications/client/src/views/Campaign/Explore/Panels/Meta/BeaconMeta.tsx
@@ -231,6 +231,7 @@ export const BeaconMeta = observer((props) => {
fill
>
+
+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);
+ });
+});
diff --git a/applications/redeye-e2e/src/integration/e2e/blueteam/hide-show-beacon.cy.js b/applications/redeye-e2e/src/integration/e2e/blueteam/hide-show-beacon.cy.js
index 1776fb30..44b44a7b 100644
--- a/applications/redeye-e2e/src/integration/e2e/blueteam/hide-show-beacon.cy.js
+++ b/applications/redeye-e2e/src/integration/e2e/blueteam/hide-show-beacon.cy.js
@@ -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(() => {
diff --git a/applications/redeye-e2e/src/integration/e2e/blueteam/meta-tab.cy.js b/applications/redeye-e2e/src/integration/e2e/blueteam/meta-tab.cy.js
new file mode 100644
index 00000000..cdffdaa7
--- /dev/null
+++ b/applications/redeye-e2e/src/integration/e2e/blueteam/meta-tab.cy.js
@@ -0,0 +1,29 @@
+///
+
+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);
+ });
+});
diff --git a/applications/redeye-e2e/src/integration/e2e/blueteam/presentation-mode-navigation.cy.js b/applications/redeye-e2e/src/integration/e2e/blueteam/presentation-mode-navigation.cy.js
new file mode 100644
index 00000000..25b92bc3
--- /dev/null
+++ b/applications/redeye-e2e/src/integration/e2e/blueteam/presentation-mode-navigation.cy.js
@@ -0,0 +1,133 @@
+///
+
+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);
+ });
+});
diff --git a/applications/redeye-e2e/src/integration/e2e/blueteam/toggle-redacted.cy.js b/applications/redeye-e2e/src/integration/e2e/blueteam/toggle-redacted.cy.js
new file mode 100644
index 00000000..b5f5425a
--- /dev/null
+++ b/applications/redeye-e2e/src/integration/e2e/blueteam/toggle-redacted.cy.js
@@ -0,0 +1,42 @@
+///
+
+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);
+ });
+});
diff --git a/applications/redeye-e2e/src/integration/e2e/blueteam/view-raw-logs.cy.js b/applications/redeye-e2e/src/integration/e2e/blueteam/view-raw-logs.cy.js
new file mode 100644
index 00000000..51dcca53
--- /dev/null
+++ b/applications/redeye-e2e/src/integration/e2e/blueteam/view-raw-logs.cy.js
@@ -0,0 +1,51 @@
+///
+
+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);
+ });
+});
diff --git a/applications/redeye-e2e/src/integration/e2e/redteam/hide-last-server.cy.js b/applications/redeye-e2e/src/integration/e2e/redteam/hide-last-server.cy.js
index d1de3266..d25b02f1 100644
--- a/applications/redeye-e2e/src/integration/e2e/redteam/hide-last-server.cy.js
+++ b/applications/redeye-e2e/src/integration/e2e/redteam/hide-last-server.cy.js
@@ -1,5 +1,16 @@
///
+function showHideConfirm(index) {
+ // Hide the first server in the list
+ cy.showHideItem(index);
+
+ // Verify confirmation modal appears
+ cy.verifyDialogBoxAppears();
+
+ // Confirm that you want to hide the server
+ cy.confirmShowHide();
+}
+
describe('Hide last server', () => {
const camp = 'hideonlyserver';
const fileName = 'gt.redeye';
@@ -32,6 +43,9 @@ describe('Hide last server', () => {
// Verify last host still shows in UI
cy.get('[cy-test=hosts-view]').should('contain', serverName);
+
+ // Delete campaign
+ cy.deleteCampaignGraphQL(camp);
});
});
@@ -48,13 +62,7 @@ describe('Hide last server', () => {
.as('server')
.then((serverName1) => {
// Hide the first server in the list
- cy.showHideItem(0);
-
- // Verify confirmation modal appears
- cy.verifyDialogBoxAppears();
-
- // Confirm that you want to hide the server
- cy.confirmShowHide();
+ showHideConfirm(0);
// Confirm first server does not show in list
cy.get('[cy-test=hostName]').each(($servers) => {
@@ -65,13 +73,7 @@ describe('Hide last server', () => {
// Get name of seccond server
cy.get('@server').then((serverName2) => {
// Hide the first server in the list
- cy.showHideItem(0);
-
- // Verify confirmation modal appears
- cy.verifyDialogBoxAppears();
-
- // Confirm that you want to hide the host
- cy.confirmShowHide();
+ showHideConfirm(0);
// Confirm first host does not show in list
cy.get('[cy-test=hostName]').each(($servers) => {
@@ -82,13 +84,7 @@ describe('Hide last server', () => {
// Get name of third server
cy.get('@server').then((serverName3) => {
// Hide the first server in the list
- cy.showHideItem(0);
-
- // Verify confirmation modal appears
- cy.verifyDialogBoxAppears();
-
- // Confirm that you want to hide the host
- cy.confirmShowHide();
+ showHideConfirm(0);
// Confirm first host does not show in list
cy.get('[cy-test=hostName]').each(($servers) => {
@@ -114,7 +110,6 @@ describe('Hide last server', () => {
});
after(() => {
- cy.deleteCampaignGraphQL(camp);
cy.deleteCampaignGraphQL(camp2);
});
});
diff --git a/applications/redeye-e2e/src/integration/e2e/redteam/toggle-redacted.cy.js b/applications/redeye-e2e/src/integration/e2e/redteam/toggle-redacted.cy.js
new file mode 100644
index 00000000..6bc32696
--- /dev/null
+++ b/applications/redeye-e2e/src/integration/e2e/redteam/toggle-redacted.cy.js
@@ -0,0 +1,42 @@
+///
+
+describe('Redacted mode toggle', () => {
+ const camp = 'toggleredactedmode';
+ const fileName = 'gt.redeye';
+
+ it('Toggle Redacted mode within a campaign', () => {
+ cy.uploadCampaign(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);
+ });
+});
diff --git a/applications/redeye-e2e/src/support/campaignCard.js b/applications/redeye-e2e/src/support/campaignCard.js
index 0b5d2f98..94013d4f 100644
--- a/applications/redeye-e2e/src/support/campaignCard.js
+++ b/applications/redeye-e2e/src/support/campaignCard.js
@@ -57,6 +57,7 @@ Cypress.Commands.add('uploadFolder', (camp, fileName) => {
//UPLOAD CAMPAIGN DB FILE
Cypress.Commands.add('uploadCampaignBlue', (camp, fileName) => {
cy.get('[cy-test=add-campaign-btn]').click();
+ cy.get('[cy-test=upload-from-file]').click();
cy.get('[cy-test=new-camp-name]').click().type(camp);
cy.fixture(fileName, { encoding: null }).as('myFixture');
cy.get('[cy-test=browse-for-file]').selectFile('@myFixture');
diff --git a/applications/redeye-e2e/src/support/commands.js b/applications/redeye-e2e/src/support/commands.js
index 9225c718..7c2c1af8 100644
--- a/applications/redeye-e2e/src/support/commands.js
+++ b/applications/redeye-e2e/src/support/commands.js
@@ -274,3 +274,15 @@ Cypress.Commands.add('toggleDarkTheme', () => {
cy.get('[cy-test=toggle-theme]').uncheck({ force: true });
cy.get('[cy-test=close-log]').click();
});
+
+Cypress.Commands.add('toggleRedacted', () => {
+ cy.get('[cy-test=settings]').click();
+ cy.get('[cy-test=toggle-redacted-mode]').check({ force: true });
+ cy.get('[cy-test=close-log]').click();
+});
+
+Cypress.Commands.add('toggleUnredacted', () => {
+ cy.get('[cy-test=settings]').click();
+ cy.get('[cy-test=toggle-redacted-mode]').uncheck({ force: true });
+ cy.get('[cy-test=close-log]').click();
+});