diff --git a/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb similarity index 70% rename from qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb rename to qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb index 9d44cd88bb73a1e495cf85cbd96a28a417d746c9..b67143276e881a662ceebf57aba02d3adf84192a 100644 --- a/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb @@ -4,6 +4,7 @@ module QA RSpec.describe 'Manage' do # TODO: `:reliable` should be added back once https://gitlab.com/gitlab-org/gitlab/-/issues/359278 is resolved describe 'User', :requires_admin, product_group: :authentication_and_authorization do + # rubocop:disable RSpec/InstanceVariable before(:all) do admin_api_client = Runtime::API::Client.as_admin @@ -11,21 +12,30 @@ module QA @user_api_client = Runtime::API::Client.new(:gitlab, user: @user) - @sandbox = create(:sandbox, path: "sandbox-for-access-termination-#{SecureRandom.hex(4)}", api_client: admin_api_client) + # Use UI to create the top-level group as the `top_level_group_creation_enabled` feature flag + # could be disabled on live environments + @sandbox = Resource::Sandbox.fabricate! do |sandbox_group| + sandbox_group.path = "sandbox-for-access-termination-#{SecureRandom.hex(4)}" + end - group = create(:group, path: "group-to-test-access-termination-#{SecureRandom.hex(8)}", sandbox: @sandbox, api_client: admin_api_client) + group = create(:group, path: "group-to-test-access-termination-#{SecureRandom.hex(8)}", sandbox: @sandbox) @sandbox.add_member(@user) - @project = create(:project, :with_readme, name: 'project-for-user-group-access-termination', group: group, api_client: admin_api_client) + @project = create(:project, :with_readme, name: 'project-for-user-group-access-termination', group: group) + end + + after(:all) do + @sandbox.remove_via_api! end - context 'after parent group membership termination' do + context 'when parent group membership is terminated' do before do @sandbox.remove_member(@user) end - it 'is not allowed to push code via the CLI', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347863' do + it 'is not allowed to push code via the CLI', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347863' do QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do expect do Resource::Repository::Push.fabricate! do |push| @@ -40,7 +50,8 @@ module QA 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 + it 'is not allowed to create a file via the API', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347864' do QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do expect do create(:file, @@ -51,7 +62,8 @@ module QA end end - it 'is not allowed to commit via the API', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347865' do + it 'is not allowed to commit via the API', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347865' do QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do expect do Resource::Repository::Commit.fabricate_via_api! do |commit| @@ -62,14 +74,12 @@ module QA 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.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, + /403 Forbidden - You are not allowed to push into this branch/) end end end - - after(:all) do - @sandbox.remove_via_api! - end + # rubocop:enable RSpec/InstanceVariable end end end