Commit 7483ed5b authored by Sanad Liaquat's avatar Sanad Liaquat

Added another test and some refactoring

parent 810024a1
......@@ -36,7 +36,7 @@
= f.label :filter, class: 'col-form-label col-sm-2' do
LDAP User filter
.col-sm-10
= f.text_field :filter, placeholder: 'Ex. (&(objectCategory=person)(objectClass=developer))', class: 'form-control xxlarge input-mn-300'
= f.text_field :filter, placeholder: 'Ex. (&(objectCategory=person)(objectClass=developer))', class: 'form-control xxlarge input-mn-300 qa-ldap-user-filter-text-field'
.form-text.text-muted
- ldap_link = link_to 'LDAP Search Filter Syntax', 'https://msdn.microsoft.com/en-us/library/aa746475(v=vs.85).aspx'
This query must use valid #{ldap_link}. Synchronize #{group.name}'s members with this LDAP user filter.
......
......@@ -11,6 +11,7 @@ module QA
view 'ee/app/views/ldap_group_links/_form.html.haml' do
element :ldap_group_cn_select
element :add_sync_button
element :ldap_user_filter_text_field
end
def set_sync_method(method)
......@@ -22,6 +23,10 @@ module QA
search_and_select(group_cn)
end
def set_user_filter(user_filter)
fill_element :ldap_user_filter_text_field, user_filter
end
def click_add_sync_button
click_element :add_sync_button
end
......
# frozen_string_literal: true
module QA
context 'Manage', :orchestrated, :ldap_tls do
# context 'Manage', :orchestrated, :ldap_tls do
context 'Manage' do
describe 'LDAP Group Sync' do
it 'Has LDAP user synced with group' do
it 'Has LDAP user synced using group cn method' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
# Login and Logout enguser3
Page::Main::Login.perform do |login_page|
login_page.sign_in_using_ldap_credentials(username: 'enguser3', password: 'password')
end
# Login users to create them
login_logout_users(['enguser3', 'enguser2'])
Page::Main::Menu.perform do |menu|
expect(menu).to have_personal_area
end
create_sandbox_group_with_user(user: 'enguser1', group_name:'Synched-engineering-group')
Page::Main::Menu.perform(&:sign_out)
EE::Page::Group::Menu.perform(&:go_to_ldap_sync_settings)
# Login and Logout enguser2
Page::Main::Login.perform do |login_page|
login_page.sign_in_using_ldap_credentials(username: 'enguser2', password: 'password')
EE::Page::Group::Settings::LDAPSync.perform do |page|
page.set_sync_method('LDAP Group cn')
page.set_group_cn('Engineering')
page.click_add_sync_button
end
Page::Main::Menu.perform do |menu|
expect(menu).to have_personal_area
end
EE::Page::Group::Menu.perform(&:go_to_members)
Page::Main::Menu.perform(&:sign_out)
verify_users_synched(['ENG User 2', 'ENG User 3'])
# Login enguser1
Page::Main::Login.perform do |login_page|
login_page.sign_in_using_ldap_credentials(username: 'enguser1', password: 'password')
end
end
Page::Main::Menu.perform do |menu|
expect(menu).to have_personal_area
end
it 'Has LDAP user synced using user filter method' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
# Create a sand box group
Resource::Sandbox.fabricate_via_browser_ui! do |resource|
resource.path = "Synched-engineering-group-#{SecureRandom.hex(4)}"
end
# Login users to create them
login_logout_users(['hruser3', 'hruser2'])
create_sandbox_group_with_user(user: 'hruser1', group_name:'Synched-human-resources-group')
EE::Page::Group::Menu.perform(&:go_to_ldap_sync_settings)
EE::Page::Group::Settings::LDAPSync.perform do |page|
page.set_sync_method('LDAP Group cn')
page.set_group_cn('Engineering')
page.set_user_filter('(&(objectClass=person)(cn=HR*))')
page.click_add_sync_button
end
EE::Page::Group::Menu.perform(&:go_to_members)
verify_users_synched(['HR User 2', 'HR User 3'])
end
def login_logout_users(users)
users.each do |user|
Page::Main::Login.perform do |login_page|
login_page.sign_in_using_ldap_credentials(username: user, password: 'password')
end
Page::Main::Menu.perform do |menu|
expect(menu).to have_personal_area
end
Page::Main::Menu.perform(&:sign_out)
end
end
def create_sandbox_group_with_user(user: nil, group_name: nil)
Page::Main::Login.perform do |login_page|
login_page.sign_in_using_ldap_credentials(username: user, password: 'password')
end
Page::Main::Menu.perform do |menu|
expect(menu).to have_personal_area
end
Resource::Sandbox.fabricate_via_browser_ui! do |resource|
resource.path = "#{group_name}-#{SecureRandom.hex(4)}"
end
end
def verify_users_synched(expected_users)
users_synchronised = false
EE::Page::Group::Members.perform do |page|
page.click_sync_now
users_synchronised = page.with_retry(reload: true) do
page.has_content?('ENG User 2') && page.has_content?('ENG User 3')
expected_users.map { |user| page.has_content?(user) }.reduce(true) { |a, b| a && b }
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