diff options
author | Mark Lapierre <mlapierre@gitlab.com> | 2019-06-13 13:56:46 +1000 |
---|---|---|
committer | Mark Lapierre <mlapierre@gitlab.com> | 2019-06-13 13:56:46 +1000 |
commit | 2d51d000cf80d1e1509fd9b1f441369441835eec (patch) | |
tree | 48f721844f7a053c13935af98ce3f85f5f936f3d | |
parent | 51d4eb34ba28fd71215077db6e15bc49886464ba (diff) | |
download | gitlab-ce-qa-ml-push-test-requires-admin.tar.gz |
Set push size limit via APIqa-ml-push-test-requires-admin
With an admin access token set as the env var
GITLAB_QA_ADMIN_ACCESS_TOKEN, the push size
limit test now only uses the API and CLI
-rw-r--r-- | qa/qa/runtime/env.rb | 20 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb | 56 |
2 files changed, 32 insertions, 44 deletions
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index 386c7028091..96f337dc081 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -18,6 +18,18 @@ module QA SUPPORTED_FEATURES end + def admin_password + ENV['GITLAB_ADMIN_PASSWORD'] + end + + def admin_username + ENV['GITLAB_ADMIN_USERNAME'] + end + + def admin_personal_access_token + ENV['GITLAB_QA_ADMIN_ACCESS_TOKEN'] + end + def debug? enabled?(ENV['QA_DEBUG'], default: false) end @@ -93,14 +105,6 @@ module QA ENV['GITLAB_PASSWORD'] end - def admin_username - ENV['GITLAB_ADMIN_USERNAME'] - end - - def admin_password - ENV['GITLAB_ADMIN_PASSWORD'] - end - def github_username ENV['GITHUB_USERNAME'] end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb index 2c91844e693..247cde38e52 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb @@ -3,71 +3,55 @@ module QA context 'Create', :requires_admin do describe 'push after setting the file size limit via admin/application_settings' do - before(:all) do - push = Resource::Repository::ProjectPush.fabricate! do |p| - p.file_name = 'README.md' - p.file_content = '# This is a test project' - p.commit_message = 'Add README.md' + before(:context) do + @project = Resource::Project.fabricate_via_api! do |p| + p.name = 'project-test-push-limit' + p.initialize_with_readme = true end - @project = push.project + @api_client = Runtime::API::Client.new(:gitlab, personal_access_token: Runtime::Env.admin_personal_access_token) end - before do - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.perform(&:sign_in_using_admin_credentials) - end - - after(:all) do + after(:context) do # need to set the default value after test # default value for file size limit is empty - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.perform(&:sign_in_using_admin_credentials) - - set_file_size_limit('') - - Page::Main::Menu.perform(&:sign_out) + set_file_size_limit(nil) end it 'push successful when the file size is under the limit' do set_file_size_limit(5) - expect(page).to have_content("Application settings saved successfully") - push = push_new_file('oversize_file_1.bin', wait_for_push: true) expect(push.output).not_to have_content 'remote: fatal: pack exceeds maximum allowed size' end it 'push fails when the file size is above the limit' do set_file_size_limit(1) - expect(page).to have_content("Application settings saved successfully") - expect { push_new_file('oversize_file_2.bin', wait_for_push: false) } .to raise_error(QA::Git::Repository::RepositoryCommandError, /remote: fatal: pack exceeds maximum allowed size/) end def set_file_size_limit(limit) - Page::Main::Menu.perform(&:click_admin_area) - Page::Admin::Menu.perform(&:go_to_general_settings) + request = Runtime::API::Request.new(@api_client, '/application/settings') + put request.url, receive_max_input_size: limit - Page::Admin::Settings::General.perform do |setting| - setting.expand_account_and_limit do |page| - page.set_max_file_size(limit) - page.save_settings - end - end + expect_status(200) + expect(json_body).to match( + a_hash_including(receive_max_input_size: limit) + ) end def push_new_file(file_name, wait_for_push: true) - @project.visit! - - Resource::Repository::ProjectPush.fabricate! do |p| - p.project = @project + commit_message = 'Adding a new file' + output = Resource::Repository::Push.fabricate! do |p| + p.repository_http_uri = @project.repository_http_location.uri p.file_name = file_name p.file_content = SecureRandom.random_bytes(2000000) - p.commit_message = 'Adding a new file' - p.wait_for_push = wait_for_push + p.commit_message = commit_message p.new_branch = false end + @project.wait_for_push commit_message + + output end end end |