Commit 4f37e9d5 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'djadmin-site-validation-refactor' into 'master'

Refactor site validation modal component

See merge request gitlab-org/gitlab!48017
parents b0d463e1 35e8701f
---
name: security_on_demand_scans_http_header_validation
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42812
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/276403
milestone: '13.6'
type: development
group: group::dynamic analysis
default_enabled: false
...@@ -11,12 +11,10 @@ import { ...@@ -11,12 +11,10 @@ import {
GlSkeletonLoader, GlSkeletonLoader,
GlTruncate, GlTruncate,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { omit } from 'lodash';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import * as Sentry from '~/sentry/wrapper'; import * as Sentry from '~/sentry/wrapper';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import download from '~/lib/utils/downloader'; import download from '~/lib/utils/downloader';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { cleanLeadingSeparator, joinPaths, stripPathTail } from '~/lib/utils/url_utility'; import { cleanLeadingSeparator, joinPaths, stripPathTail } from '~/lib/utils/url_utility';
import { import {
DAST_SITE_VALIDATION_MODAL_ID, DAST_SITE_VALIDATION_MODAL_ID,
...@@ -44,7 +42,6 @@ export default { ...@@ -44,7 +42,6 @@ export default {
GlSkeletonLoader, GlSkeletonLoader,
GlTruncate, GlTruncate,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
fullPath: { fullPath: {
type: String, type: String,
...@@ -85,14 +82,7 @@ export default { ...@@ -85,14 +82,7 @@ export default {
}; };
}, },
validationMethodOptions() { validationMethodOptions() {
const isHttpHeaderValidationEnabled = this.glFeatures return Object.values(DAST_SITE_VALIDATION_METHODS);
.securityOnDemandScansHttpHeaderValidation;
const enabledValidationMethods = omit(DAST_SITE_VALIDATION_METHODS, [
!isHttpHeaderValidationEnabled ? DAST_SITE_VALIDATION_METHOD_HTTP_HEADER : '',
]);
return Object.values(enabledValidationMethods);
}, },
urlObject() { urlObject() {
try { try {
...@@ -187,7 +177,7 @@ export default { ...@@ -187,7 +177,7 @@ export default {
await this.$apollo.mutate({ await this.$apollo.mutate({
mutation: dastSiteValidationCreateMutation, mutation: dastSiteValidationCreateMutation,
variables: { variables: {
projectFullPath: this.fullPath, fullPath: this.fullPath,
dastSiteTokenId: this.tokenId, dastSiteTokenId: this.tokenId,
validationPath: this.validationPath, validationPath: this.validationPath,
validationStrategy: this.validationMethod, validationStrategy: this.validationMethod,
......
mutation dastSiteValidationCreate( mutation dastSiteValidationCreate(
$projectFullPath: ID! $fullPath: ID!
$dastSiteTokenId: DastSiteTokenID! $dastSiteTokenId: DastSiteTokenID!
$validationPath: String! $validationPath: String!
$validationStrategy: DastSiteValidationStrategyEnum $validationStrategy: DastSiteValidationStrategyEnum
) { ) {
dastSiteValidationCreate( dastSiteValidationCreate(
input: { input: {
fullPath: $projectFullPath fullPath: $fullPath
dastSiteTokenId: $dastSiteTokenId dastSiteTokenId: $dastSiteTokenId
validationPath: $validationPath validationPath: $validationPath
strategy: $validationStrategy strategy: $validationStrategy
......
...@@ -6,7 +6,6 @@ module Projects ...@@ -6,7 +6,6 @@ module Projects
before_action do before_action do
authorize_read_on_demand_scans! authorize_read_on_demand_scans!
push_frontend_feature_flag(:security_on_demand_scans_site_validation, @project) push_frontend_feature_flag(:security_on_demand_scans_site_validation, @project)
push_frontend_feature_flag(:security_on_demand_scans_http_header_validation, @project)
end end
feature_category :dynamic_application_security_testing feature_category :dynamic_application_security_testing
......
...@@ -51,9 +51,6 @@ describe('DastSiteValidationModal', () => { ...@@ -51,9 +51,6 @@ describe('DastSiteValidationModal', () => {
{}, {},
{ {
propsData: defaultProps, propsData: defaultProps,
provide: {
glFeatures: { securityOnDemandScansHttpHeaderValidation: true },
},
attrs: { attrs: {
static: true, static: true,
visible: true, visible: true,
...@@ -287,22 +284,6 @@ describe('DastSiteValidationModal', () => { ...@@ -287,22 +284,6 @@ describe('DastSiteValidationModal', () => {
}); });
}); });
describe('with the "securityOnDemandScansHttpHeaderValidation" feature flag disabled', () => {
beforeEach(() => {
createFullComponent({
provide: {
glFeatures: {
securityOnDemandScansHttpHeaderValidation: false,
},
},
});
});
it('does not render the http-header validation method', () => {
expect(findRadioInputForValidationMethod('header')).toBe(null);
});
});
describe.each(validationMethods)('"%s" validation submission', validationMethod => { describe.each(validationMethods)('"%s" validation submission', validationMethod => {
beforeEach(async () => { beforeEach(async () => {
createFullComponent(); createFullComponent();
...@@ -318,7 +299,7 @@ describe('DastSiteValidationModal', () => { ...@@ -318,7 +299,7 @@ describe('DastSiteValidationModal', () => {
findValidateButton().trigger('click'); findValidateButton().trigger('click');
expect(requestHandlers.dastSiteValidationCreate).toHaveBeenCalledWith({ expect(requestHandlers.dastSiteValidationCreate).toHaveBeenCalledWith({
projectFullPath: fullPath, fullPath,
dastSiteTokenId: tokenId, dastSiteTokenId: tokenId,
validationPath: wrapper.vm.validationPath, validationPath: wrapper.vm.validationPath,
validationStrategy: wrapper.vm.validationMethod, validationStrategy: wrapper.vm.validationMethod,
......
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