1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Add assertion about key columns to account key generate spec (#30635)

This commit is contained in:
Matt Jankowski 2024-07-15 06:42:18 -04:00 committed by GitHub
parent 1dd8262071
commit 91ef4a6fc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1015,21 +1015,26 @@ RSpec.describe Account do
context 'when is local' do
it 'generates keys' do
account = described_class.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_']))
expect(account.keypair).to be_private
expect(account.keypair).to be_public
account = described_class.create!(domain: nil, username: 'user_without_keys')
expect(account)
.to be_private_key
.and be_public_key
expect(account.keypair)
.to be_private
.and be_public
end
end
context 'when is remote' do
it 'does not generate keys' do
key = OpenSSL::PKey::RSA.new(1024).public_key
account = described_class.create!(domain: 'remote', uri: 'https://remote/actor', username: Faker::Internet.user_name(separators: ['_']), public_key: key.to_pem)
account = described_class.create!(domain: 'remote', uri: 'https://remote/actor', username: 'remote_user_with_public', public_key: key.to_pem)
expect(account.keypair.params).to eq key.params
end
it 'normalizes domain' do
account = described_class.create!(domain: 'にゃん', uri: 'https://xn--r9j5b5b/actor', username: Faker::Internet.user_name(separators: ['_']))
account = described_class.create!(domain: 'にゃん', uri: 'https://xn--r9j5b5b/actor', username: 'remote_user_with_idn_domain')
expect(account.domain).to eq 'xn--r9j5b5b'
end
end