Commit 62f0e99c authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'djadmin-dast-hide-none-values-in-summary' into 'master'

DAST Profiles: Hide empty values on the summary card

See merge request gitlab-org/gitlab!83737
parents 95a0c76c 22914612
<script> <script>
import { SCAN_TYPE_LABEL } from 'ee/security_configuration/dast_profiles/dast_scanner_profiles/constants'; import { SCAN_TYPE_LABEL } from 'ee/security_configuration/dast_profiles/dast_scanner_profiles/constants';
import ProfileSelectorSummaryCell from './summary_cell.vue'; import SummaryCell from './summary_cell.vue';
export default { export default {
name: 'DastScannerProfileSummary', name: 'DastScannerProfileSummary',
components: { components: {
ProfileSelectorSummaryCell, SummaryCell,
}, },
props: { props: {
profile: { profile: {
...@@ -23,37 +23,31 @@ export default { ...@@ -23,37 +23,31 @@ export default {
</script> </script>
<template> <template>
<div> <div class="row">
<div class="row"> <summary-cell
<profile-selector-summary-cell :class="{ 'gl-text-red-500': hasConflict }"
:class="{ 'gl-text-red-500': hasConflict }" :label="s__('DastProfiles|Scan mode')"
:label="s__('DastProfiles|Scan mode')" :value="$options.SCAN_TYPE_LABEL[profile.scanType]"
:value="$options.SCAN_TYPE_LABEL[profile.scanType]" />
/> <summary-cell
</div> :label="s__('DastProfiles|Spider timeout')"
<div class="row"> :value="n__('%d minute', '%d minutes', profile.spiderTimeout || 0)"
<profile-selector-summary-cell />
:label="s__('DastProfiles|Spider timeout')" <summary-cell
:value="n__('%d minute', '%d minutes', profile.spiderTimeout || 0)" :label="s__('DastProfiles|Target timeout')"
/> :value="n__('%d second', '%d seconds', profile.targetTimeout || 0)"
<profile-selector-summary-cell />
:label="s__('DastProfiles|Target timeout')" <summary-cell
:value="n__('%d second', '%d seconds', profile.targetTimeout || 0)" :label="s__('DastProfiles|AJAX spider')"
/> :value="profile.useAjaxSpider ? __('On') : __('Off')"
</div> />
<div class="row"> <summary-cell
<profile-selector-summary-cell :label="s__('DastProfiles|Debug messages')"
:label="s__('DastProfiles|AJAX spider')" :value="
:value="profile.useAjaxSpider ? __('On') : __('Off')" profile.showDebugMessages
/> ? s__('DastProfiles|Show debug messages')
<profile-selector-summary-cell : s__('DastProfiles|Hide debug messages')
:label="s__('DastProfiles|Debug messages')" "
:value=" />
profile.showDebugMessages
? s__('DastProfiles|Show debug messages')
: s__('DastProfiles|Hide debug messages')
"
/>
</div>
</div> </div>
</template> </template>
...@@ -5,12 +5,12 @@ import { ...@@ -5,12 +5,12 @@ import {
} from 'ee/security_configuration/dast_profiles/dast_site_profiles/constants'; } from 'ee/security_configuration/dast_profiles/dast_site_profiles/constants';
import { DAST_SITE_VALIDATION_STATUS } from 'ee/security_configuration/dast_site_validation/constants'; import { DAST_SITE_VALIDATION_STATUS } from 'ee/security_configuration/dast_site_validation/constants';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import ProfileSelectorSummaryCell from './summary_cell.vue'; import SummaryCell from './summary_cell.vue';
export default { export default {
name: 'DastSiteProfileSummary', name: 'DastSiteProfileSummary',
components: { components: {
ProfileSelectorSummaryCell, SummaryCell,
}, },
props: { props: {
profile: { profile: {
...@@ -39,6 +39,7 @@ export default { ...@@ -39,6 +39,7 @@ export default {
? s__('DastProfiles|Excluded paths') ? s__('DastProfiles|Excluded paths')
: s__('DastProfiles|Excluded URLs'), : s__('DastProfiles|Excluded URLs'),
requestHeaders: s__('DastProfiles|Request headers'), requestHeaders: s__('DastProfiles|Request headers'),
validationStatus: s__('DastProfiles|Validation status'),
}; };
}, },
hasExcludedUrls() { hasExcludedUrls() {
...@@ -66,47 +67,25 @@ export default { ...@@ -66,47 +67,25 @@ export default {
</script> </script>
<template> <template>
<div> <div class="row">
<div class="row"> <summary-cell
<profile-selector-summary-cell :class="{ 'gl-text-red-500': hasConflict }"
:class="{ 'gl-text-red-500': hasConflict }" :label="i18n.targetUrl"
:label="i18n.targetUrl" :value="profile.targetUrl"
:value="profile.targetUrl" />
/> <summary-cell :label="i18n.targetType" :value="targetTypeValue" />
<profile-selector-summary-cell :label="i18n.targetType" :value="targetTypeValue" />
</div>
<template v-if="profile.auth.enabled"> <template v-if="profile.auth.enabled">
<div class="row"> <summary-cell :label="i18n.authUrl" :value="profile.auth.url" />
<profile-selector-summary-cell :label="i18n.authUrl" :value="profile.auth.url" /> <summary-cell :label="i18n.username" :value="profile.auth.username" />
</div> <summary-cell :label="i18n.password" value="••••••••" />
<div class="row"> <summary-cell :label="i18n.usernameField" :value="profile.auth.usernameField" />
<profile-selector-summary-cell :label="i18n.username" :value="profile.auth.username" /> <summary-cell :label="i18n.passwordField" :value="profile.auth.passwordField" />
<profile-selector-summary-cell :label="i18n.password" value="••••••••" />
</div>
<div class="row">
<profile-selector-summary-cell
:label="i18n.usernameField"
:value="profile.auth.usernameField"
/>
<profile-selector-summary-cell
:label="i18n.passwordField"
:value="profile.auth.passwordField"
/>
</div>
</template> </template>
<div class="row"> <summary-cell :label="i18n.excludedUrls" :value="displayExcludedUrls" />
<profile-selector-summary-cell :label="i18n.excludedUrls" :value="displayExcludedUrls" /> <summary-cell
<profile-selector-summary-cell :label="i18n.requestHeaders"
:label="i18n.requestHeaders" :value="profile.requestHeaders ? __('[Redacted]') : undefined"
:value="profile.requestHeaders ? __('[Redacted]') : undefined" />
/> <summary-cell :label="i18n.validationStatus" :value="isProfileValidated" />
</div>
<div class="row">
<profile-selector-summary-cell
:label="s__('DastProfiles|Validation status')"
:value="isProfileValidated"
/>
</div>
</div> </div>
</template> </template>
<script> <script>
import { __ } from '~/locale';
export default { export default {
name: 'OnDemandScansProfileSummaryCell', name: 'OnDemandScansProfileSummaryCell',
props: { props: {
...@@ -11,14 +9,14 @@ export default { ...@@ -11,14 +9,14 @@ export default {
value: { value: {
type: String, type: String,
required: false, required: false,
default: __('None'), default: null,
}, },
}, },
}; };
</script> </script>
<template> <template>
<div class="col-md-6"> <div v-if="value" class="col-md-6">
<div class="row gl-my-2"> <div class="row gl-my-2">
<div class="col-md-4">{{ label }}:</div> <div class="col-md-4">{{ label }}:</div>
<div class="col-md-8"> <div class="col-md-8">
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DastScannerProfileSummary renders properly 1`] = ` exports[`DastScannerProfileSummary renders properly 1`] = `
<div> <div
<div class="row"
class="row" >
> <summary-cell-stub
<profile-selector-summary-cell-stub class=""
class="" label="Scan mode"
label="Scan mode" value="Passive"
value="Passive" />
/>
</div>
<div <summary-cell-stub
class="row" label="Spider timeout"
> value="5 minutes"
<profile-selector-summary-cell-stub />
label="Spider timeout"
value="5 minutes"
/>
<profile-selector-summary-cell-stub
label="Target timeout"
value="10 seconds"
/>
</div>
<div <summary-cell-stub
class="row" label="Target timeout"
> value="10 seconds"
<profile-selector-summary-cell-stub />
label="AJAX spider"
value="Off" <summary-cell-stub
/> label="AJAX spider"
value="Off"
<profile-selector-summary-cell-stub />
label="Debug messages"
value="Hide debug messages" <summary-cell-stub
/> label="Debug messages"
</div> value="Hide debug messages"
/>
</div> </div>
`; `;
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import OnDemandScansProfileSummaryCell from 'ee/on_demand_scans_form/components/profile_selector/summary_cell.vue'; import OnDemandScansProfileSummaryCell from 'ee/on_demand_scans_form/components/profile_selector/summary_cell.vue';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
describe('OnDemandScansProfileSummaryCell', () => { describe('OnDemandScansProfileSummaryCell', () => {
let wrapper; let wrapper;
const createFullComponent = (propsData) => { const createFullComponent = (propsData) => {
wrapper = extendedWrapper( wrapper = shallowMount(OnDemandScansProfileSummaryCell, {
shallowMount(OnDemandScansProfileSummaryCell, { propsData,
propsData, });
}),
);
}; };
const findValue = () => wrapper.findByTestId('summary-value');
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
...@@ -28,12 +23,12 @@ describe('OnDemandScansProfileSummaryCell', () => { ...@@ -28,12 +23,12 @@ describe('OnDemandScansProfileSummaryCell', () => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
it('renders default when value prop is undefined', () => { it('renders nothing when value prop is undefined', () => {
createFullComponent({ createFullComponent({
label: 'Row Label', label: 'Row Label',
value: undefined, value: undefined,
}); });
expect(findValue().text()).toContain('None'); expect(wrapper.html()).toBe('');
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment