Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c3896451
Commit
c3896451
authored
Jul 11, 2019
by
Etienne Baqué
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored code in Audit::Details and added a test
parent
6c0f34bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
9 deletions
+31
-9
ee/lib/audit/details.rb
ee/lib/audit/details.rb
+15
-9
ee/spec/lib/audit/details_spec.rb
ee/spec/lib/audit/details_spec.rb
+16
-0
No files found.
ee/lib/audit/details.rb
View file @
c3896451
...
...
@@ -27,15 +27,15 @@ module Audit
case
action
.
keys
.
first
when
:add
"Added
#{
target_
type
_value
}#{
@details
[
:as
]
?
" as
#{
@details
[
:as
]
}
"
:
''
}
"
"Added
#{
target_
detail
_value
}#{
@details
[
:as
]
?
" as
#{
@details
[
:as
]
}
"
:
''
}
"
when
:remove
"Removed
#{
target_
type
_value
}
"
"Removed
#{
target_
detail
_value
}
"
when
:failed_login
"Failed to login with
#{
Gitlab
::
Auth
::
OAuth
::
Provider
.
label_for
(
target_type_value
).
upcase
}
authentication"
"Failed to login with
#{
oath_label
}
authentication"
when
:custom_message
target_type
_value
detail
_value
else
text_for_change
(
target_
type
_value
)
text_for_change
(
target_
detail
_value
)
end
end
...
...
@@ -48,10 +48,16 @@ module Audit
changed
.
join
(
' '
)
end
def
target_type_value
target_type
=
@details
[
:target_type
]
val
=
@details
.
values
.
first
target_type
==
'Operations::FeatureFlag'
?
val
:
val
.
tr
(
'_'
,
' '
)
def
target_detail_value
@details
[
:target_type
]
==
'Operations::FeatureFlag'
?
detail_value
:
detail_value
.
tr
(
'_'
,
' '
)
end
def
detail_value
@details
.
values
.
first
end
def
oath_label
Gitlab
::
Auth
::
OAuth
::
Provider
.
label_for
(
detail_value
).
upcase
end
end
end
ee/spec/lib/audit/details_spec.rb
View file @
c3896451
...
...
@@ -83,6 +83,22 @@ describe Audit::Details do
expect
(
string
).
to
eq
(
custom_message
)
end
context
'failed_login'
do
let
(
:feature_flag
)
do
{
failed_login:
'google_oauth2'
,
target_type:
'Operations::FeatureFlag'
}
end
let
(
:message
)
{
'Failed to login with GOOGLE authentication'
}
it
'shows the correct failed login meessage'
do
string
=
described_class
.
humanize
(
feature_flag
)
expect
(
string
).
to
eq
message
end
end
end
context
'deploy key'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment