Skip to content

Show failed site validations in profiles library

What does this MR do?

This adds alerts at the top of the DAST profiles library to let users know of failed validations and give them easy ways to either retry or revoke said validations.

How to test this?

  1. Enable the dast_failed_site_validations feature flag.
echo "Feature.enable(:dast_failed_site_validations)" | rails c
  1. Apply the following patch to mock some data client-side:
diff --git a/ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/dast_failed_site_validations.query.graphql b/ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/dast_failed_site_validations.query.graphql
index 4421c7cf817..9a9d6fb5416 100644
--- a/ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/dast_failed_site_validations.query.graphql
+++ b/ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/dast_failed_site_validations.query.graphql
@@ -1,5 +1,5 @@
 query DastFailedSiteValidations($fullPath: ID!) {
-  project(fullPath: $fullPath) {
+  project(fullPath: $fullPath) @client {
     validations: dastSiteValidations(normalizedTargetUrls: $urls, status: "FAILED_VALIDATION") {
       nodes {
         normalizedTargetUrl
diff --git a/ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/provider.js b/ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/provider.js
index fa23669b615..54014fcd36a 100644
--- a/ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/provider.js
+++ b/ee/app/assets/javascripts/security_configuration/dast_profiles/graphql/provider.js
@@ -4,6 +4,29 @@ import createDefaultClient from '~/lib/graphql';
 
 Vue.use(VueApollo);
 
+const resolvers = {
+  Query: {
+    project: () => {
+      return {
+        __typename: 'Project',
+        dastSiteValidations: {
+          __typename: 'DastSiteValidationsNodes',
+          nodes: [
+            {
+              __typename: 'DastSiteValidationNode',
+              normalizedTargetUrl: 'http://example.com:80',
+            },
+            {
+              __typename: 'DastSiteValidationNode',
+              normalizedTargetUrl: 'https://example.com:443',
+            },
+          ],
+        },
+      };
+    },
+  },
+};
+
 export default new VueApollo({
-  defaultClient: createDefaultClient({}, { assumeImmutableResults: true }),
+  defaultClient: createDefaultClient(resolvers, { assumeImmutableResults: true }),
 });
  1. Navigate to a project's DAST profiles library at /:namespace/:project/-/security/configuration/dast_profiles.

Screenshots (strongly suggested)

failed validations

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Related to #322608 (closed)

Edited by Paul Gascou-Vaillancourt

Merge request reports