Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/graphql/types/project_type_spec.rb')
-rw-r--r--spec/graphql/types/project_type_spec.rb92
1 files changed, 90 insertions, 2 deletions
diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb
index 8ee9aa9cf3a..ea88ed6a3f5 100644
--- a/spec/graphql/types/project_type_spec.rb
+++ b/spec/graphql/types/project_type_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe GitlabSchema.types['Project'] do
+RSpec.describe GitlabSchema.types['Project'] do
specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Project) }
specify { expect(described_class.graphql_name).to eq('Project') }
@@ -26,7 +26,7 @@ describe GitlabSchema.types['Project'] do
grafanaIntegration autocloseReferencedIssues suggestion_commit_message environments
boards jira_import_status jira_imports services releases release
alert_management_alerts alert_management_alert alert_management_alert_status_counts
- container_expiration_policy
+ container_expiration_policy sast_ci_configuration service_desk_enabled service_desk_address
]
expect(described_class).to include_graphql_fields(*expected_fields)
@@ -140,5 +140,93 @@ describe GitlabSchema.types['Project'] do
it { is_expected.to have_graphql_type(Types::ContainerExpirationPolicyType) }
end
+ describe 'sast_ci_configuration' do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:query) do
+ %(
+ query {
+ project(fullPath: "#{project.full_path}") {
+ sastCiConfiguration {
+ global {
+ nodes {
+ type
+ options {
+ nodes {
+ label
+ value
+ }
+ }
+ field
+ label
+ defaultValue
+ value
+ }
+ }
+ pipeline {
+ nodes {
+ type
+ options {
+ nodes {
+ label
+ value
+ }
+ }
+ field
+ label
+ defaultValue
+ value
+ }
+ }
+ analyzers {
+ nodes {
+ name
+ label
+ enabled
+ }
+ }
+ }
+ }
+ }
+ )
+ end
+
+ subject { GitlabSchema.execute(query, context: { current_user: user }).as_json }
+
+ before do
+ project.add_developer(user)
+ end
+
+ it "returns the project's sast configuration for global variables" do
+ query_result = subject.dig('data', 'project', 'sastCiConfiguration', 'global', 'nodes')
+ first_config = query_result.first
+ fourth_config = query_result[3]
+ expect(first_config['type']).to eq('string')
+ expect(first_config['field']).to eq('SECURE_ANALYZERS_PREFIX')
+ expect(first_config['label']).to eq('Image prefix')
+ expect(first_config['defaultValue']).to eq('registry.gitlab.com/gitlab-org/security-products/analyzers')
+ expect(first_config['value']).to eq('')
+ expect(first_config['options']).to be_nil
+ expect(fourth_config['options']['nodes']).to match([{ "value" => "true", "label" => "true (disables SAST)" },
+ { "value" => "false", "label" => "false (enables SAST)" }])
+ end
+
+ it "returns the project's sast configuration for pipeline variables" do
+ configuration = subject.dig('data', 'project', 'sastCiConfiguration', 'pipeline', 'nodes').first
+ expect(configuration['type']).to eq('dropdown')
+ expect(configuration['field']).to eq('stage')
+ expect(configuration['label']).to eq('Stage')
+ expect(configuration['defaultValue']).to eq('test')
+ expect(configuration['value']).to eq('')
+ end
+
+ it "returns the project's sast configuration for analyzer variables" do
+ configuration = subject.dig('data', 'project', 'sastCiConfiguration', 'analyzers', 'nodes').first
+ expect(configuration['name']).to eq('brakeman')
+ expect(configuration['label']).to eq('Brakeman')
+ expect(configuration['enabled']).to eq(true)
+ end
+ end
+
it_behaves_like 'a GraphQL type with labels'
end