Commit edd23d67 authored by Terri Chu's avatar Terri Chu

Merge branch 'fix-agent-project-self-auth' into 'master'

Allow non-group Agent projects to authorize themselves

See merge request gitlab-org/gitlab!73917
parents 6909b4f6 6a5201ed
...@@ -86,7 +86,7 @@ module Clusters ...@@ -86,7 +86,7 @@ module Clusters
if group_root_ancestor? if group_root_ancestor?
root_ancestor.all_projects root_ancestor.all_projects
else else
::Project.none ::Project.id_in(project.id)
end end
end end
......
...@@ -113,6 +113,16 @@ RSpec.describe Clusters::Agents::RefreshAuthorizationService do ...@@ -113,6 +113,16 @@ RSpec.describe Clusters::Agents::RefreshAuthorizationService do
expect(modified_authorization.config).to eq({ 'default_namespace' => 'new-namespace' }) expect(modified_authorization.config).to eq({ 'default_namespace' => 'new-namespace' })
end end
context 'project does not belong to a group, and is authorizing itself' do
let(:root_ancestor) { create(:namespace) }
let(:added_project) { project }
it 'creates an authorization record for the project' do
expect(subject).to be_truthy
expect(agent.authorized_projects).to contain_exactly(added_project)
end
end
context 'config contains too many projects' do context 'config contains too many projects' do
before do before do
stub_const("#{described_class}::AUTHORIZED_ENTITY_LIMIT", 1) stub_const("#{described_class}::AUTHORIZED_ENTITY_LIMIT", 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment