summaryrefslogtreecommitdiff
path: root/spec/requests/api/project_clusters_spec.rb
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2019-01-08 17:35:54 -0600
committerMayra Cabrera <mcabrera@gitlab.com>2019-01-10 18:20:04 -0600
commit8b2fe985ddf29a490fef0fc2b76d6a6ac2d566fd (patch)
treef7eb12962d01b81fafa3e2450b90763f46f6b5b4 /spec/requests/api/project_clusters_spec.rb
parenta0f77090854b3510543dc42529d7353adab03da0 (diff)
downloadgitlab-ce-8b2fe985ddf29a490fef0fc2b76d6a6ac2d566fd.tar.gz
Restrict multiple clusters through API
Modifies authorize! method to accept a third param, and then use it in combination with 'add_cluster' policy to appropriately restrict adding multiple clusters Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56110
Diffstat (limited to 'spec/requests/api/project_clusters_spec.rb')
-rw-r--r--spec/requests/api/project_clusters_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/requests/api/project_clusters_spec.rb b/spec/requests/api/project_clusters_spec.rb
index e34164aa66a..9bab1f95150 100644
--- a/spec/requests/api/project_clusters_spec.rb
+++ b/spec/requests/api/project_clusters_spec.rb
@@ -266,6 +266,23 @@ describe API::ProjectClusters do
end
end
end
+
+ context 'when user tries to add multiple clusters' do
+ before do
+ create(:cluster, :provided_by_gcp, :project,
+ projects: [project])
+
+ post api("/projects/#{project.id}/clusters/user", current_user), params: cluster_params
+ end
+
+ it 'should respond with 403' do
+ expect(response).to have_gitlab_http_status(403)
+ end
+
+ it 'should return an appropriate message' do
+ expect(json_response['message']).to include('Instance does not support multiple Kubernetes clusters')
+ end
+ end
end
describe 'PUT /projects/:id/clusters/:cluster_id' do