Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/models/prometheus_alert_spec.rb
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/models/prometheus_alert_spec.rb')
-rw-r--r--spec/models/prometheus_alert_spec.rb37
1 files changed, 36 insertions, 1 deletions
diff --git a/spec/models/prometheus_alert_spec.rb b/spec/models/prometheus_alert_spec.rb
index 7169a34d96f..8e517e1764e 100644
--- a/spec/models/prometheus_alert_spec.rb
+++ b/spec/models/prometheus_alert_spec.rb
@@ -50,6 +50,8 @@ RSpec.describe PrometheusAlert do
it { is_expected.to validate_presence_of(:environment) }
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:prometheus_metric) }
+ it { is_expected.to validate_presence_of(:operator) }
+ it { is_expected.to validate_presence_of(:threshold) }
context 'when environment and metric belongs same project' do
it { is_expected.to be_valid }
@@ -74,6 +76,34 @@ RSpec.describe PrometheusAlert do
end
end
+ describe 'runbook validations' do
+ it 'disallow invalid urls' do
+ unsafe_url = %{https://replaceme.com/'><script>alert(document.cookie)</script>}
+ non_ascii_url = 'http://gitlab.com/user/project1/wiki/something€'
+ excessively_long_url = 'https://gitla' + 'b' * 1024 + '.com'
+
+ is_expected.not_to allow_values(
+ unsafe_url,
+ non_ascii_url,
+ excessively_long_url
+ ).for(:runbook_url)
+ end
+
+ it 'allow valid urls' do
+ external_url = 'http://runbook.gitlab.com/'
+ internal_url = 'http://192.168.1.1'
+ blank_url = ''
+ nil_url = nil
+
+ is_expected.to allow_value(
+ external_url,
+ internal_url,
+ blank_url,
+ nil_url
+ ).for(:runbook_url)
+ end
+ end
+
describe '#full_query' do
before do
subject.operator = "gt"
@@ -91,6 +121,7 @@ RSpec.describe PrometheusAlert do
subject.operator = "gt"
subject.threshold = 1
subject.prometheus_metric = metric
+ subject.runbook_url = 'runbook'
end
it 'returns the params of the prometheus alert' do
@@ -102,7 +133,11 @@ RSpec.describe PrometheusAlert do
"gitlab" => "hook",
"gitlab_alert_id" => metric.id,
"gitlab_prometheus_alert_id" => subject.id
- })
+ },
+ "annotations" => {
+ "runbook" => "runbook"
+ }
+ )
end
end
end