diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/migrations/generate_ci_jwt_signing_key_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/migrations/generate_ci_jwt_signing_key_spec.rb')
-rw-r--r-- | spec/migrations/generate_ci_jwt_signing_key_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/migrations/generate_ci_jwt_signing_key_spec.rb b/spec/migrations/generate_ci_jwt_signing_key_spec.rb new file mode 100644 index 00000000000..4cfaa8701aa --- /dev/null +++ b/spec/migrations/generate_ci_jwt_signing_key_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require Rails.root.join('db', 'migrate', '20201008013434_generate_ci_jwt_signing_key.rb') + +RSpec.describe GenerateCiJwtSigningKey do + let(:application_settings) do + Class.new(ActiveRecord::Base) do + self.table_name = 'application_settings' + + attr_encrypted :ci_jwt_signing_key, { + mode: :per_attribute_iv, + key: Rails.application.secrets.db_key_base[0..31], + algorithm: 'aes-256-gcm', + encode: true + } + end + end + + it 'generates JWT signing key' do + application_settings.create! + + reversible_migration do |migration| + migration.before -> { + settings = application_settings.first + + expect(settings.ci_jwt_signing_key).to be_nil + expect(settings.encrypted_ci_jwt_signing_key).to be_nil + expect(settings.encrypted_ci_jwt_signing_key_iv).to be_nil + } + + migration.after -> { + settings = application_settings.first + + expect(settings.encrypted_ci_jwt_signing_key).to be_present + expect(settings.encrypted_ci_jwt_signing_key_iv).to be_present + expect { OpenSSL::PKey::RSA.new(settings.ci_jwt_signing_key) }.not_to raise_error + } + end + end +end |