Skip to content

Configure Secret Detection via an MR [RUN ALL RSPEC] [RUN AS-IF-FOSS]

What does this MR do?

This makes it possible to configure Secret Detection via an automatically created MR from the Security Configuration page.

How to test this?

Note that the backend doesn't yet support this feature, it is therefor hidden behind a feature flag, and the GraphQL mutation needs to be mocked in order for the feature to be fully tested.

  1. Enable the sec_secret_detection_ui_enable feature flag.
echo "Feature.enable(:sec_secret_detection_ui_enable)" | rails c
  1. Apply this patch to mock the mutation:
diff --git a/ee/app/assets/javascripts/security_configuration/graphql/configure_secret_detection.mutation.graphql b/ee/app/assets/javascripts/security_configuration/graphql/configure_secret_detection.mutation.graphql
index 2fd4b0982df..1d8cbee288a 100644
--- a/ee/app/assets/javascripts/security_configuration/graphql/configure_secret_detection.mutation.graphql
+++ b/ee/app/assets/javascripts/security_configuration/graphql/configure_secret_detection.mutation.graphql
@@ -1,5 +1,5 @@
 mutation configureSecretDetection($fullPath: ID!) {
-  configureSecretDetection(fullPath: $fullPath) {
+  configureSecretDetection(fullPath: $fullPath) @client {
     successPath
     errors
   }
diff --git a/ee/app/assets/javascripts/security_configuration/graphql/provider.js b/ee/app/assets/javascripts/security_configuration/graphql/provider.js
index ef96b443da8..25be7103bd2 100644
--- a/ee/app/assets/javascripts/security_configuration/graphql/provider.js
+++ b/ee/app/assets/javascripts/security_configuration/graphql/provider.js
@@ -2,8 +2,20 @@ import Vue from 'vue';
 import VueApollo from 'vue-apollo';
 import createDefaultClient from '~/lib/graphql';

+const resolvers = {
+  Mutation: {
+    configureSecretDetection: () => {
+      return {
+        successPath: '/success',
+        errors: [],
+        __typename: 'configureSecretDetection',
+      };
+    },
+  },
+};
+
 Vue.use(VueApollo);

 export default new VueApollo({
-  defaultClient: createDefaultClient(),
+  defaultClient: createDefaultClient(resolvers),
 });

Screenshots (strongly suggested)

Before After
Screen_Shot_2021-03-31_at_7.02.31_AM Screen_Shot_2021-03-31_at_7.01.51_AM

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Related to #321281 (closed)

Edited by Paul Gascou-Vaillancourt

Merge request reports