summaryrefslogtreecommitdiff
path: root/spec/models/clusters
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-17 21:09:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-17 21:09:16 +0000
commit154b9bae142ba15fec753f44327654595094b879 (patch)
tree027f8ae024961778d5b00c77a72fe302f985d4f3 /spec/models/clusters
parent2c156e3c7bbade01c36eee18327f1ced6eebea79 (diff)
downloadgitlab-ce-154b9bae142ba15fec753f44327654595094b879.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/clusters')
-rw-r--r--spec/models/clusters/applications/prometheus_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb
index 04e4d261b1c..ecb87910d2d 100644
--- a/spec/models/clusters/applications/prometheus_spec.rb
+++ b/spec/models/clusters/applications/prometheus_spec.rb
@@ -330,4 +330,46 @@ describe Clusters::Applications::Prometheus do
it { is_expected.to be_falsy }
end
end
+
+ describe 'alert manager token' do
+ subject { create(:clusters_applications_prometheus) }
+
+ context 'when not set' do
+ it 'is empty by default' do
+ expect(subject.alert_manager_token).to be_nil
+ expect(subject.encrypted_alert_manager_token).to be_nil
+ expect(subject.encrypted_alert_manager_token_iv).to be_nil
+ end
+
+ describe '#generate_alert_manager_token!' do
+ it 'generates a token' do
+ subject.generate_alert_manager_token!
+
+ expect(subject.alert_manager_token).to match(/\A\h{32}\z/)
+ end
+ end
+ end
+
+ context 'when set' do
+ let(:token) { SecureRandom.hex }
+
+ before do
+ subject.update!(alert_manager_token: token)
+ end
+
+ it 'reads the token' do
+ expect(subject.alert_manager_token).to eq(token)
+ expect(subject.encrypted_alert_manager_token).not_to be_nil
+ expect(subject.encrypted_alert_manager_token_iv).not_to be_nil
+ end
+
+ describe '#generate_alert_manager_token!' do
+ it 'does not re-generate the token' do
+ subject.generate_alert_manager_token!
+
+ expect(subject.alert_manager_token).to eq(token)
+ end
+ end
+ end
+ end
end