about summary refs log tree commit diff
path: root/spec/fabricators/one_time_key_fabricator.rb
blob: 8794baeb59770629604364cba7d666dad69ca7e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
Fabricator(:one_time_key) do
  device
  key_id { Faker::Alphanumeric.alphanumeric(number: 10) }
  key    { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }

  signature do |attrs|
    signing_key = Ed25519::SigningKey.generate
    attrs[:device].update(fingerprint_key: Base64.strict_encode64(signing_key.verify_key.to_bytes))
    Base64.strict_encode64(signing_key.sign(attrs[:key]))
  end
end