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
9efe0220
Commit
9efe0220
authored
Apr 26, 2021
by
Alan (Maciej) Paruszewski
Committed by
Nick Thomas
Apr 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Threat Monitoring Alert to generate valid link
parent
6141f9ce
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
1 deletion
+79
-1
app/presenters/alert_management/alert_presenter.rb
app/presenters/alert_management/alert_presenter.rb
+2
-0
ee/app/presenters/ee/alert_management/alert_presenter.rb
ee/app/presenters/ee/alert_management/alert_presenter.rb
+15
-0
ee/changelogs/unreleased/323240-generate-link-to-threat-management-alert.yml
...eased/323240-generate-link-to-threat-management-alert.yml
+5
-0
ee/config/routes/project.rb
ee/config/routes/project.rb
+1
-1
ee/spec/presenters/alert_management/alert_presenter_spec.rb
ee/spec/presenters/alert_management/alert_presenter_spec.rb
+52
-0
spec/factories/alert_management/alerts.rb
spec/factories/alert_management/alerts.rb
+4
-0
No files found.
app/presenters/alert_management/alert_presenter.rb
View file @
9efe0220
...
...
@@ -112,3 +112,5 @@ module AlertManagement
end
end
end
AlertManagement
::
AlertPresenter
.
prepend_if_ee
(
'EE::AlertManagement::AlertPresenter'
)
ee/app/presenters/ee/alert_management/alert_presenter.rb
0 → 100644
View file @
9efe0220
# frozen_string_literal: true
module
EE
module
AlertManagement
module
AlertPresenter
extend
ActiveSupport
::
Concern
def
details_url
return
threat_monitoring_alert_project_threat_monitoring_url
(
project
,
alert
.
iid
)
if
alert
.
threat_monitoring?
super
end
end
end
end
ee/changelogs/unreleased/323240-generate-link-to-threat-management-alert.yml
0 → 100644
View file @
9efe0220
---
title
:
Create link to Threat Monitoring Alert for threat management alerts
merge_request
:
59724
author
:
type
:
fixed
ee/config/routes/project.rb
View file @
9efe0220
...
...
@@ -40,7 +40,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources
:subscriptions
,
only:
[
:create
,
:destroy
]
resource
:threat_monitoring
,
only:
[
:show
],
controller: :threat_monitoring
do
get
'/alerts/:id'
,
action:
'alert_details'
,
constraints:
{
id:
/\d+/
}
get
'/alerts/:id'
,
action:
'alert_details'
,
constraints:
{
id:
/\d+/
}
,
as: :threat_monitoring_alert
resources
:policies
,
only:
[
:new
,
:edit
],
controller: :threat_monitoring
end
...
...
ee/spec/presenters/alert_management/alert_presenter_spec.rb
0 → 100644
View file @
9efe0220
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
AlertManagement
::
AlertPresenter
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:payload
)
do
{
'title'
=>
'Alert title'
,
'start_time'
=>
'2020-04-27T10:10:22.265949279Z'
,
'custom'
=>
{
'alert'
=>
{
'fields'
=>
%w[one two]
}
},
'yet'
=>
{
'another'
=>
73
}
}
end
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
,
:threat_monitoring
,
project:
project
,
payload:
payload
)
}
subject
(
:presenter
)
{
described_class
.
new
(
alert
)
}
describe
'#issue_description'
do
let
(
:markdown_line_break
)
{
' '
}
subject
{
presenter
.
issue_description
}
context
'with threat monitoring alert'
do
it
do
is_expected
.
to
eq
(
<<~
MARKDOWN
.
chomp
**Start time:**
#{
presenter
.
start_time
}#{
markdown_line_break
}
**Severity:**
#{
presenter
.
severity
}#{
markdown_line_break
}
**GitLab alert:** http://localhost/
#{
project
.
full_path
}
/-/threat_monitoring/alerts/
#{
alert
.
iid
}
MARKDOWN
)
end
end
end
describe
'#details_url'
do
context
'when alert has threat_monitoring domain'
do
it
'returns the details URL'
do
expect
(
presenter
.
details_url
).
to
match
(
%r{
#{
project
.
web_url
}
/-/threat_monitoring/alerts/
#{
alert
.
iid
}
}
)
end
end
end
end
spec/factories/alert_management/alerts.rb
View file @
9efe0220
...
...
@@ -95,6 +95,10 @@ FactoryBot.define do
severity
{
'unknown'
}
end
trait
:threat_monitoring
do
domain
{
:threat_monitoring
}
end
trait
:prometheus
do
monitoring_tool
{
Gitlab
::
AlertManagement
::
Payload
::
MONITORING_TOOLS
[
:prometheus
]
}
payload
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