Skip to content
代码片段 群组 项目
提交 461f79c2 编辑于 作者: Aboobacker MK's avatar Aboobacker MK 提交者: Lukas 'Eipi' Eipert
浏览文件

Redirect audit_log to /-/user_settings/authentication_log

Move /-/profile/audit_log to /-/user_settings/authentication_log and
redirect end_point to new endpoint till next major release (17.0)

Changelog: changed
上级 979c82c5
No related branches found
No related tags found
无相关合并请求
显示
89 个添加47 个删除
......@@ -583,7 +583,7 @@ RSpec/FactoryBot/AvoidCreate:
- 'spec/views/notify/import_issues_csv_email.html.haml_spec.rb'
- 'spec/views/notify/pipeline_failed_email.text.erb_spec.rb'
- 'spec/views/notify/push_to_merge_request_email.text.haml_spec.rb'
- 'spec/views/profiles/audit_log.html.haml_spec.rb'
- 'spec/views/user_settings/user_settings/authentication_log.html.haml_spec.rb'
- 'spec/views/profiles/keys/_key.html.haml_spec.rb'
- 'spec/views/profiles/keys/_key_details.html.haml_spec.rb'
- 'spec/views/profiles/notifications/show.html.haml_spec.rb'
......
......@@ -14,7 +14,6 @@ class ProfilesController < Profiles::ApplicationController
feature_category :user_profile, [:show, :update, :reset_incoming_email_token, :reset_feed_token,
:reset_static_object_token, :update_username]
feature_category :system_access, [:audit_log]
urgency :low, [:show, :update]
def show
......@@ -65,16 +64,6 @@ def reset_static_object_token
notice: s_('Profiles|Static object token was successfully reset')
end
# rubocop: disable CodeReuse/ActiveRecord
def audit_log
@events = AuthenticationEvent.where(user: current_user)
.order("created_at DESC")
.page(params[:page])
Gitlab::Tracking.event(self.class.name, 'search_audit_event', user: current_user)
end
# rubocop: enable CodeReuse/ActiveRecord
def update_username
result = Users::UpdateService.new(current_user, user: @user, username: username_param).execute
......
# frozen_string_literal: true
module UserSettings
class UserSettingsController < ApplicationController
layout 'profile'
feature_category :system_access
def authentication_log
@events = AuthenticationEvent.for_user(current_user)
.order_by_created_at_desc
.page(params[:page])
Gitlab::Tracking.event(self.class.name, 'search_audit_event', user: current_user)
end
end
end
......@@ -21,6 +21,8 @@ class AuthenticationEvent < MainClusterwide::ApplicationRecord
scope :for_provider, ->(provider) { where(provider: provider) }
scope :ldap, -> { where('provider LIKE ?', 'ldap%') }
scope :for_user, ->(user) { where(user: user) }
scope :order_by_created_at_desc, -> { reorder(created_at: :desc) }
def self.providers
STATIC_PROVIDERS | Devise.omniauth_providers.map(&:to_s)
......
......@@ -210,6 +210,7 @@
draw :snippets
draw :profile
draw :user_settings
post '/mailgun/webhooks' => 'mailgun/webhooks#process_webhook'
......
......@@ -5,7 +5,7 @@
resource :profile, only: [:show, :update] do
member do
get :audit_log
get :audit_log, to: redirect('-/user_settings/authentication_log')
get :applications, to: 'oauth/applications#index'
put :reset_incoming_email_token
......
# frozen_string_literal: true
scope module: 'user_settings' do
namespace :user_settings do
get :authentication_log
end
end
......@@ -8,7 +8,7 @@ class AuthenticationLogMenu < ::Sidebars::Menu
override :link
def link
audit_log_profile_path
user_settings_authentication_log_path
end
override :title
......@@ -23,7 +23,7 @@ def sprite_icon
override :active_routes
def active_routes
{ path: 'profiles#audit_log' }
{ path: 'user_settings#authentication_log' }
end
end
end
......
......@@ -140,30 +140,6 @@
end
end
describe 'GET audit_log' do
let(:auth_event) { create(:authentication_event, user: user) }
it 'tracks search event', :snowplow do
sign_in(user)
get :audit_log
expect_snowplow_event(
category: 'ProfilesController',
action: 'search_audit_event',
user: user
)
end
it 'loads page correctly' do
sign_in(user)
get :audit_log
expect(response).to have_gitlab_http_status(:success)
end
end
describe 'PUT update_username' do
let(:namespace) { user.namespace }
let(:gitlab_shell) { Gitlab::Shell.new }
......
......@@ -32,7 +32,7 @@
context 'when visiting authentication logs' do
before do
visit audit_log_profile_path
visit user_settings_authentication_log_path
end
it 'renders the side navigation with the correct submenu set as active' do
......
......@@ -4,10 +4,10 @@
RSpec.describe Sidebars::UserSettings::Menus::AuthenticationLogMenu, feature_category: :navigation do
it_behaves_like 'User settings menu',
link: '/-/profile/audit_log',
link: '/-/user_settings/authentication_log',
title: _('Authentication Log'),
icon: 'log',
active_routes: { path: 'profiles#audit_log' }
active_routes: { path: 'user_settings#authentication_log' }
it_behaves_like 'User settings menu #render? method'
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "Legacy routes", type: :request, feature_category: :system_access do
let(:user) { create(:user) }
before do
login_as(user)
end
it "/-/profile/audit_log" do
get "/-/profile/audit_log"
expect(response).to redirect_to('/-/user_settings/authentication_log')
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "UserSettings", type: :request, feature_category: :system_access do
let(:user) { create(:user) }
describe 'GET authentication_log' do
let(:auth_event) { create(:authentication_event, user: user) }
it 'tracks search event', :snowplow do
sign_in(user)
get '/-/user_settings/authentication_log'
expect_snowplow_event(
category: 'UserSettings::UserSettingsController',
action: 'search_audit_event',
user: user
)
end
it 'loads page correctly' do
sign_in(user)
get '/-/user_settings/authentication_log'
expect(response).to have_gitlab_http_status(:success)
end
end
end
......@@ -131,10 +131,6 @@
expect(get("/-/profile/account")).to route_to('profiles/accounts#show')
end
it "to #audit_log" do
expect(get("/-/profile/audit_log")).to route_to('profiles#audit_log')
end
it "to #reset_feed_token" do
expect(put("/-/profile/reset_feed_token")).to route_to('profiles#reset_feed_token')
end
......@@ -397,3 +393,11 @@
expect(get('/-/jwks')).to route_to('jwks#index')
end
end
# user_settings_authentication_log GET /-/user_settings/authentication_log(.:format) system_access/user_settings#authentication_log
RSpec.describe UserSettings::UserSettingsController, 'routing', feature_category: :system_access do
it 'to #authentication_log' do
expect(get('/-/user_settings/authentication_log')).to route_to('user_settings/user_settings#authentication_log')
end
end
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'profiles/audit_log' do
RSpec.describe 'user_settings/user_settings/authentication_log', feature_category: :system_access do
let(:user) { create(:user) }
before do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册