Remove unused E2EE messaging code (#31193)

This commit is contained in:
Matt Jankowski 2024-09-18 05:27:43 -04:00 committed by GitHub
parent 2d399f5d4a
commit 5405bdd344
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
130 changed files with 25 additions and 1347 deletions

View file

@ -1,19 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::ClaimsController do
let(:account) { Fabricate(:account) }
describe 'POST #create' do
context 'without signature' do
before do
post :create, params: { account_username: account.username }, body: '{}'
end
it 'returns http not authorized' do
expect(response).to have_http_status(401)
end
end
end
end

View file

@ -1,10 +0,0 @@
# frozen_string_literal: true
Fabricator(:device) do
access_token { Fabricate.build(:access_token) }
account { Fabricate.build(:account) }
device_id { Faker::Number.number(digits: 5) }
name { Faker::App.name }
fingerprint_key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
identity_key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
end

View file

@ -1,7 +0,0 @@
# frozen_string_literal: true
Fabricator(:encrypted_message) do
device { Fabricate.build(:device) }
from_account { Fabricate.build(:account) }
from_device_id { Faker::Number.number(digits: 5) }
end

View file

@ -1,13 +0,0 @@
# frozen_string_literal: true
Fabricator(:one_time_key) do
device { Fabricate.build(:device) }
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

View file

@ -1,3 +0,0 @@
# frozen_string_literal: true
Fabricator(:system_key)

View file

@ -936,64 +936,6 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'with an encrypted message' do
subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) }
let(:recipient) { Fabricate(:account) }
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'EncryptedMessage',
attributedTo: {
type: 'Device',
deviceId: '1234',
},
to: {
type: 'Device',
deviceId: target_device.device_id,
},
messageType: 1,
cipherText: 'Foo',
messageFranking: 'Baz678',
digest: {
digestAlgorithm: 'Bar456',
digestValue: 'Foo123',
},
}
end
let(:target_device) { Fabricate(:device, account: recipient) }
before do
subject.perform
end
it 'creates an encrypted message' do
encrypted_message = target_device.encrypted_messages.reload.first
expect(encrypted_message)
.to be_present
.and have_attributes(
from_device_id: eq('1234'),
from_account: eq(sender),
type: eq(1),
body: eq('Foo'),
digest: eq('Foo123')
)
end
it 'creates a message franking' do
encrypted_message = target_device.encrypted_messages.reload.first
message_franking = encrypted_message.message_franking
crypt = ActiveSupport::MessageEncryptor.new(SystemKey.current_key, serializer: Oj)
json = crypt.decrypt_and_verify(message_franking)
expect(json['source_account_id']).to eq sender.id
expect(json['target_account_id']).to eq recipient.id
expect(json['original_franking']).to eq 'Baz678'
end
end
context 'when sender is followed by local users' do
subject { described_class.new(json, sender, delivery: true) }

View file

@ -1,24 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Vacuum::SystemKeysVacuum do
subject { described_class.new }
describe '#perform' do
let!(:expired_system_key) { Fabricate(:system_key, created_at: (SystemKey::ROTATION_PERIOD * 4).ago) }
let!(:current_system_key) { Fabricate(:system_key) }
before do
subject.perform
end
it 'deletes the expired key' do
expect { expired_system_key.reload }.to raise_error ActiveRecord::RecordNotFound
end
it 'does not delete the current key' do
expect { current_system_key.reload }.to_not raise_error
end
end
end

View file

@ -1,23 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe OneTimeKey do
describe 'validations' do
context 'with an invalid signature' do
let(:one_time_key) { Fabricate.build(:one_time_key, signature: 'wrong!') }
it 'is invalid' do
expect(one_time_key).to_not be_valid
end
end
context 'with an invalid key' do
let(:one_time_key) { Fabricate.build(:one_time_key, key: 'wrong!') }
it 'is invalid' do
expect(one_time_key).to_not be_valid
end
end
end
end

View file

@ -1,14 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::DeviceSerializer do
let(:serialization) { serialized_record_json(record, described_class) }
let(:record) { Fabricate(:device) }
describe 'type' do
it 'returns correct serialized type' do
expect(serialization['type']).to eq('Device')
end
end
end

View file

@ -1,14 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::OneTimeKeySerializer do
let(:serialization) { serialized_record_json(record, described_class) }
let(:record) { Fabricate(:one_time_key) }
describe 'type' do
it 'returns correct serialized type' do
expect(serialization['type']).to eq('Curve25519Key')
end
end
end

View file

@ -1,14 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe REST::EncryptedMessageSerializer do
let(:serialization) { serialized_record_json(record, described_class) }
let(:record) { Fabricate(:encrypted_message) }
describe 'account' do
it 'returns the associated account' do
expect(serialization['account_id']).to eq(record.from_account.id.to_s)
end
end
end

View file

@ -1,14 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe REST::Keys::ClaimResultSerializer do
let(:serialization) { serialized_record_json(record, described_class) }
let(:record) { Keys::ClaimService::Result.new(Account.new(id: 123), 456) }
describe 'account' do
it 'returns the associated account' do
expect(serialization['account_id']).to eq('123')
end
end
end

View file

@ -1,14 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe REST::Keys::DeviceSerializer do
let(:serialization) { serialized_record_json(record, described_class) }
let(:record) { Device.new(name: 'Device name') }
describe 'name' do
it 'returns the name' do
expect(serialization['name']).to eq('Device name')
end
end
end

View file

@ -1,14 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe REST::Keys::QueryResultSerializer do
let(:serialization) { serialized_record_json(record, described_class) }
let(:record) { Keys::QueryService::Result.new(Account.new(id: 123), []) }
describe 'account' do
it 'returns the associated account id' do
expect(serialization['account_id']).to eq('123')
end
end
end

View file

@ -1,13 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe PushEncryptedMessageWorker do
let(:worker) { described_class.new }
describe 'perform' do
it 'runs without error for missing record' do
expect { worker.perform(nil) }.to_not raise_error
end
end
end