1
0
Fork 0
forked from gitea/nas

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

This commit is contained in:
KMY 2024-02-09 12:53:59 +09:00
commit 05e52a09a8
188 changed files with 2810 additions and 1295 deletions

View file

@ -57,20 +57,27 @@ RSpec.describe ActivityPub::TagManager do
expect(subject.to(status)).to include(subject.followers_uri_for(mentioned))
end
it "returns URIs of mentions for direct silenced author's status only if they are followers or requesting to be" do
bob = Fabricate(:account, username: 'bob')
alice = Fabricate(:account, username: 'alice')
foo = Fabricate(:account)
author = Fabricate(:account, username: 'author', silenced: true)
status = Fabricate(:status, visibility: :direct, account: author)
bob.follow!(author)
FollowRequest.create!(account: foo, target_account: author)
status.mentions.create(account: alice)
status.mentions.create(account: bob)
status.mentions.create(account: foo)
expect(subject.to(status)).to include(subject.uri_for(bob))
expect(subject.to(status)).to include(subject.uri_for(foo))
expect(subject.to(status)).to_not include(subject.uri_for(alice))
context 'with followers and requested followers' do
let!(:bob) { Fabricate(:account, username: 'bob') }
let!(:alice) { Fabricate(:account, username: 'alice') }
let!(:foo) { Fabricate(:account) }
let!(:author) { Fabricate(:account, username: 'author', silenced: true) }
let!(:status) { Fabricate(:status, visibility: :direct, account: author) }
before do
bob.follow!(author)
FollowRequest.create!(account: foo, target_account: author)
status.mentions.create(account: alice)
status.mentions.create(account: bob)
status.mentions.create(account: foo)
end
it "returns URIs of mentions for direct silenced author's status only if they are followers or requesting to be" do
expect(subject.to(status))
.to include(subject.uri_for(bob))
.and include(subject.uri_for(foo))
.and not_include(subject.uri_for(alice))
end
end
end
@ -124,20 +131,27 @@ RSpec.describe ActivityPub::TagManager do
expect(subject.cc(status)).to include(subject.uri_for(mentioned))
end
it "returns URIs of mentions for silenced author's non-direct status only if they are followers or requesting to be" do
bob = Fabricate(:account, username: 'bob')
alice = Fabricate(:account, username: 'alice')
foo = Fabricate(:account)
author = Fabricate(:account, username: 'author', silenced: true)
status = Fabricate(:status, visibility: :public, account: author)
bob.follow!(author)
FollowRequest.create!(account: foo, target_account: author)
status.mentions.create(account: alice)
status.mentions.create(account: bob)
status.mentions.create(account: foo)
expect(subject.cc(status)).to include(subject.uri_for(bob))
expect(subject.cc(status)).to include(subject.uri_for(foo))
expect(subject.cc(status)).to_not include(subject.uri_for(alice))
context 'with followers and requested followers' do
let!(:bob) { Fabricate(:account, username: 'bob') }
let!(:alice) { Fabricate(:account, username: 'alice') }
let!(:foo) { Fabricate(:account) }
let!(:author) { Fabricate(:account, username: 'author', silenced: true) }
let!(:status) { Fabricate(:status, visibility: :public, account: author) }
before do
bob.follow!(author)
FollowRequest.create!(account: foo, target_account: author)
status.mentions.create(account: alice)
status.mentions.create(account: bob)
status.mentions.create(account: foo)
end
it "returns URIs of mentions for silenced author's non-direct status only if they are followers or requesting to be" do
expect(subject.cc(status))
.to include(subject.uri_for(bob))
.and include(subject.uri_for(foo))
.and not_include(subject.uri_for(alice))
end
end
it 'returns poster of reblogged post, if reblog' do

View file

@ -33,18 +33,14 @@ describe RequestPool do
subject
threads = Array.new(5) do
Thread.new do
subject.with('http://example.com') do |http_client|
http_client.get('/').flush
# Nudge scheduler to yield and exercise the full pool
sleep(0.01)
end
multi_threaded_execution(5) do
subject.with('http://example.com') do |http_client|
http_client.get('/').flush
# Nudge scheduler to yield and exercise the full pool
sleep(0.01)
end
end
threads.map(&:join)
expect(subject.size).to be > 1
end

View file

@ -0,0 +1,34 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe SignatureParser do
describe '.parse' do
subject { described_class.parse(header) }
context 'with Signature headers conforming to draft-cavage-http-signatures-12' do
let(:header) do
# This example signature string deliberately mixes uneven spacing
# and quoting styles to ensure everything is covered
'keyId = "https://remote.domain/users/bob#main-key,",algorithm= rsa-sha256 , headers="host date digest (request-target)",signature="gmhMjgMROGElJU3fpehV2acD5kMHeELi8EFP2UPHOdQ54H0r55AxIpji+J3lPe+N2qSb/4H1KXIh6f0lRu8TGSsu12OQmg5hiO8VA9flcA/mh9Lpk+qwlQZIPRqKP9xUEfqD+Z7ti5wPzDKrWAUK/7FIqWgcT/mlqB1R1MGkpMFc/q4CIs2OSNiWgA4K+Kp21oQxzC2kUuYob04gAZ7cyE/FTia5t08uv6lVYFdRsn4XNPn1MsHgFBwBMRG79ng3SyhoG4PrqBEi5q2IdLq3zfre/M6He3wlCpyO2VJNdGVoTIzeZ0Zz8jUscPV3XtWUchpGclLGSaKaq/JyNZeiYQ=="' # rubocop:disable Layout/LineLength
end
it 'correctly parses the header' do
expect(subject).to eq({
'keyId' => 'https://remote.domain/users/bob#main-key,',
'algorithm' => 'rsa-sha256',
'headers' => 'host date digest (request-target)',
'signature' => 'gmhMjgMROGElJU3fpehV2acD5kMHeELi8EFP2UPHOdQ54H0r55AxIpji+J3lPe+N2qSb/4H1KXIh6f0lRu8TGSsu12OQmg5hiO8VA9flcA/mh9Lpk+qwlQZIPRqKP9xUEfqD+Z7ti5wPzDKrWAUK/7FIqWgcT/mlqB1R1MGkpMFc/q4CIs2OSNiWgA4K+Kp21oQxzC2kUuYob04gAZ7cyE/FTia5t08uv6lVYFdRsn4XNPn1MsHgFBwBMRG79ng3SyhoG4PrqBEi5q2IdLq3zfre/M6He3wlCpyO2VJNdGVoTIzeZ0Zz8jUscPV3XtWUchpGclLGSaKaq/JyNZeiYQ==', # rubocop:disable Layout/LineLength
})
end
end
context 'with a malformed Signature header' do
let(:header) { 'hello this is malformed!' }
it 'raises an error' do
expect { subject }.to raise_error(SignatureParser::ParsingError)
end
end
end
end