diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-25 19:31:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-25 19:32:06 +0300 |
commit | e92c90758eb4126acc84962d37bb273d6d87b27b (patch) | |
tree | 6d5f4ca9731a6aa76b80372276c68ab39e0f4149 /spec/graphql | |
parent | b485c8c3723dc5aaba15ab9fa258010d1ec66d61 (diff) |
Add latest changes from gitlab-org/security/gitlab@14-8-stable-ee
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/resolvers/snippets/blobs_resolver_spec.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/graphql/resolvers/snippets/blobs_resolver_spec.rb b/spec/graphql/resolvers/snippets/blobs_resolver_spec.rb index ebe286769cf..b5db7ac5748 100644 --- a/spec/graphql/resolvers/snippets/blobs_resolver_spec.rb +++ b/spec/graphql/resolvers/snippets/blobs_resolver_spec.rb @@ -13,11 +13,14 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do let_it_be(:current_user) { create(:user) } let_it_be(:snippet) { create(:personal_snippet, :private, :repository, author: current_user) } + let(:query_context) { {} } + context 'when user is not authorized' do let(:other_user) { create(:user) } it 'redacts the field' do expect(resolve_blobs(snippet, user: other_user)).to be_nil + expect(query_context[:unretrievable_blobs?]).to eq(false) end end @@ -28,6 +31,7 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do expect(result).to match_array(snippet.list_files.map do |file| have_attributes(path: file) end) + expect(query_context[:unretrievable_blobs?]).to eq(false) end end @@ -37,12 +41,14 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do path = 'CHANGELOG' expect(resolve_blobs(snippet, paths: [path])).to contain_exactly(have_attributes(path: path)) + expect(query_context[:unretrievable_blobs?]).to eq(false) end end context 'the argument does not match anything' do it 'returns an empty result' do expect(resolve_blobs(snippet, paths: ['does not exist'])).to be_empty + expect(query_context[:unretrievable_blobs?]).to eq(true) end end @@ -53,12 +59,15 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do expect(resolve_blobs(snippet, paths: paths)).to match_array(paths.map do |file| have_attributes(path: file) end) + expect(query_context[:unretrievable_blobs?]).to eq(false) end end end end - def resolve_blobs(snippet, user: current_user, paths: [], args: { paths: paths }) - resolve(described_class, args: args, ctx: { current_user: user }, obj: snippet) + def resolve_blobs(snippet, user: current_user, paths: [], args: { paths: paths }, has_unretrievable_blobs: false) + query_context[:current_user] = user + query_context[:unretrievable_blobs?] = has_unretrievable_blobs + resolve(described_class, args: args, ctx: query_context, obj: snippet) end end |