1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-05 02:09:05 +09:00
YuruToot/spec/fabricators/one_time_key_fabricator.rb

14 lines
478 B
Ruby
Raw Normal View History

2023-03-05 02:31:13 +09:00
# frozen_string_literal: true
Fabricator(:one_time_key) do
device { Fabricate.build(:device) }
2023-03-05 02:31:13 +09:00
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