1
0
Fork 0
forked from gitea/nas

Merge remote-tracking branch 'parent/main' into upstream-20240926

This commit is contained in:
KMY 2024-09-26 08:29:41 +09:00
commit c905714459
517 changed files with 4284 additions and 3891 deletions

View file

@ -2329,64 +2329,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 in remote pending' do
subject { described_class.new(json, sender, delivery: true) }

View file

@ -29,5 +29,20 @@ RSpec.describe PermalinkRedirector do
redirector = described_class.new('@alice/123')
expect(redirector.redirect_path).to eq 'https://example.com/status-123'
end
it 'returns path for legacy status links with a query param' do
redirector = described_class.new('statuses/123?foo=bar')
expect(redirector.redirect_path).to eq 'https://example.com/status-123'
end
it 'returns path for pretty status links with a query param' do
redirector = described_class.new('@alice/123?foo=bar')
expect(redirector.redirect_path).to eq 'https://example.com/status-123'
end
it 'returns path for deck URLs with query params' do
redirector = described_class.new('/deck/directory?local=true')
expect(redirector.redirect_path).to eq '/directory?local=true'
end
end
end

View file

@ -7,16 +7,13 @@ RSpec.describe ScopeTransformer do
subject { described_class.new.apply(ScopeParser.new.parse(input)) }
shared_examples 'a scope' do |namespace, term, access|
it 'parses the term' do
expect(subject.term).to eq term
end
it 'parses the namespace' do
expect(subject.namespace).to eq namespace
end
it 'parses the access' do
expect(subject.access).to eq access
it 'parses the attributes' do
expect(subject)
.to have_attributes(
term: term,
namespace: namespace,
access: access
)
end
end

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