Add tests for processing statuses using bearcap URIs (#28904)
parent
0471a78055
commit
087415d0fe
|
@ -893,6 +893,49 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when object URI uses bearcaps' do
|
||||||
|
subject { described_class.new(json, sender) }
|
||||||
|
|
||||||
|
let(:token) { 'foo' }
|
||||||
|
|
||||||
|
let(:json) do
|
||||||
|
{
|
||||||
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
|
id: [ActivityPub::TagManager.instance.uri_for(sender), '#foo'].join,
|
||||||
|
type: 'Create',
|
||||||
|
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
|
object: Addressable::URI.new(scheme: 'bear', query_values: { t: token, u: object_json[:id] }).to_s,
|
||||||
|
}.with_indifferent_access
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:object_json) do
|
||||||
|
{
|
||||||
|
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||||
|
type: 'Note',
|
||||||
|
content: 'Lorem ipsum',
|
||||||
|
to: 'https://www.w3.org/ns/activitystreams#Public',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
stub_request(:get, object_json[:id])
|
||||||
|
.with(headers: { Authorization: "Bearer #{token}" })
|
||||||
|
.to_return(body: Oj.dump(object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||||
|
|
||||||
|
subject.perform
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates status' do
|
||||||
|
status = sender.statuses.first
|
||||||
|
|
||||||
|
expect(status).to_not be_nil
|
||||||
|
expect(status).to have_attributes(
|
||||||
|
visibility: 'public',
|
||||||
|
text: 'Lorem ipsum'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with an encrypted message' do
|
context 'with an encrypted message' do
|
||||||
subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) }
|
subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue