summaryrefslogtreecommitdiff
path: root/spec/finders/labels_finder_spec.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-11-16 11:51:47 +0200
committerRobert Speicher <rspeicher@gmail.com>2016-11-16 15:04:51 +0200
commitc44474150c8a82e62ed1e0ed5758b1f38bbf7c41 (patch)
tree6cf408135deed1305d35b14061fb5c4ead245e53 /spec/finders/labels_finder_spec.rb
parentf27f9803833f72d7f62534c195539dcdef2e3ccd (diff)
downloadgitlab-ce-c44474150c8a82e62ed1e0ed5758b1f38bbf7c41.tar.gz
Limit labels returned for a specific project as an administrator
Prior, an administrator viewing a project's Labels page would see _all_ labels from every project they had access to, rather than only the labels of that specific project (if any). This was not an information disclosure, as admins have access to everything, but it was a performance issue.
Diffstat (limited to 'spec/finders/labels_finder_spec.rb')
-rw-r--r--spec/finders/labels_finder_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/finders/labels_finder_spec.rb b/spec/finders/labels_finder_spec.rb
index 10cfb66ec1c..9085cc8debf 100644
--- a/spec/finders/labels_finder_spec.rb
+++ b/spec/finders/labels_finder_spec.rb
@@ -64,6 +64,21 @@ describe LabelsFinder do
expect(finder.execute).to eq [group_label_2, project_label_1, group_label_1]
end
+
+ context 'as an administrator' do
+ it 'does not return labels from another project' do
+ # Purposefully creating a project with _nothing_ associated to it
+ isolated_project = create(:empty_project)
+ admin = create(:admin)
+
+ # project_3 has a label associated to it, which we don't want coming
+ # back when we ask for the isolated project's labels
+ project_3.team << [admin, :reporter]
+ finder = described_class.new(admin, project_id: isolated_project.id)
+
+ expect(finder.execute).to be_empty
+ end
+ end
end
context 'filtering by title' do