From 161d678c3447f18ca96117908387a3d384613666 Mon Sep 17 00:00:00 2001 From: Avi Shah Date: Thu, 9 Jan 2025 12:40:40 +0530 Subject: [PATCH] --wip-- [skip ci] --- .../dynamic-scan/header/index.hbs | 6 +- .../dynamicscan-automation-settings/index.hbs | 2 +- .../dynamicscan-automation-settings/index.ts | 12 +-- .../file-details/dynamic-scan-test.js | 99 ++++++++++++++++++- .../index-test.js | 46 ++++++--- translations/en.json | 8 +- translations/ja.json | 8 +- 7 files changed, 144 insertions(+), 37 deletions(-) diff --git a/app/components/file-details/dynamic-scan/header/index.hbs b/app/components/file-details/dynamic-scan/header/index.hbs index 1a1d872b7..ea2e218ef 100644 --- a/app/components/file-details/dynamic-scan/header/index.hbs +++ b/app/components/file-details/dynamic-scan/header/index.hbs @@ -34,7 +34,11 @@ {{/if}} {{#if item.inProgress}} - + {{/if}} diff --git a/app/components/project-settings/general-settings/dynamicscan-automation-settings/index.hbs b/app/components/project-settings/general-settings/dynamicscan-automation-settings/index.hbs index 764818305..5e1ed1cef 100644 --- a/app/components/project-settings/general-settings/dynamicscan-automation-settings/index.hbs +++ b/app/components/project-settings/general-settings/dynamicscan-automation-settings/index.hbs @@ -39,7 +39,7 @@ local-class='schedule-automation-toggle' > @@ -472,6 +540,7 @@ module('Acceptance | file-details/dynamic-scan', function (hooks) { mode: ENUMS.DYNAMIC_MODE[mode.toUpperCase()], status: ENUMS.DYNAMIC_SCAN_STATUS.NOT_STARTED, ended_on: null, + started_by_user: startedBy ? this.profile.id : null, }); const availableDevices = this.server.createList( @@ -555,6 +624,10 @@ module('Acceptance | file-details/dynamic-scan', function (hooks) { enabled: false, })); + const user = this.server.create('user', { + id: this.profile.id, + }); + await visit(`/dashboard/file/${this.file.id}/dynamic-scan/${mode}`); assert @@ -648,9 +721,25 @@ module('Acceptance | file-details/dynamic-scan', function (hooks) { assert.dom('[data-test-vncViewer-scanTriggeredNote]').exists(); + if (startedBy) { + assert + .dom('[data-test-vncViewer-scanStartedByText]') + .exists() + .hasText(`${t('scanStartedBy')} ${user.username}`); + } else { + assert + .dom('[data-test-vncViewer-scanTriggeredAutomaticallyText]') + .exists() + .hasText(t('scanTriggeredAutomatically')); + } + assert .dom('[data-test-vncViewer-automatedNote]') .hasText(`${t('note')} - ${t('automatedScanQueuedVncNote')}`); + + assert + .dom('[data-test-fileDetails-dynamicScan-inProgress-loader]') + .exists(); } else { assert.dom('[data-test-vncViewer-automatedNote]').doesNotExist(); assert.dom('[data-test-vncViewer-scanTriggeredNote]').doesNotExist(); diff --git a/tests/integration/components/project-settings/general-settings/dynamicscan-automation-settings/index-test.js b/tests/integration/components/project-settings/general-settings/dynamicscan-automation-settings/index-test.js index 4e6122e66..c9710d237 100644 --- a/tests/integration/components/project-settings/general-settings/dynamicscan-automation-settings/index-test.js +++ b/tests/integration/components/project-settings/general-settings/dynamicscan-automation-settings/index-test.js @@ -23,9 +23,9 @@ const selectors = { dynScanAutoRoot: '[data-test-projectSettings-genSettings-dynScanAutoSettings-root]', dynScanAutoToggle: - '[data-test-genSettings-dynScanAutoSettings-dynamicscanModeToggle] [data-test-toggle-input]', + '[data-test-genSettings-dynScanAutoSettings-dynamicscanAutomationToggle] [data-test-toggle-input]', dynamicscanModeToggleLabel: - '[data-test-genSettings-dynScanAutoSettings-dynamicscanModeToggleLabel]', + '[data-test-genSettings-dynScanAutoSettings-dynamicscanAutomationToggleLabel]', }; module( @@ -45,8 +45,26 @@ module( return schema.files.find(`${req.params.id}`)?.toJSON(); }); - this.server.get('/profiles/:id/dynamicscan_mode', (schema, req) => - schema.dynamicscanModes.find(`${req.queryParams.id}`)?.toJSON() + this.server.create('ds-automation-preference', { + dynamic_scan_automation_enabled: false, + }); + + this.server.get( + '/v2/projects/:projectId/scan_parameter_groups', + function (schema) { + const results = schema.scanParameterGroups.all().models; + + return { + count: results.length, + next: null, + previous: null, + results, + }; + } + ); + + this.server.get('/v2/profiles/:id/automation_preference', (schema, req) => + schema.dsAutomationPreferences.find(`${req.queryParams.id}`)?.toJSON() ); this.owner.register('service:notifications', NotificationsStub); @@ -68,11 +86,6 @@ module( }); test('it renders', async function (assert) { - this.server.create('dynamicscan-mode', { - id: 1, - dynamicscan_mode: 'Manual', - }); - await render(hbs` { + this.server.put('v2/profiles/:id/automation_preference', (_, req) => { const reqBody = JSON.parse(req.requestBody); - this.set('dynamicscan_mode', reqBody.dynamicscan_mode); - return { - dynamicscan_mode: reqBody.dynamicscan_mode, + dynamic_scan_automation_enabled: + reqBody.dynamic_scan_automation_enabled, id: req.params.id, }; }); @@ -124,7 +136,7 @@ module( assert .dom(selectors.dynamicscanModeToggleLabel) .exists() - .containsText(t('appiumScheduledAutomation')); + .containsText(t('enableAutomation')); assert.dom(selectors.dynScanAutoToggle).exists().isNotChecked(); @@ -132,13 +144,15 @@ module( assert.dom(selectors.dynScanAutoToggle).isChecked(); - assert.ok(this.dynamicscan_mode, 'Automated'); + const notify = this.owner.lookup('service:notifications'); + + assert.strictEqual(notify.successMsg, t('scheduledAutomationSuccessOn')); await click(selectors.dynScanAutoToggle); assert.dom(selectors.dynScanAutoToggle).isNotChecked(); - assert.ok(this.dynamicscan_mode, 'Manual'); + assert.strictEqual(notify.successMsg, t('scheduledAutomationSuccessOff')); }); } ); diff --git a/translations/en.json b/translations/en.json index 495c1c0bc..0a6ed9e6d 100644 --- a/translations/en.json +++ b/translations/en.json @@ -82,9 +82,6 @@ "appOrS": "app(s)", "appSwitcher": "App Switcher", "appiumFileUploadedSuccessfully": "File Uploaded Successfully", - "appiumScheduledAutomation": "Schedule Automation", - "appiumScheduledAutomationSuccessOff": "Scheduled dynamic scan automation turned OFF", - "appiumScheduledAutomationSuccessOn": "Scheduled dynamic scan automation turned ON", "appiumScriptInvalid": "Invalid script file. Please upload a valid Appium project", "appiumScripts": "Appium scripts", "appiumScriptsDescription": "As a part of our upcoming automated dynamic scan feature, we are currently supporting scheduled dynamic scans option using Appium scripts. Upload your app's Appium test scripts here as a zip file, dynamic scans would be automatically scheduled for all your future app uploads in this project.", @@ -355,7 +352,7 @@ "deviceLaunching": "Launching", "deviceNotFound": "Hard time for us to find the device", "devicePreferences": "Device Preferences", - "devicePreferencesAutomatedDast": "Device Preferences (Automated Dast)", + "devicePreferencesAutomatedDast": "Device Preferences (Automated DAST)", "deviceSelected": "You have successfully selected the device", "deviceShuttingDown": "Stopping", "deviceType": "Device Type", @@ -409,6 +406,7 @@ "emptyURLFilter": "Enter host name", "enHTMLReport": "EN HTML Report", "enable": "Enable", + "enableAutomation": "Enable Automation", "enableMFA": "Enable MFA", "enableMandatoryMFADescription": "By enabling this you are mandating multi factor authentication for all users in this organization. Users who do not have MFA enabled in their user account will receive OTP via the registered email.", "enableMandatoryMFARequirement": "For enabling mandatory MFA for organization, you need to have MFA enabled for your user account. Enable it from here:", @@ -1379,6 +1377,8 @@ "scheduleDynamicscan": "Schedule Automated Dynamic Scan", "scheduleDynamicscanDesc": "Schedule an automated dynamic scan for this file by clicking on the button below. Once scheduled, the system will use the Active Scenarios on the Project Settings page to execute the Automated DAST. It may take up to 24hrs for this to be completed.", "scheduleDynamicscanSuccess": "Automated dynamic scan scheduled successfully", + "scheduledAutomationSuccessOff": "Dynamic Scan Automation has been turned OFF for this project", + "scheduledAutomationSuccessOn": "Dynamic Scan Automation has been scheduled for this project", "search": "Search", "searchUser": "Search user", "searchProject": "Search project", diff --git a/translations/ja.json b/translations/ja.json index 6346108af..e85832a38 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -82,9 +82,6 @@ "appOrS": "アプリ", "appSwitcher": "App Switcher", "appiumFileUploadedSuccessfully": "File Uploaded Successfully", - "appiumScheduledAutomation": "Schedule Automation", - "appiumScheduledAutomationSuccessOff": "Scheduled dynamic scan automation turned OFF", - "appiumScheduledAutomationSuccessOn": "Scheduled dynamic scan automation turned ON", "appiumScriptInvalid": "Invalid script file. Please upload a valid Appium project", "appiumScripts": "Appium scripts", "appiumScriptsDescription": "As a part of our upcoming automated dynamic scan feature, we are currently supporting scheduled dynamic scans option using Appium scripts. Upload your app's Appium test scripts here as a zip file, dynamic scans would be automatically scheduled for all your future app uploads in this project.", @@ -355,7 +352,7 @@ "deviceLaunching": "開始中", "deviceNotFound": "デバイスが見つかりませんでした", "devicePreferences": "デバイスの設定", - "devicePreferencesAutomatedDast": "Device Preferences (Automated Dast)", + "devicePreferencesAutomatedDast": "Device Preferences (Automated DAST)", "deviceSelected": "デバイスを選択しました", "deviceShuttingDown": "停止中", "deviceType": "デバイスタイプ", @@ -409,6 +406,7 @@ "emptyURLFilter": "Enter host name", "enHTMLReport": "EN HTML Report", "enable": "Enable", + "enableAutomation": "Enable Automation", "enableMFA": "MFAの有効化", "enableMandatoryMFADescription": "By enabling this you are mandating multi factor authentication for all users in this organization. Users who do not have MFA enabled in their user account will receive OTP via the registered email.", "enableMandatoryMFARequirement": "For enabling mandatory MFA for organization, you need to have MFA enabled for your user account. Enable it from here:", @@ -1379,6 +1377,8 @@ "scheduleDynamicscan": "Schedule Automated Dynamic Scan", "scheduleDynamicscanDesc": "Schedule an automated dynamic scan for this file by clicking on the button below. Once scheduled, the system will use the Active Scenarios on the Project Settings page to execute the Automated DAST. It may take up to 24hrs for this to be completed.", "scheduleDynamicscanSuccess": "Automated dynamic scan scheduled successfully", + "scheduledAutomationSuccessOff": "Dynamic Scan Automation has been turned OFF for this project", + "scheduledAutomationSuccessOn": "Dynamic Scan Automation has been scheduled for this project", "search": "検索", "searchUser": "Search user", "searchProject": "Search project",