diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/requests/api/internal/kubernetes_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/requests/api/internal/kubernetes_spec.rb')
-rw-r--r-- | spec/requests/api/internal/kubernetes_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/requests/api/internal/kubernetes_spec.rb b/spec/requests/api/internal/kubernetes_spec.rb index 2acf6951d50..24422f7b0dd 100644 --- a/spec/requests/api/internal/kubernetes_spec.rb +++ b/spec/requests/api/internal/kubernetes_spec.rb @@ -93,6 +93,48 @@ RSpec.describe API::Internal::Kubernetes do end end + describe 'POST /internal/kubernetes/agent_configuration' do + def send_request(headers: {}, params: {}) + post api('/internal/kubernetes/agent_configuration'), params: params, headers: headers.reverse_merge(jwt_auth_headers) + end + + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, namespace: group) } + let_it_be(:agent) { create(:cluster_agent, project: project) } + let_it_be(:config) do + { + ci_access: { + groups: [ + { id: group.full_path, default_namespace: 'production' } + ], + projects: [ + { id: project.full_path, default_namespace: 'staging' } + ] + } + } + end + + include_examples 'authorization' + + context 'agent exists' do + it 'configures the agent and returns a 204' do + send_request(params: { agent_id: agent.id, agent_config: config }) + + expect(response).to have_gitlab_http_status(:no_content) + expect(agent.authorized_groups).to contain_exactly(group) + expect(agent.authorized_projects).to contain_exactly(project) + end + end + + context 'agent does not exist' do + it 'returns a 404' do + send_request(params: { agent_id: -1, agent_config: config }) + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end + describe 'GET /internal/kubernetes/agent_info' do def send_request(headers: {}, params: {}) get api('/internal/kubernetes/agent_info'), params: params, headers: headers.reverse_merge(jwt_auth_headers) |