Commit ab505d3c authored by Ramya Authappan's avatar Ramya Authappan

Merge branch '222352-update-push-rules-test' into 'master'

Use non-member to test restriction by GitLab user

Closes #222352

See merge request gitlab-org/gitlab!34580
parents 211d5e63 7d291926
...@@ -60,13 +60,13 @@ module QA ...@@ -60,13 +60,13 @@ module QA
repository.use_lfs = use_lfs repository.use_lfs = use_lfs
username = 'GitLab QA' name = 'GitLab QA'
email = 'root@gitlab.com' email = 'root@gitlab.com'
if user if user
repository.username = user.username repository.username = user.username
repository.password = user.password repository.password = user.password
username = user.name name = user.name
email = user.email email = user.email
end end
...@@ -75,7 +75,7 @@ module QA ...@@ -75,7 +75,7 @@ module QA
end end
@output += repository.clone @output += repository.clone
repository.configure_identity(username, email) repository.configure_identity(name, email)
@output += repository.checkout(branch_name, new_branch: new_branch) @output += repository.checkout(branch_name, new_branch: new_branch)
......
...@@ -23,7 +23,6 @@ module QA ...@@ -23,7 +23,6 @@ module QA
push_rules.fill_commit_message_rule(@needed_phrase_limitation) push_rules.fill_commit_message_rule(@needed_phrase_limitation)
push_rules.fill_deny_commit_message_rule(@deny_message_phrase_limitation) push_rules.fill_deny_commit_message_rule(@deny_message_phrase_limitation)
push_rules.check_prevent_secrets push_rules.check_prevent_secrets
push_rules.check_restrict_author
push_rules.check_deny_delete_tag push_rules.check_deny_delete_tag
push_rules.click_submit push_rules.click_submit
end end
...@@ -81,11 +80,6 @@ module QA ...@@ -81,11 +80,6 @@ module QA
error: Regexp.escape('File name id_rsa was blacklisted by the pattern id_rsa$')) error: Regexp.escape('File name id_rsa was blacklisted by the pattern id_rsa$'))
end end
it 'restricts commits by user' do
expect_error_on_push(file: standard_file, user: @root,
error: Regexp.escape("Author '#{@root.email}' is not a member of team"))
end
it 'restricts removal of tag' do it 'restricts removal of tag' do
tag = Resource::Tag.fabricate_via_api! do |tag| tag = Resource::Tag.fabricate_via_api! do |tag|
tag.project = @project tag.project = @project
...@@ -98,6 +92,31 @@ module QA ...@@ -98,6 +92,31 @@ module QA
end end
end end
describe 'with commits restricted by author email to existing GitLab users' do
before do
prepare
Page::Project::Settings::Repository.perform do |repository|
repository.expand_push_rules do |push_rules|
push_rules.check_restrict_author
push_rules.click_submit
end
end
end
it 'rejects non-member users' do
non_member_user = Resource::User.new.tap do |user|
user.username = ''
user.password = ''
user.name = 'non_member_user'
user.email = 'non_member_user@non_member_user.com'
end
expect_error_on_push(file: standard_file, user: non_member_user,
error: Regexp.escape("Author '#{non_member_user.email}' is not a member of team"))
end
end
describe 'with commits restricted to verified emails' do describe 'with commits restricted to verified emails' do
before do before do
prepare prepare
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment