diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-04 00:09:04 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-04 00:09:04 +0000 |
commit | 27a18afc7dba4e09a5ec78e5c251c31216d7792a (patch) | |
tree | 5dcc015be79e00de4133a66defe10bf1463ff827 /spec/requests/api/graphql | |
parent | 71c9d577ad563572050335dc261ba7673e3e566f (diff) | |
download | gitlab-ce-27a18afc7dba4e09a5ec78e5c251c31216d7792a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/graphql')
-rw-r--r-- | spec/requests/api/graphql/gitlab_schema_spec.rb | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/spec/requests/api/graphql/gitlab_schema_spec.rb b/spec/requests/api/graphql/gitlab_schema_spec.rb index 2cb8436662b..e10f0732852 100644 --- a/spec/requests/api/graphql/gitlab_schema_spec.rb +++ b/spec/requests/api/graphql/gitlab_schema_spec.rb @@ -67,24 +67,45 @@ describe 'GitlabSchema configurations' do end end - context 'a deep but simple recursive introspective query' do - it 'fails due to recursion' do - query = File.read(Rails.root.join('spec/fixtures/api/graphql/recursive-introspection.graphql')) + context 'failing queries' do + before do + allow(GitlabSchema).to receive(:max_query_recursion).and_return 1 + end - post_graphql(query, current_user: nil) + context 'a recursive introspective query' do + it 'fails due to recursion' do + query = File.read(Rails.root.join('spec/fixtures/api/graphql/recursive-introspection.graphql')) - expect_graphql_errors_to_include [/Recursive query/] + post_graphql(query, current_user: nil) + + expect_graphql_errors_to_include [/Recursive query/] + end end - end - context 'a deep recursive non-introspective query' do - it 'fails due to recursion, complexity and depth' do - allow(GitlabSchema).to receive(:max_query_complexity).and_return 1 - query = File.read(Rails.root.join('spec/fixtures/api/graphql/recursive-query.graphql')) + context 'a recursive non-introspective query' do + before do + allow(GitlabSchema).to receive(:max_query_complexity).and_return 1 + allow(GitlabSchema).to receive(:max_query_depth).and_return 1 + allow(GitlabSchema).to receive(:max_query_complexity).and_return 1 + end - post_graphql(query, current_user: nil) + shared_examples 'fails due to recursion, complexity and depth' do |fixture_file| + it 'fails due to recursion, complexity and depth' do + query = File.read(Rails.root.join(fixture_file)) + + post_graphql(query, current_user: nil) + + expect_graphql_errors_to_include [/Recursive query/, /exceeds max complexity/, /exceeds max depth/] + end + end - expect_graphql_errors_to_include [/Recursive query/, /exceeds max complexity/, /exceeds max depth/] + context 'using `nodes` notation' do + it_behaves_like 'fails due to recursion, complexity and depth', 'spec/fixtures/api/graphql/recursive-query-nodes.graphql' + end + + context 'using `edges -> node` notation' do + it_behaves_like 'fails due to recursion, complexity and depth', 'spec/fixtures/api/graphql/recursive-query-edges-node.graphql' + end end end end |