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
475ab94e
Commit
475ab94e
authored
Sep 19, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more license specs
parent
0ad7f5db
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
18 deletions
+34
-18
ee/app/services/ee/audit_event_service.rb
ee/app/services/ee/audit_event_service.rb
+13
-13
spec/services/audit_event_service_spec.rb
spec/services/audit_event_service_spec.rb
+21
-5
No files found.
ee/app/services/ee/audit_event_service.rb
View file @
475ab94e
...
@@ -93,6 +93,19 @@ module EE
...
@@ -93,6 +93,19 @@ module EE
)
)
end
end
def
entity_audit_events_enabled?
@entity
.
respond_to?
(
:feature_available?
)
&&
@entity
.
feature_available?
(
:audit_events
)
end
def
audit_events_enabled?
# Always log auth events. Log all other events if `extended_audit_events` is enabled
@details
[
:with
]
||
License
.
feature_available?
(
:extended_audit_events
)
end
def
admin_audit_log_enabled?
License
.
feature_available?
(
:admin_audit_log
)
end
def
method_missing
(
method_sym
,
*
arguments
,
&
block
)
def
method_missing
(
method_sym
,
*
arguments
,
&
block
)
super
(
method_sym
,
*
arguments
,
&
block
)
unless
respond_to?
(
method_sym
)
super
(
method_sym
,
*
arguments
,
&
block
)
unless
respond_to?
(
method_sym
)
...
@@ -150,18 +163,5 @@ module EE
...
@@ -150,18 +163,5 @@ module EE
@details
.
merge!
(
ip_address:
ip_address
,
@details
.
merge!
(
ip_address:
ip_address
,
entity_path:
@entity
.
full_path
)
entity_path:
@entity
.
full_path
)
end
end
def
entity_audit_events_enabled?
@entity
.
respond_to?
(
:feature_available?
)
&&
@entity
.
feature_available?
(
:audit_events
)
end
def
audit_events_enabled?
# Always log auth events. Log all other events if `extended_audit_events` is enabled
@details
[
:with
]
||
License
.
feature_available?
(
:extended_audit_events
)
end
def
admin_audit_log_enabled?
License
.
feature_available?
(
:admin_audit_log
)
end
end
end
end
end
spec/services/audit_event_service_spec.rb
View file @
475ab94e
...
@@ -56,20 +56,20 @@ describe AuditEventService do
...
@@ -56,20 +56,20 @@ describe AuditEventService do
end
end
end
end
describe
'#
audit_events_enabled
?'
do
describe
'#
entity_audit_events_enabled?
?'
do
context
'entity is a project'
do
context
'entity is a project'
do
let
(
:service
)
{
described_class
.
new
(
user
,
project
,
{
action: :destroy
})
}
let
(
:service
)
{
described_class
.
new
(
user
,
project
,
{
action: :destroy
})
}
it
'returns false when project is unlicensed'
do
it
'returns false when project is unlicensed'
do
stub_licensed_features
(
audit_events:
false
)
stub_licensed_features
(
audit_events:
false
)
expect
(
service
.
audit_events_enabled?
).
to
be_falsy
expect
(
service
.
entity_
audit_events_enabled?
).
to
be_falsy
end
end
it
'returns true when project is licensed'
do
it
'returns true when project is licensed'
do
stub_licensed_features
(
audit_events:
true
)
stub_licensed_features
(
audit_events:
true
)
expect
(
service
.
audit_events_enabled?
).
to
be_truthy
expect
(
service
.
entity_
audit_events_enabled?
).
to
be_truthy
end
end
end
end
...
@@ -80,19 +80,35 @@ describe AuditEventService do
...
@@ -80,19 +80,35 @@ describe AuditEventService do
it
'returns false when group is unlicensed'
do
it
'returns false when group is unlicensed'
do
stub_licensed_features
(
audit_events:
false
)
stub_licensed_features
(
audit_events:
false
)
expect
(
service
.
audit_events_enabled?
).
to
be_falsy
expect
(
service
.
entity_
audit_events_enabled?
).
to
be_falsy
end
end
it
'returns true when group is licensed'
do
it
'returns true when group is licensed'
do
stub_licensed_features
(
audit_events:
true
)
stub_licensed_features
(
audit_events:
true
)
expect
(
service
.
audit_events_enabled?
).
to
be_truthy
expect
(
service
.
entity_
audit_events_enabled?
).
to
be_truthy
end
end
end
end
context
'entity is a user'
do
context
'entity is a user'
do
let
(
:service
)
{
described_class
.
new
(
user
,
user
,
{
action: :destroy
})
}
let
(
:service
)
{
described_class
.
new
(
user
,
user
,
{
action: :destroy
})
}
it
'returns false when unlicensed'
do
stub_licensed_features
(
audit_events:
false
,
admin_audit_log:
false
)
expect
(
service
.
audit_events_enabled?
).
to
be_falsey
end
it
'returns true when licensed with extended events'
do
stub_licensed_features
(
extended_audit_events:
true
)
expect
(
service
.
audit_events_enabled?
).
to
be_truthy
end
end
context
'auth event'
do
let
(
:service
)
{
described_class
.
new
(
user
,
user
,
{
with:
'auth'
})
}
it
'returns true when unlicensed'
do
it
'returns true when unlicensed'
do
stub_licensed_features
(
audit_events:
false
,
admin_audit_log:
false
)
stub_licensed_features
(
audit_events:
false
,
admin_audit_log:
false
)
...
...
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