web_push_subscription_fabricator.rb 355 B

1234567891011
  1. # frozen_string_literal: true
  2. Fabricator(:web_push_subscription, from: Web::PushSubscription) do
  3. endpoint Faker::Internet.url
  4. key_p256dh do
  5. curve = OpenSSL::PKey::EC.generate('prime256v1')
  6. ecdh_key = curve.public_key.to_bn.to_s(2)
  7. Base64.urlsafe_encode64(ecdh_key)
  8. end
  9. key_auth { Base64.urlsafe_encode64(Random.new.bytes(16)) }
  10. end