Commit 72f91b7f authored by Sanad Liaquat's avatar Sanad Liaquat

Ensure correct group owner role

parent b3bb149e
...@@ -62,8 +62,8 @@ module QA ...@@ -62,8 +62,8 @@ module QA
let(:sync_users) { ['ENG User 2', 'ENG User 3'] } let(:sync_users) { ['ENG User 2', 'ENG User 3'] }
before do before do
create_users_via_api(ldap_users) @created_users = create_users_via_api(ldap_users)
group = create_group_and_add_user_via_api(owner_user, 'Synched-engineering-group') group = create_group_and_add_user_via_api(owner_user, 'Synched-engineering-group', Resource::Members::AccessLevel::OWNER)
signin_and_visit_group_as_user(owner_user, group) signin_and_visit_group_as_user(owner_user, group)
Page::Group::Menu.perform(&:go_to_ldap_sync_settings) Page::Group::Menu.perform(&:go_to_ldap_sync_settings)
...@@ -112,8 +112,10 @@ module QA ...@@ -112,8 +112,10 @@ module QA
let(:sync_users) { ['HR User 2', 'HR User 3'] } let(:sync_users) { ['HR User 2', 'HR User 3'] }
before do before do
create_users_via_api(ldap_users) @created_users = create_users_via_api(ldap_users)
group = create_group_and_add_user_via_api(owner_user, 'Synched-human-resources-group')
group = create_group_and_add_user_via_api(owner_user, 'Synched-human-resources-group', Resource::Members::AccessLevel::OWNER)
signin_and_visit_group_as_user(owner_user, group) signin_and_visit_group_as_user(owner_user, group)
Page::Group::Menu.perform(&:go_to_ldap_sync_settings) Page::Group::Menu.perform(&:go_to_ldap_sync_settings)
...@@ -126,14 +128,16 @@ module QA ...@@ -126,14 +128,16 @@ module QA
Page::Group::Menu.perform(&:click_group_members_item) Page::Group::Menu.perform(&:click_group_members_item)
end end
it 'has LDAP users synced', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/196040' do it 'has LDAP users synced' do
verify_users_synced(sync_users) verify_users_synced(sync_users)
end end
end end
def create_users_via_api(users) def create_users_via_api(users)
created_users = {}
users.each do |user| users.each do |user|
Resource::User.fabricate_via_api! do |resource| created_users[user[:username]] = Resource::User.fabricate_via_api! do |resource|
resource.username = user[:username] resource.username = user[:username]
resource.name = user[:name] resource.name = user[:name]
resource.email = user[:email] resource.email = user[:email]
...@@ -141,20 +145,15 @@ module QA ...@@ -141,20 +145,15 @@ module QA
resource.provider = user[:provider] resource.provider = user[:provider]
end end
end end
created_users
end end
def add_user_to_group_via_api(user, group) def create_group_and_add_user_via_api(user_name, group_name, role)
api_client = Runtime::API::Client.new(:gitlab)
response = get Runtime::API::Request.new(api_client, "/users?username=#{user}").url
post Runtime::API::Request.new(api_client, group.api_members_path).url, { user_id: parse_body(response).first[:id], access_level: '50' }
end
def create_group_and_add_user_via_api(user_name, group_name)
group = Resource::Group.fabricate_via_api! do |resource| group = Resource::Group.fabricate_via_api! do |resource|
resource.path = "#{group_name}-#{SecureRandom.hex(4)}" resource.path = "#{group_name}-#{SecureRandom.hex(4)}"
end end
add_user_to_group_via_api(user_name, group) group.add_member(@created_users[user_name], role)
group group
end end
......
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