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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'getting dependency proxy settings for a group', feature_category: :dependency_proxy do
using RSpec::Parameterized::TableSyntax
include GraphqlHelpers
let_it_be(:user) { create(:user) }
let_it_be_with_reload(:group) { create(:group) }
let(:dependency_proxy_group_setting_fields) do
<<~GQL
#{all_graphql_fields_for('dependency_proxy_setting'.classify, max_depth: 1)}
GQL
end
let(:fields) do
<<~GQL
#{query_graphql_field('dependency_proxy_setting', {}, dependency_proxy_group_setting_fields)}
GQL
end
let(:query) do
graphql_query_for(
'group',
{ 'fullPath' => group.full_path },
fields
)
end
let(:variables) { {} }
let(:dependency_proxy_group_setting_response) { graphql_data.dig('group', 'dependencyProxySetting') }
before do
stub_config(dependency_proxy: { enabled: true })
end
subject { post_graphql(query, current_user: user, variables: variables) }
shared_examples 'dependency proxy group setting query' do
it_behaves_like 'a working graphql query' do
before do
subject
end
end
context 'with different permissions' do
where(:group_visibility, :role, :access_granted) do
:private | :maintainer | true
:private | :developer | false
:private | :reporter | false
:private | :guest | false
:private | :anonymous | false
:public | :maintainer | true
:public | :developer | false
:public | :reporter | false
:public | :guest | false
:public | :anonymous | false
end
with_them do
before do
group.update_column(:visibility_level, Gitlab::VisibilityLevel.const_get(group_visibility.to_s.upcase, false))
group.add_member(user, role) unless role == :anonymous
end
it 'return the proper response' do
subject
if access_granted
expect(dependency_proxy_group_setting_response).to eq('enabled' => true)
else
expect(dependency_proxy_group_setting_response).to be_blank
end
end
end
end
end
context 'with the settings model created' do
before do
group.create_dependency_proxy_setting!(enabled: true)
end
it_behaves_like 'dependency proxy group setting query'
end
context 'without the settings model created' do
it_behaves_like 'dependency proxy group setting query'
end
end
|