diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
commit | 3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch) | |
tree | 3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /spec/services/clusters | |
parent | 9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff) |
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'spec/services/clusters')
-rw-r--r-- | spec/services/clusters/agent_tokens/create_service_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/services/clusters/agent_tokens/create_service_spec.rb b/spec/services/clusters/agent_tokens/create_service_spec.rb index 803bd947629..431d7ce2079 100644 --- a/spec/services/clusters/agent_tokens/create_service_spec.rb +++ b/spec/services/clusters/agent_tokens/create_service_spec.rb @@ -78,6 +78,33 @@ RSpec.describe Clusters::AgentTokens::CreateService, feature_category: :deployme expect(subject.message).to eq(["Name can't be blank"]) end end + + context 'when the active agent tokens limit is reached' do + before do + create(:cluster_agent_token, agent: cluster_agent) + create(:cluster_agent_token, agent: cluster_agent) + end + + it 'returns an error' do + expect(subject.status).to eq(:error) + expect(subject.message).to eq('An agent can have only two active tokens at a time') + end + + context 'when cluster_agents_limit_tokens_created feature flag is disabled' do + before do + stub_feature_flags(cluster_agents_limit_tokens_created: false) + end + + it 'creates a new token' do + expect { subject }.to change { ::Clusters::AgentToken.count }.by(1) + end + + it 'returns success status', :aggregate_failures do + expect(subject.status).to eq(:success) + expect(subject.message).to be_nil + end + end + end end end end |