From 91ef4a6fc5d8536378a2d3bc456711bcb95bd8f4 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 15 Jul 2024 06:42:18 -0400 Subject: [PATCH] Add assertion about key columns to account key generate spec (#30635) --- spec/models/account_spec.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 225929ae3..dfb1f5bc6 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -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