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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-29 00:20:15 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-29 00:20:15 +0300
commit92d5172ad42ebc62eb78cac21b1e236ad6ace580 (patch)
treeca89437d4725caeb4e27682522061d3bab7e05b0 /spec/controllers/groups
parentf4a969f7f495978a7e656c69c929c9fdac111cff (diff)
Add latest changes from gitlab-org/security/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/controllers/groups')
-rw-r--r--spec/controllers/groups/clusters_controller_spec.rb33
1 files changed, 19 insertions, 14 deletions
diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb
index 1593e1290c4..81d5bc7770f 100644
--- a/spec/controllers/groups/clusters_controller_spec.rb
+++ b/spec/controllers/groups/clusters_controller_spec.rb
@@ -180,6 +180,8 @@ RSpec.describe Groups::ClustersController do
end
end
+ include_examples 'GET new cluster shared examples'
+
describe 'security' do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(group) }
@@ -493,14 +495,13 @@ RSpec.describe Groups::ClustersController do
end
describe 'POST authorize AWS role for EKS cluster' do
- let(:role_arn) { 'arn:aws:iam::123456789012:role/role-name' }
- let(:role_external_id) { '12345' }
+ let!(:role) { create(:aws_role, user: user) }
+ let(:role_arn) { 'arn:new-role' }
let(:params) do
{
cluster: {
- role_arn: role_arn,
- role_external_id: role_external_id
+ role_arn: role_arn
}
}
end
@@ -514,28 +515,32 @@ RSpec.describe Groups::ClustersController do
.and_return(double(execute: double))
end
- it 'creates an Aws::Role record' do
- expect { go }.to change { Aws::Role.count }
+ it 'updates the associated role with the supplied ARN' do
+ go
expect(response).to have_gitlab_http_status(:ok)
-
- role = Aws::Role.last
- expect(role.user).to eq user
- expect(role.role_arn).to eq role_arn
- expect(role.role_external_id).to eq role_external_id
+ expect(role.reload.role_arn).to eq(role_arn)
end
- context 'role cannot be created' do
+ context 'supplied role is invalid' do
let(:role_arn) { 'invalid-role' }
- it 'does not create a record' do
- expect { go }.not_to change { Aws::Role.count }
+ it 'does not update the associated role' do
+ expect { go }.not_to change { role.role_arn }
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
describe 'security' do
+ before do
+ allow_next_instance_of(Clusters::Aws::AuthorizeRoleService) do |service|
+ response = double(status: :ok, body: double)
+
+ allow(service).to receive(:execute).and_return(response)
+ end
+ end
+
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(group) }
it { expect { go }.to be_allowed_for(:maintainer).of(group) }