summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2024-01-25 12:13:36 +0100
committerGitHub <noreply@github.com>2024-01-25 11:13:36 +0000
commit087415d0fe8d9a719eb2df7e915b08f4d4d0360a (patch)
tree0d29089d12fb5980cc054074613e353fbe619415
parent0471a780556720338fef29266f2fc2578ab2010c (diff)
Add tests for processing statuses using bearcap URIs (#28904)
-rw-r--r--spec/lib/activitypub/activity/create_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb
index 3e3a4978c89..e4966cffa33 100644
--- a/spec/lib/activitypub/activity/create_spec.rb
+++ b/spec/lib/activitypub/activity/create_spec.rb
@@ -893,6 +893,49 @@ RSpec.describe ActivityPub::Activity::Create do
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
subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) }