1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Querying for integration exclusions', feature_category: :integrations do
include GraphqlHelpers
let_it_be(:project) { create(:project) }
let_it_be(:project2) { create(:project) }
let_it_be(:admin_user) { create(:admin) }
let_it_be(:user) { create(:user) }
let(:current_user) { admin_user }
let(:query) { graphql_query_for('integrationExclusions', args, fields) }
let(:args) { { 'integrationName' => :BEYOND_IDENTITY } }
let(:fields) do
<<~GRAPHQL
nodes {
project {
id
}
}
GRAPHQL
end
context 'when the user is authorized' do
let!(:instance_integration) { create(:beyond_identity_integration) }
let!(:integration_exclusion) do
create(:beyond_identity_integration, active: false, instance: false, project: project2, inherit_from_id: nil)
end
let!(:propagated_integration) do
create(:beyond_identity_integration, active: false, instance: false, project: project,
inherit_from_id: instance_integration.id)
end
before do
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query that returns data'
it 'returns projects that are custom exclusions' do
nodes = graphql_data['integrationExclusions']['nodes']
expect(nodes.size).to eq(1)
expect(nodes).to include(a_hash_including('project' => { 'id' => project2.to_global_id.to_s }))
end
end
context 'when the user is not authorized' do
let(:current_user) { user }
it 'responds with an error' do
post_graphql(query, current_user: current_user)
expect(graphql_errors.first['message']).to eq(
Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR
)
end
end
context 'when the user is not authenticated' do
let(:current_user) { nil }
it 'responds with an error' do
post_graphql(query, current_user: current_user)
expect(graphql_errors.first['message']).to eq(
Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR
)
end
end
end
|