Commit 9514d151 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'qa-testcases-195-instance-audit-logs' into 'master'

Add test for instance audit logs

Closes gitlab-org/quality/testcases#195

See merge request gitlab-org/gitlab!16610
parents 0794d0ea 4c93691c
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
.float-right .float-right
- if impersonation_enabled? && @user != current_user && @user.can?(:log_in) - if impersonation_enabled? && @user != current_user && @user.can?(:log_in)
= link_to 'Impersonate', impersonate_admin_user_path(@user), method: :post, class: "btn btn-nr btn-grouped btn-info" = link_to 'Impersonate', impersonate_admin_user_path(@user), method: :post, class: "btn btn-nr btn-grouped btn-info", data: { qa_selector: 'impersonate_user_link' }
= link_to edit_admin_user_path(@user), class: "btn btn-nr btn-grouped" do = link_to edit_admin_user_path(@user), class: "btn btn-nr btn-grouped" do
%i.fa.fa-pencil-square-o %i.fa.fa-pencil-square-o
Edit Edit
......
.gl-responsive-table-row{ role: 'row' } .gl-responsive-table-row{ role: 'row', data: { qa_selector: 'user_row_content' } }
.table-section.section-40 .table-section.section-40
.table-mobile-header{ role: 'rowheader' } .table-mobile-header{ role: 'rowheader' }
= _('Name') = _('Name')
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
.row-main-content .row-main-content
.row-title.str-truncated-100 .row-title.str-truncated-100
= image_tag avatar_icon_for_user(user), class: 'avatar s16 d-xs-flex d-md-none mr-1 prepend-top-2', alt: _('Avatar for %{name}') % { name: sanitize_name(user.name) } = image_tag avatar_icon_for_user(user), class: 'avatar s16 d-xs-flex d-md-none mr-1 prepend-top-2', alt: _('Avatar for %{name}') % { name: sanitize_name(user.name) }
= link_to user.name, admin_user_path(user), class: 'text-plain js-user-link', data: { user_id: user.id } = link_to user.name, admin_user_path(user), class: 'text-plain js-user-link', data: { user_id: user.id, qa_selector: 'username_link' }
= render_if_exists 'admin/users/user_listing_note', user: user = render_if_exists 'admin/users/user_listing_note', user: user
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
= hidden_field_tag "filter", h(params[:filter]) = hidden_field_tag "filter", h(params[:filter])
.search-holder .search-holder
.search-field-holder .search-field-holder
= search_field_tag :search_query, params[:search_query], placeholder: s_('AdminUsers|Search by name, email or username'), class: 'form-control search-text-input js-search-input', spellcheck: false = search_field_tag :search_query, params[:search_query], placeholder: s_('AdminUsers|Search by name, email or username'), class: 'form-control search-text-input js-search-input', spellcheck: false, data: { qa_selector: 'user_search_field' }
- if @sort.present? - if @sort.present?
= hidden_field_tag :sort, @sort = hidden_field_tag :sort, @sort
= icon("search", class: "search-icon") = icon("search", class: "search-icon")
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
= render 'layouts/header/current_user_dropdown' = render 'layouts/header/current_user_dropdown'
- if has_impersonation_link - if has_impersonation_link
%li.nav-item.impersonation.ml-0 %li.nav-item.impersonation.ml-0
= link_to admin_impersonation_path, class: 'nav-link impersonation-btn', method: :delete, title: _('Stop impersonation'), aria: { label: _('Stop impersonation') }, data: { toggle: 'tooltip', placement: 'bottom', container: 'body' } do = link_to admin_impersonation_path, class: 'nav-link impersonation-btn', method: :delete, title: _('Stop impersonation'), aria: { label: _('Stop impersonation') }, data: { toggle: 'tooltip', placement: 'bottom', container: 'body', qa_selector: 'stop_impersonation_link' } do
= icon('user-secret') = icon('user-secret')
- if header_link?(:sign_in) - if header_link?(:sign_in)
%li.nav-item %li.nav-item
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
= sprite_icon('admin', size: 24) = sprite_icon('admin', size: 24)
.sidebar-context-title .sidebar-context-title
= _('Admin Area') = _('Admin Area')
%ul.sidebar-top-level-items %ul.sidebar-top-level-items{ data: { qa_selector: 'admin_sidebar_overview_submenu_content' } }
= nav_link(controller: %w(dashboard admin admin/projects users groups jobs runners gitaly_servers), html_options: {class: 'home'}) do = nav_link(controller: %w(dashboard admin admin/projects users groups jobs runners gitaly_servers), html_options: {class: 'home'}) do
= link_to admin_root_path, class: 'shortcuts-tree' do = link_to admin_root_path, class: 'shortcuts-tree' do
.nav-icon-container .nav-icon-container
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
%span %span
= _('Projects') = _('Projects')
= nav_link(controller: :users) do = nav_link(controller: :users) do
= link_to admin_users_path, title: _('Users') do = link_to admin_users_path, title: _('Users') , data: { qa_selector: 'users_overview_link' } do
%span %span
= _('Users') = _('Users')
= nav_link(controller: :groups) do = nav_link(controller: :groups) do
...@@ -49,13 +49,13 @@ ...@@ -49,13 +49,13 @@
= _('Gitaly Servers') = _('Gitaly Servers')
= nav_link(controller: admin_monitoring_nav_links) do = nav_link(controller: admin_monitoring_nav_links) do
= link_to admin_system_info_path do = link_to admin_system_info_path, data: { qa_selector: 'admin_monitoring_link' } do
.nav-icon-container .nav-icon-container
= sprite_icon('monitor') = sprite_icon('monitor')
%span.nav-item-name %span.nav-item-name
= _('Monitoring') = _('Monitoring')
%ul.sidebar-sub-level-items %ul.sidebar-sub-level-items{ data: { qa_selector: 'admin_sidebar_monitoring_submenu_content' } }
= nav_link(controller: %w(system_info background_jobs logs health_check requests_profiles), html_options: { class: "fly-out-top-item" } ) do = nav_link(controller: %w(system_info background_jobs logs health_check requests_profiles), html_options: { class: "fly-out-top-item" } ) do
= link_to admin_system_info_path do = link_to admin_system_info_path do
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
%span.nav-item-name.qa-admin-settings-item %span.nav-item-name.qa-admin-settings-item
= _('Settings') = _('Settings')
%ul.sidebar-sub-level-items.qa-admin-sidebar-submenu %ul.sidebar-sub-level-items.qa-admin-sidebar-settings-submenu
= nav_link(controller: :application_settings, html_options: { class: "fly-out-top-item" } ) do = nav_link(controller: :application_settings, html_options: { class: "fly-out-top-item" } ) do
= link_to admin_application_settings_path do = link_to admin_application_settings_path do
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Access Tokens') = _('Access Tokens')
= nav_link(controller: :emails) do = nav_link(controller: :emails) do
= link_to profile_emails_path do = link_to profile_emails_path, data: { qa_selector: 'profile_emails_link' } do
.nav-icon-container .nav-icon-container
= sprite_icon('mail') = sprite_icon('mail')
%span.nav-item-name %span.nav-item-name
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
= _('Emails') = _('Emails')
- if current_user.allow_password_authentication? - if current_user.allow_password_authentication?
= nav_link(controller: :passwords) do = nav_link(controller: :passwords) do
= link_to edit_profile_password_path do = link_to edit_profile_password_path , data: { qa_selector: 'profile_password_link' } do
.nav-icon-container .nav-icon-container
= sprite_icon('lock') = sprite_icon('lock')
%span.nav-item-name %span.nav-item-name
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
= form_for 'email', url: profile_emails_path do |f| = form_for 'email', url: profile_emails_path do |f|
.form-group .form-group
= f.label :email, _('Email'), class: 'label-bold' = f.label :email, _('Email'), class: 'label-bold'
= f.text_field :email, class: 'form-control' = f.text_field :email, class: 'form-control', data: { qa_selector: 'email_address_field' }
.prepend-top-default .prepend-top-default
= f.submit _('Add email address'), class: 'btn btn-success' = f.submit _('Add email address'), class: 'btn btn-success', data: { qa_selector: 'add_email_address_button' }
%hr %hr
%h4.prepend-top-0 %h4.prepend-top-0
= _('Linked emails (%{email_count})') % { email_count: @emails.count + 1 } = _('Linked emails (%{email_count})') % { email_count: @emails.count + 1 }
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
- if @primary_email === current_user.notification_email - if @primary_email === current_user.notification_email
%span.badge.badge-info= s_('Profiles|Default notification email') %span.badge.badge-info= s_('Profiles|Default notification email')
- @emails.each do |email| - @emails.each do |email|
%li %li{ data: { qa_selector: 'email_row_content' } }
= render partial: 'shared/email_with_badge', locals: { email: email.email, verified: email.confirmed? } = render partial: 'shared/email_with_badge', locals: { email: email.email, verified: email.confirmed? }
%span.float-right %span.float-right
- if email.email === current_user.commit_email - if email.email === current_user.commit_email
...@@ -58,6 +58,6 @@ ...@@ -58,6 +58,6 @@
- confirm_title = "#{email.confirmation_sent_at ? _('Resend confirmation email') : _('Send confirmation email')}" - confirm_title = "#{email.confirmation_sent_at ? _('Resend confirmation email') : _('Send confirmation email')}"
= link_to confirm_title, resend_confirmation_instructions_profile_email_path(email), method: :put, class: 'btn btn-sm btn-warning prepend-left-10' = link_to confirm_title, resend_confirmation_instructions_profile_email_path(email), method: :put, class: 'btn btn-sm btn-warning prepend-left-10'
= link_to profile_email_path(email), data: { confirm: _('Are you sure?')}, method: :delete, class: 'btn btn-sm btn-danger prepend-left-10' do = link_to profile_email_path(email), data: { confirm: _('Are you sure?'), qa_selector: 'delete_email_link'}, method: :delete, class: 'btn btn-sm btn-danger prepend-left-10' do
%span.sr-only= _('Remove') %span.sr-only= _('Remove')
= icon('trash') = icon('trash')
...@@ -20,16 +20,16 @@ ...@@ -20,16 +20,16 @@
- unless @user.password_automatically_set? - unless @user.password_automatically_set?
.form-group .form-group
= f.label :current_password, _('Current password'), class: 'label-bold' = f.label :current_password, _('Current password'), class: 'label-bold'
= f.password_field :current_password, required: true, class: 'form-control' = f.password_field :current_password, required: true, class: 'form-control', data: { qa_selector: 'current_password_field' }
%p.form-text.text-muted %p.form-text.text-muted
= _('You must provide your current password in order to change it.') = _('You must provide your current password in order to change it.')
.form-group .form-group
= f.label :password, _('New password'), class: 'label-bold' = f.label :password, _('New password'), class: 'label-bold'
= f.password_field :password, required: true, class: 'form-control' = f.password_field :password, required: true, class: 'form-control', data: { qa_selector: 'new_password_field' }
.form-group .form-group
= f.label :password_confirmation, _('Password confirmation'), class: 'label-bold' = f.label :password_confirmation, _('Password confirmation'), class: 'label-bold'
= f.password_field :password_confirmation, required: true, class: 'form-control' = f.password_field :password_confirmation, required: true, class: 'form-control', data: { qa_selector: 'confirm_password_field' }
.prepend-top-default.append-bottom-default .prepend-top-default.append-bottom-default
= f.submit _('Save password'), class: "btn btn-success append-right-10" = f.submit _('Save password'), class: "btn btn-success append-right-10", data: { qa_selector: 'save_password_button' }
- unless @user.password_automatically_set? - unless @user.password_automatically_set?
= link_to _('I forgot my password'), reset_profile_password_path, method: :put, class: "account-btn-link" = link_to _('I forgot my password'), reset_profile_password_path, method: :put, class: "account-btn-link"
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
%th Date %th Date
%tbody %tbody
- @events.map(&:present).each do |event| - @events.map(&:present).each do |event|
%tr %tr{ data: { qa_selector: 'admin_audit_log_row_content' } }
%td %td
- if (author_link = event.author_name) - if (author_link = event.author_name)
= author_link = author_link
......
- if License.feature_available?(:admin_audit_log) - if License.feature_available?(:admin_audit_log)
= nav_link path: 'audit_logs#index' do = nav_link path: 'audit_logs#index' do
= link_to admin_audit_logs_path, title: 'Audit Log' do = link_to admin_audit_logs_path, title: 'Audit Log', data: { qa_selector: 'admin_monitoring_audit_logs_link' } do
%span %span
Audit Log Audit Log
...@@ -290,6 +290,8 @@ module QA ...@@ -290,6 +290,8 @@ module QA
autoload :Menu, 'qa/page/profile/menu' autoload :Menu, 'qa/page/profile/menu'
autoload :PersonalAccessTokens, 'qa/page/profile/personal_access_tokens' autoload :PersonalAccessTokens, 'qa/page/profile/personal_access_tokens'
autoload :SSHKeys, 'qa/page/profile/ssh_keys' autoload :SSHKeys, 'qa/page/profile/ssh_keys'
autoload :Emails, 'qa/page/profile/emails'
autoload :Password, 'qa/page/profile/password'
autoload :TwoFactorAuth, 'qa/page/profile/two_factor_auth' autoload :TwoFactorAuth, 'qa/page/profile/two_factor_auth'
end end
...@@ -332,6 +334,13 @@ module QA ...@@ -332,6 +334,13 @@ module QA
autoload :PerformanceBar, 'qa/page/admin/settings/component/performance_bar' autoload :PerformanceBar, 'qa/page/admin/settings/component/performance_bar'
end end
end end
module Overview
module Users
autoload :Index, 'qa/page/admin/overview/users/index'
autoload :Show, 'qa/page/admin/overview/users/show'
end
end
end end
module Mattermost module Mattermost
......
...@@ -61,6 +61,10 @@ module QA ...@@ -61,6 +61,10 @@ module QA
end end
end end
module Monitoring
autoload :AuditLog, 'qa/ee/page/admin/monitoring/audit_log.rb'
end
module Settings module Settings
autoload :Templates, 'qa/ee/page/admin/settings/templates' autoload :Templates, 'qa/ee/page/admin/settings/templates'
autoload :Integration, 'qa/ee/page/admin/settings/integration' autoload :Integration, 'qa/ee/page/admin/settings/integration'
......
...@@ -18,6 +18,18 @@ module QA ...@@ -18,6 +18,18 @@ module QA
view 'ee/app/views/layouts/nav/sidebar/_licenses_link.html.haml' do view 'ee/app/views/layouts/nav/sidebar/_licenses_link.html.haml' do
element :link_license_menu element :link_license_menu
end end
view 'ee/app/views/layouts/nav/ee/admin/_new_monitoring_sidebar.html.haml' do
element :admin_monitoring_audit_logs_link
end
end
end
def go_to_monitoring_audit_logs
hover_element(:admin_monitoring_link) do
within_submenu(:admin_sidebar_monitoring_submenu_content) do
click_element :admin_monitoring_audit_logs_link
end
end end
end end
...@@ -30,7 +42,7 @@ module QA ...@@ -30,7 +42,7 @@ module QA
end end
def go_to_template_settings def go_to_template_settings
hover_settings do hover_element(:admin_settings_item) do
within_submenu do within_submenu do
click_element :admin_settings_template_item click_element :admin_settings_template_item
end end
......
# frozen_string_literal: true
module QA
module EE
module Page
module Admin
module Monitoring
class AuditLog < QA::Page::Base
view 'ee/app/views/admin/audit_logs/index.html.haml' do
element :admin_audit_log_row_content
end
def has_audit_log_row?(text)
has_element?(:admin_audit_log_row_content, text: text)
end
end
end
end
end
end
end
...@@ -6,12 +6,16 @@ module QA ...@@ -6,12 +6,16 @@ module QA
class Menu < Page::Base class Menu < Page::Base
view 'app/views/layouts/nav/sidebar/_admin.html.haml' do view 'app/views/layouts/nav/sidebar/_admin.html.haml' do
element :admin_sidebar element :admin_sidebar
element :admin_sidebar_submenu element :admin_sidebar_settings_submenu
element :admin_settings_item element :admin_settings_item
element :admin_settings_repository_item element :admin_settings_repository_item
element :admin_settings_general_item element :admin_settings_general_item
element :admin_settings_metrics_and_profiling_item element :admin_settings_metrics_and_profiling_item
element :admin_settings_preferences_link element :admin_settings_preferences_link
element :admin_monitoring_link
element :admin_sidebar_monitoring_submenu_content
element :admin_sidebar_overview_submenu_content
element :users_overview_link
end end
view 'app/views/layouts/nav/sidebar/_admin.html.haml' do view 'app/views/layouts/nav/sidebar/_admin.html.haml' do
...@@ -19,59 +23,65 @@ module QA ...@@ -19,59 +23,65 @@ module QA
end end
def go_to_preferences_settings def go_to_preferences_settings
hover_settings do hover_element(:admin_settings_item) do
within_submenu do within_submenu(:admin_sidebar_settings_submenu) do
click_element :admin_settings_preferences_link click_element :admin_settings_preferences_link
end end
end end
end end
def go_to_repository_settings def go_to_repository_settings
hover_settings do hover_element(:admin_settings_item) do
within_submenu do within_submenu(:admin_sidebar_settings_submenu) do
click_element :admin_settings_repository_item click_element :admin_settings_repository_item
end end
end end
end end
def go_to_integration_settings def go_to_integration_settings
hover_settings do hover_element(:admin_settings_item) do
within_submenu do within_submenu(:admin_sidebar_settings_submenu) do
click_element :integration_settings_link click_element :integration_settings_link
end end
end end
end end
def go_to_general_settings def go_to_general_settings
hover_settings do hover_element(:admin_settings_item) do
within_submenu do within_submenu(:admin_sidebar_settings_submenu) do
click_element :admin_settings_general_item click_element :admin_settings_general_item
end end
end end
end end
def go_to_metrics_and_profiling_settings def go_to_metrics_and_profiling_settings
hover_settings do hover_element(:admin_settings_item) do
within_submenu do within_submenu(:admin_sidebar_settings_submenu) do
click_element :admin_settings_metrics_and_profiling_item click_element :admin_settings_metrics_and_profiling_item
end end
end end
end end
def go_to_network_settings def go_to_network_settings
hover_settings do hover_element(:admin_settings_item) do
within_submenu do within_submenu(:admin_sidebar_settings_submenu) do
click_element :admin_settings_network_item click_element :admin_settings_network_item
end end
end end
end end
def go_to_users_overview
within_submenu(:admin_sidebar_overview_submenu_content) do
click_element :users_overview_link
end
end
private private
def hover_settings def hover_element(element)
within_sidebar do within_sidebar do
scroll_to_element(:admin_settings_item) scroll_to_element(element)
find_element(:admin_settings_item).hover find_element(element).hover
yield yield
end end
...@@ -83,8 +93,8 @@ module QA ...@@ -83,8 +93,8 @@ module QA
end end
end end
def within_submenu def within_submenu(element)
within_element(:admin_sidebar_submenu) do within_element(element) do
yield yield
end end
end end
......
# frozen_string_literal: true
module QA
module Page
module Admin
module Overview
module Users
class Index < QA::Page::Base
view 'app/views/admin/users/index.html.haml' do
element :user_search_field
end
view 'app/views/admin/users/_user.html.haml' do
element :user_row_content
end
view 'app/views/admin/users/_user_detail.html.haml' do
element :username_link
end
def search_user(username)
find_element(:user_search_field).set(username).send_keys(:return)
end
def click_user(username)
within_element(:user_row_content, text: username) do
click_element(:username_link)
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Admin
module Overview
module Users
class Show < QA::Page::Base
view 'app/views/admin/users/_head.html.haml' do
element :impersonate_user_link
end
def click_impersonate_user
click_element(:impersonate_user_link)
end
end
end
end
end
end
end
...@@ -42,7 +42,7 @@ module QA ...@@ -42,7 +42,7 @@ module QA
element :login_page, required: true element :login_page, required: true
end end
def sign_in_using_credentials(user = nil) def sign_in_using_credentials(user: nil, skip_page_validation: false)
# Don't try to log-in if we're already logged-in # Don't try to log-in if we're already logged-in
return if Page::Main::Menu.perform(&:signed_in?) return if Page::Main::Menu.perform(&:signed_in?)
...@@ -52,9 +52,9 @@ module QA ...@@ -52,9 +52,9 @@ module QA
raise NotImplementedError if Runtime::User.ldap_user? && user&.credentials_given? raise NotImplementedError if Runtime::User.ldap_user? && user&.credentials_given?
if Runtime::User.ldap_user? if Runtime::User.ldap_user?
sign_in_using_ldap_credentials(user || Runtime::User) sign_in_using_ldap_credentials(user: user || Runtime::User)
else else
sign_in_using_gitlab_credentials(user || Runtime::User) sign_in_using_gitlab_credentials(user: user || Runtime::User, skip_page_validation: skip_page_validation)
end end
end end
end end
...@@ -68,13 +68,13 @@ module QA ...@@ -68,13 +68,13 @@ module QA
using_wait_time 0 do using_wait_time 0 do
set_initial_password_if_present set_initial_password_if_present
sign_in_using_gitlab_credentials(admin) sign_in_using_gitlab_credentials(user: admin)
end end
Page::Main::Menu.perform(&:has_personal_area?) Page::Main::Menu.perform(&:has_personal_area?)
end end
def sign_in_using_ldap_credentials(user) def sign_in_using_ldap_credentials(user:)
Page::Main::Menu.perform(&:sign_out_if_signed_in) Page::Main::Menu.perform(&:sign_out_if_signed_in)
using_wait_time 0 do using_wait_time 0 do
...@@ -148,18 +148,18 @@ module QA ...@@ -148,18 +148,18 @@ module QA
def sign_out_and_sign_in_as(user:) def sign_out_and_sign_in_as(user:)
Menu.perform(&:sign_out_if_signed_in) Menu.perform(&:sign_out_if_signed_in)
has_sign_in_tab? has_sign_in_tab?
sign_in_using_credentials(user) sign_in_using_credentials(user: user)
end end
private private
def sign_in_using_gitlab_credentials(user) def sign_in_using_gitlab_credentials(user:, skip_page_validation: false)
switch_to_sign_in_tab if has_sign_in_tab? switch_to_sign_in_tab if has_sign_in_tab?
switch_to_standard_tab if has_standard_tab? switch_to_standard_tab if has_standard_tab?
fill_element :login_field, user.username fill_element :login_field, user.username
fill_element :password_field, user.password fill_element :password_field, user.password
click_element :sign_in_button, Page::Main::Menu click_element :sign_in_button, !skip_page_validation && Page::Main::Menu
end end
def set_initial_password_if_present def set_initial_password_if_present
......
...@@ -13,6 +13,7 @@ module QA ...@@ -13,6 +13,7 @@ module QA
element :navbar, required: true element :navbar, required: true
element :user_avatar, required: true element :user_avatar, required: true
element :user_menu, required: true element :user_menu, required: true
element :stop_impersonation_link
end end
view 'app/views/layouts/nav/_dashboard.html.haml' do view 'app/views/layouts/nav/_dashboard.html.haml' do
...@@ -95,6 +96,10 @@ module QA ...@@ -95,6 +96,10 @@ module QA
has_element?(:admin_area_link, wait: wait) has_element?(:admin_area_link, wait: wait)
end end
def click_stop_impersonation_link
click_element(:stop_impersonation_link)
end
private private
def within_top_menu def within_top_menu
......
# frozen_string_literal: true
module QA
module Page
module Profile
class Emails < Page::Base
view 'app/views/profiles/emails/index.html.haml' do
element :email_address_field
element :add_email_address_button
element :email_row_content
element :delete_email_link
end
def add_email_address(email_address)
find_element(:email_address_field).set email_address
click_element(:add_email_address_button)
end
def delete_email_address(email_address)
page.accept_alert do
within_element(:email_row_content, text: email_address) do
click_element(:delete_email_link)
end
end
end
end
end
end
end
...@@ -9,6 +9,8 @@ module QA ...@@ -9,6 +9,8 @@ module QA
element :access_token_title, 'Access Tokens' # rubocop:disable QA/ElementWithPattern element :access_token_title, 'Access Tokens' # rubocop:disable QA/ElementWithPattern
element :top_level_items, '.sidebar-top-level-items' # rubocop:disable QA/ElementWithPattern element :top_level_items, '.sidebar-top-level-items' # rubocop:disable QA/ElementWithPattern
element :ssh_keys, 'SSH Keys' # rubocop:disable QA/ElementWithPattern element :ssh_keys, 'SSH Keys' # rubocop:disable QA/ElementWithPattern
element :profile_emails_link
element :profile_password_link
end end
def click_access_tokens def click_access_tokens
...@@ -23,6 +25,18 @@ module QA ...@@ -23,6 +25,18 @@ module QA
end end
end end
def click_emails
within_sidebar do
click_element(:profile_emails_link)
end
end
def click_password
within_sidebar do
click_element(:profile_password_link)
end
end
private private
def within_sidebar def within_sidebar
......
# frozen_string_literal: true
module QA
module Page
module Profile
class Password < Page::Base
view 'app/views/profiles/passwords/edit.html.haml' do
element :current_password_field
element :new_password_field
element :confirm_password_field
element :save_password_button
end
def update_password(new_password, current_password)
find_element(:current_password_field).set current_password
find_element(:new_password_field).set new_password
find_element(:confirm_password_field).set new_password
click_element(:save_password_button)
end
end
end
end
end
...@@ -30,7 +30,7 @@ module QA ...@@ -30,7 +30,7 @@ module QA
Page::Main::Menu.perform(&:sign_out) Page::Main::Menu.perform(&:sign_out)
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform do |login| Page::Main::Login.perform do |login|
login.sign_in_using_credentials(user) login.sign_in_using_credentials(user: user)
end end
upstream.project.visit! upstream.project.visit!
......
...@@ -53,7 +53,7 @@ module QA ...@@ -53,7 +53,7 @@ module QA
if credentials_given? if credentials_given?
Page::Main::Login.perform do |login| Page::Main::Login.perform do |login|
login.sign_in_using_credentials(self) login.sign_in_using_credentials(user: self)
end end
else else
Page::Main::Login.perform do |login| Page::Main::Login.perform do |login|
......
...@@ -50,7 +50,7 @@ module QA ...@@ -50,7 +50,7 @@ module QA
unless Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) } unless Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) }
Runtime::Browser.visit(@address, Page::Main::Login) Runtime::Browser.visit(@address, Page::Main::Login)
Page::Main::Login.perform { |login| login.sign_in_using_credentials(@user) } Page::Main::Login.perform { |login| login.sign_in_using_credentials(user: @user) }
end end
token = Resource::PersonalAccessToken.fabricate!.access_token token = Resource::PersonalAccessToken.fabricate!.access_token
......
...@@ -164,7 +164,7 @@ module QA ...@@ -164,7 +164,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform do |login_page| Page::Main::Login.perform do |login_page|
login_page.sign_in_using_ldap_credentials(user) login_page.sign_in_using_ldap_credentials(user: user)
end end
group.visit! group.visit!
......
...@@ -44,7 +44,7 @@ module QA ...@@ -44,7 +44,7 @@ module QA
end end
Page::Main::Login.perform do |menu| Page::Main::Login.perform do |menu|
menu.sign_in_using_credentials(@user) menu.sign_in_using_credentials(user: @user)
end end
@group.sandbox.visit! @group.sandbox.visit!
...@@ -72,7 +72,7 @@ module QA ...@@ -72,7 +72,7 @@ module QA
end end
Page::Main::Login.perform do |menu| Page::Main::Login.perform do |menu|
menu.sign_in_using_credentials(@user) menu.sign_in_using_credentials(user: @user)
end end
@group.sandbox.visit! @group.sandbox.visit!
......
# frozen_string_literal: true
require 'securerandom'
module QA
context 'Manage' do
shared_examples 'instance audit event logs' do |expected_events|
it 'logs audit events for UI operations' do
Page::Main::Menu.perform(&:click_admin_area)
QA::Page::Admin::Menu.perform(&:go_to_monitoring_audit_logs)
EE::Page::Admin::Monitoring::AuditLog.perform do |audit_log_page|
expected_events.each do |expected_event|
expect(audit_log_page).to have_audit_log_row(expected_event)
end
end
end
end
describe 'Instance audit logs' do
context 'Failed sign in' do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
invalid_user = QA::Resource::User.new.tap do |user|
user.username = 'bad_user_name'
user.password = 'bad_pasword'
end
Page::Main::Login.perform do |login_page|
login_page.sign_in_using_credentials(user: invalid_user, skip_page_validation: true)
end
sign_in
end
it_behaves_like 'instance audit event logs', ["Failed to login with STANDARD authentication"]
end
context 'Successful sign in' do
before do
sign_in
end
it_behaves_like 'instance audit event logs', ["Signed in with STANDARD authentication"]
end
context 'Add SSH key' do
before do
sign_in
Resource::SSHKey.fabricate! do |resource|
resource.title = "key for instance audit event logs test #{Time.now.to_f}"
end
end
it_behaves_like 'instance audit event logs', ["Added SSH key"]
end
context 'Add and delete email' do
before do
sign_in
new_email_address = 'new_email@example.com'
Page::Main::Menu.perform(&:click_settings_link)
Page::Profile::Menu.perform(&:click_emails)
Page::Profile::Emails.perform do |emails|
emails.add_email_address(new_email_address)
emails.delete_email_address(new_email_address)
end
end
it_behaves_like 'instance audit event logs', ["Added email", "Removed email"]
end
context 'Change password', :skip_signup_disabled do
before do
user = Resource::User.fabricate_via_api! do |user|
user.username = "user_#{SecureRandom.hex(4)}"
user.password = "pw_#{SecureRandom.hex(4)}"
end
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform do |login_page|
login_page.sign_in_using_credentials(user: user)
end
Page::Main::Menu.perform(&:click_settings_link)
Page::Profile::Menu.perform(&:click_password)
Page::Profile::Password.perform do |password_page|
password_page.update_password('new_password', user.password)
end
sign_in
end
it_behaves_like 'instance audit event logs', ["Changed password"]
end
context 'Start and stop user impersonation' do
before do
sign_in
user = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
Page::Main::Menu.perform(&:click_admin_area)
Page::Admin::Menu.perform(&:go_to_users_overview)
Page::Admin::Overview::Users::Index.perform do |index|
index.search_user(user.username)
index.click_user(user.username)
end
Page::Admin::Overview::Users::Show.perform(&:click_impersonate_user)
Page::Main::Menu.perform(&:click_stop_impersonation_link)
end
it_behaves_like 'instance audit event logs', ["Started Impersonation", "Stopped Impersonation"]
end
def sign_in
unless Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) }
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials)
end
end
end
end
end
...@@ -9,7 +9,7 @@ module QA ...@@ -9,7 +9,7 @@ module QA
Page::Main::Login.perform do |login_page| Page::Main::Login.perform do |login_page|
user = Struct.new(:ldap_username, :ldap_password).new('adminuser1', 'password') user = Struct.new(:ldap_username, :ldap_password).new('adminuser1', 'password')
login_page.sign_in_using_ldap_credentials(user) login_page.sign_in_using_ldap_credentials(user: user)
end end
Page::Main::Menu.perform do |menu| Page::Main::Menu.perform do |menu|
......
...@@ -11,7 +11,7 @@ module QA ...@@ -11,7 +11,7 @@ module QA
def login(user = nil) def login(user = nil)
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform { |login| login.sign_in_using_credentials(user) } Page::Main::Login.perform { |login| login.sign_in_using_credentials(user: user) }
end end
before do before do
......
...@@ -103,7 +103,7 @@ module QA ...@@ -103,7 +103,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform do |login| Page::Main::Login.perform do |login|
login.sign_in_using_credentials(as_user) login.sign_in_using_credentials(user: as_user)
end end
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