User: generate private keys on user creation

This fixes a race condition bug where keys could be regenerated
post-federation, causing activities and HTTP signatures from an user to
be dropped due to key differences.
This commit is contained in:
Hélène 2022-08-26 18:30:43 +02:00
commit cd237d22f1
No known key found for this signature in database
GPG key ID: A215F2E9F1589D62
9 changed files with 32 additions and 88 deletions

View file

@ -7,6 +7,7 @@ defmodule Pleroma.Factory do
require Pleroma.Constants
alias Pleroma.Keys
alias Pleroma.Object
alias Pleroma.User
@ -28,6 +29,8 @@ defmodule Pleroma.Factory do
end
def user_factory(attrs \\ %{}) do
{:ok, pem} = Keys.generate_rsa_pem()
user = %User{
name: sequence(:name, &"Test テスト User #{&1}"),
email: sequence(:email, &"user#{&1}@example.com"),
@ -39,7 +42,8 @@ defmodule Pleroma.Factory do
last_refreshed_at: NaiveDateTime.utc_now(),
notification_settings: %Pleroma.User.NotificationSetting{},
multi_factor_authentication_settings: %Pleroma.MFA.Settings{},
ap_enabled: true
ap_enabled: true,
keys: pem
}
urls =