Commit cbd73d86 authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'qa-shl-ldap-admin-sync-test-fix' into 'master'

Ensure correct group owner role and Un-quarantine test

See merge request gitlab-org/gitlab!24292
parents f6424953 72f91b7f
......@@ -62,8 +62,8 @@ module QA
let(:sync_users) { ['ENG User 2', 'ENG User 3'] }
before do
create_users_via_api(ldap_users)
group = create_group_and_add_user_via_api(owner_user, 'Synched-engineering-group')
@created_users = create_users_via_api(ldap_users)
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)
Page::Group::Menu.perform(&:go_to_ldap_sync_settings)
......@@ -112,8 +112,10 @@ module QA
let(:sync_users) { ['HR User 2', 'HR User 3'] }
before do
create_users_via_api(ldap_users)
group = create_group_and_add_user_via_api(owner_user, 'Synched-human-resources-group')
@created_users = create_users_via_api(ldap_users)
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)
Page::Group::Menu.perform(&:go_to_ldap_sync_settings)
......@@ -126,14 +128,16 @@ module QA
Page::Group::Menu.perform(&:click_group_members_item)
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)
end
end
def create_users_via_api(users)
created_users = {}
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.name = user[:name]
resource.email = user[:email]
......@@ -141,20 +145,15 @@ module QA
resource.provider = user[:provider]
end
end
created_users
end
def add_user_to_group_via_api(user, group)
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)
def create_group_and_add_user_via_api(user_name, group_name, role)
group = Resource::Group.fabricate_via_api! do |resource|
resource.path = "#{group_name}-#{SecureRandom.hex(4)}"
end
add_user_to_group_via_api(user_name, group)
group.add_member(@created_users[user_name], role)
group
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