Skip to content
Snippets Groups Projects
Verified Commit 83a72611 authored by Timo Furrer's avatar Timo Furrer :juggling:
Browse files

Protect Receptive Agents REST API with feature check

This feature is only for Ultimate
parent b7af4382
No related branches found
No related tags found
1 merge request!164184Move Receptive Agents feature to Ultimate
......@@ -6,6 +6,7 @@ class AgentUrlConfigurations < ::API::Base
before do
authenticate!
not_found! unless user_project.licensed_feature_available?(:cluster_receptive_agents)
not_found! unless ::Gitlab::CurrentSettings.receptive_cluster_agents_enabled
end
......
......@@ -12,7 +12,23 @@
project.add_maintainer(user)
end
before do
stub_licensed_features(cluster_receptive_agents: true)
end
describe 'GET /projects/:id/cluster_agents/:agent_id/url_configurations' do
context 'when receptive agents feature is disabled because of the tier' do
before do
stub_licensed_features(cluster_receptive_agents: false)
end
it 'returns not found' do
get api("/projects/#{project.id}/cluster_agents/#{agent.id}/url_configurations", user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when receptive agents are enabled' do
before do
stub_application_setting(receptive_cluster_agents_enabled: true)
......@@ -74,6 +90,18 @@
describe 'GET /projects/:id/cluster_agents/:agent_id/url_configurations/:url_configuration_id' do
let_it_be(:url_configuration) { create(:cluster_agent_url_configuration, :public_key_auth, agent: agent) }
context 'when receptive agents feature is disabled because of the tier' do
before do
stub_licensed_features(cluster_receptive_agents: false)
end
it 'returns not found' do
get api("/projects/#{project.id}/cluster_agents/#{agent.id}/url_configurations/#{url_configuration.id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when receptive agents are enabled' do
before do
stub_application_setting(receptive_cluster_agents_enabled: true)
......@@ -144,6 +172,20 @@
end
describe 'POST /projects/:id/cluster_agents/:agent_id/url_configurations' do
context 'when receptive agents feature is disabled because of the tier' do
let_it_be(:params) { { url: 'grpcs://localhost:4242' } }
before do
stub_licensed_features(cluster_receptive_agents: false)
end
it 'returns not found' do
post(api("/projects/#{project.id}/cluster_agents/#{agent.id}/url_configurations", user), params: params)
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when receptive agents are enabled' do
before do
stub_application_setting(receptive_cluster_agents_enabled: true)
......@@ -304,6 +346,19 @@
describe 'DELETE /projects/:id/cluster_agents/:agent_id/url_configurations/:url_configuration_id' do
let_it_be(:url_configuration) { create(:cluster_agent_url_configuration, :public_key_auth, agent: agent) }
context 'when receptive agents feature is disabled because of the tier' do
before do
stub_licensed_features(cluster_receptive_agents: false)
end
it 'returns not found' do
delete api("/projects/#{project.id}/cluster_agents/#{agent.id}/url_configurations/#{url_configuration.id}",
user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when receptive agents are enabled' do
before do
stub_application_setting(receptive_cluster_agents_enabled: true)
......@@ -355,8 +410,6 @@
end
context 'when receptive agents are disabled' do
let_it_be(:params) { { url: 'grpcs://localhost:4242' } }
before do
stub_application_setting(receptive_cluster_agents_enabled: false)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment