diff options
Diffstat (limited to 'qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb')
-rw-r--r-- | qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb b/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb index 6a31d173440..fe6c89f4ee4 100644 --- a/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb +++ b/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb @@ -31,44 +31,50 @@ module QA end it 'is not allowed to push code via the CLI', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347863' do - expect do - Resource::Repository::Push.fabricate! do |push| - push.repository_http_uri = @project.repository_http_location.uri - push.file_name = 'test.txt' - push.file_content = "# This is a test project named #{@project.name}" - push.commit_message = 'Add test.txt' - push.branch_name = "new_branch_#{SecureRandom.hex(8)}" - push.user = @user - end - end.to raise_error(QA::Support::Run::CommandError, /You are not allowed to push code to this project/) + QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do + expect do + Resource::Repository::Push.fabricate! do |push| + push.repository_http_uri = @project.repository_http_location.uri + push.file_name = 'test.txt' + push.file_content = "# This is a test project named #{@project.name}" + push.commit_message = 'Add test.txt' + push.branch_name = "new_branch_#{SecureRandom.hex(8)}" + push.user = @user + end + end.to raise_error(QA::Support::Run::CommandError, /You are not allowed to push code to this project/) + end end it 'is not allowed to create a file via the API', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347864' do - expect do - Resource::File.fabricate_via_api! do |file| - file.api_client = @user_api_client - file.project = @project - file.branch = "new_branch_#{SecureRandom.hex(8)}" - file.commit_message = 'Add new file' - file.name = 'test.txt' - file.content = "New file" - end - end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, /403 Forbidden/) + QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do + expect do + Resource::File.fabricate_via_api! do |file| + file.api_client = @user_api_client + file.project = @project + file.branch = "new_branch_#{SecureRandom.hex(8)}" + file.commit_message = 'Add new file' + file.name = 'test.txt' + file.content = "New file" + end + end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, /403 Forbidden/) + end end it 'is not allowed to commit via the API', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347865' do - expect do - Resource::Repository::Commit.fabricate_via_api! do |commit| - commit.api_client = @user_api_client - commit.project = @project - commit.branch = "new_branch_#{SecureRandom.hex(8)}" - commit.start_branch = @project.default_branch - commit.commit_message = 'Add new file' - commit.add_files([ - { file_path: 'test.txt', content: 'new file' } - ]) - end - end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, /403 Forbidden - You are not allowed to push into this branch/) + QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do + expect do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.api_client = @user_api_client + commit.project = @project + commit.branch = "new_branch_#{SecureRandom.hex(8)}" + commit.start_branch = @project.default_branch + commit.commit_message = 'Add new file' + commit.add_files([ + { file_path: 'test.txt', content: 'new file' } + ]) + end + end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, /403 Forbidden - You are not allowed to push into this branch/) + end end end |