aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/messages/rotation_configuration_test.rb
blob: 2f6824ed21f17fdc90e66de430261a6e4e82e1f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

require "abstract_unit"
require "active_support/messages/rotation_configuration"

class MessagesRotationConfiguration < ActiveSupport::TestCase
  def setup
    @config = ActiveSupport::Messages::RotationConfiguration.new
  end

  def test_signed_configurations
    @config.rotate :signed, "older secret", salt: "salt", digest: "SHA1"
    @config.rotate :signed, "old secret", salt: "salt", digest: "SHA256"

    assert_equal [
      [ "older secret", salt: "salt", digest: "SHA1" ],
      [ "old secret", salt: "salt", digest: "SHA256" ] ], @config.signed
  end

  def test_encrypted_configurations
    @config.rotate :encrypted, "old raw key", cipher: "aes-256-gcm"

    assert_equal [ [ "old raw key", cipher: "aes-256-gcm" ] ], @config.encrypted
  end
end