Upgrade diaspora_federation to 1.0
This commit is contained in:
parent
8299aabc25
commit
111b3cdc8e
13 changed files with 85 additions and 76 deletions
16
Gemfile
16
Gemfile
|
|
@ -15,8 +15,8 @@ gem "unicorn-worker-killer", "0.4.5"
|
||||||
|
|
||||||
# Federation
|
# Federation
|
||||||
|
|
||||||
gem "diaspora_federation-json_schema", "0.2.8"
|
gem "diaspora_federation-json_schema", "1.0.0"
|
||||||
gem "diaspora_federation-rails", "0.2.8"
|
gem "diaspora_federation-rails", "1.0.0"
|
||||||
|
|
||||||
# API and JSON
|
# API and JSON
|
||||||
|
|
||||||
|
|
@ -142,11 +142,11 @@ gem "acts-as-taggable-on", "9.0.1"
|
||||||
|
|
||||||
# URIs and HTTP
|
# URIs and HTTP
|
||||||
|
|
||||||
gem "addressable", "2.8.0", require: "addressable/uri"
|
gem "addressable", "2.8.0", require: "addressable/uri"
|
||||||
gem "faraday", "0.17.5"
|
gem "faraday", "1.10.0"
|
||||||
gem "faraday-cookie_jar", "0.0.7"
|
gem "faraday-cookie_jar", "0.0.7"
|
||||||
gem "faraday_middleware", "0.14.0"
|
gem "faraday-follow_redirects", "0.3.0"
|
||||||
gem "typhoeus", "1.4.0"
|
gem "typhoeus", "1.4.0"
|
||||||
|
|
||||||
# Views
|
# Views
|
||||||
|
|
||||||
|
|
@ -245,7 +245,7 @@ group :test do
|
||||||
gem "timecop", "0.9.5"
|
gem "timecop", "0.9.5"
|
||||||
gem "webmock", "3.14.0", require: false
|
gem "webmock", "3.14.0", require: false
|
||||||
|
|
||||||
gem "diaspora_federation-test", "0.2.8"
|
gem "diaspora_federation-test", "1.0.0"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
|
|
||||||
64
Gemfile.lock
64
Gemfile.lock
|
|
@ -209,19 +209,19 @@ GEM
|
||||||
devise_lastseenable (0.0.6)
|
devise_lastseenable (0.0.6)
|
||||||
devise
|
devise
|
||||||
rails (>= 3.0.4)
|
rails (>= 3.0.4)
|
||||||
diaspora_federation (0.2.8)
|
diaspora_federation (1.0.0)
|
||||||
faraday (>= 0.9.0, < 1.0)
|
faraday (>= 1.0, < 3)
|
||||||
faraday_middleware (>= 0.10.0, < 1.0)
|
faraday-follow_redirects (~> 0.3)
|
||||||
nokogiri (~> 1.6, >= 1.6.8)
|
nokogiri (~> 1.6, >= 1.6.8)
|
||||||
typhoeus (~> 1.0)
|
typhoeus (~> 1.0)
|
||||||
valid (~> 1.0)
|
valid (~> 1.0)
|
||||||
diaspora_federation-json_schema (0.2.8)
|
diaspora_federation-json_schema (1.0.0)
|
||||||
diaspora_federation-rails (0.2.8)
|
diaspora_federation-rails (1.0.0)
|
||||||
actionpack (>= 4.2, < 7)
|
actionpack (>= 5.2, < 8)
|
||||||
diaspora_federation (= 0.2.8)
|
diaspora_federation (= 1.0.0)
|
||||||
diaspora_federation-test (0.2.8)
|
diaspora_federation-test (1.0.0)
|
||||||
diaspora_federation (= 0.2.8)
|
diaspora_federation (= 1.0.0)
|
||||||
fabrication (~> 2.16)
|
fabrication (~> 2.29)
|
||||||
uuid (~> 2.3, >= 2.3.8)
|
uuid (~> 2.3, >= 2.3.8)
|
||||||
diff-lcs (1.5.0)
|
diff-lcs (1.5.0)
|
||||||
docile (1.4.0)
|
docile (1.4.0)
|
||||||
|
|
@ -246,19 +246,40 @@ GEM
|
||||||
kostya-sigar (~> 2.0.0)
|
kostya-sigar (~> 2.0.0)
|
||||||
state_machines
|
state_machines
|
||||||
thor
|
thor
|
||||||
fabrication (2.22.0)
|
fabrication (2.29.0)
|
||||||
factory_bot (6.1.0)
|
factory_bot (6.1.0)
|
||||||
activesupport (>= 5.0.0)
|
activesupport (>= 5.0.0)
|
||||||
factory_bot_rails (6.1.0)
|
factory_bot_rails (6.1.0)
|
||||||
factory_bot (~> 6.1.0)
|
factory_bot (~> 6.1.0)
|
||||||
railties (>= 5.0.0)
|
railties (>= 5.0.0)
|
||||||
faraday (0.17.5)
|
faraday (1.10.0)
|
||||||
multipart-post (>= 1.2, < 3)
|
faraday-em_http (~> 1.0)
|
||||||
|
faraday-em_synchrony (~> 1.0)
|
||||||
|
faraday-excon (~> 1.1)
|
||||||
|
faraday-httpclient (~> 1.0)
|
||||||
|
faraday-multipart (~> 1.0)
|
||||||
|
faraday-net_http (~> 1.0)
|
||||||
|
faraday-net_http_persistent (~> 1.0)
|
||||||
|
faraday-patron (~> 1.0)
|
||||||
|
faraday-rack (~> 1.0)
|
||||||
|
faraday-retry (~> 1.0)
|
||||||
|
ruby2_keywords (>= 0.0.4)
|
||||||
faraday-cookie_jar (0.0.7)
|
faraday-cookie_jar (0.0.7)
|
||||||
faraday (>= 0.8.0)
|
faraday (>= 0.8.0)
|
||||||
http-cookie (~> 1.0.0)
|
http-cookie (~> 1.0.0)
|
||||||
faraday_middleware (0.14.0)
|
faraday-em_http (1.0.0)
|
||||||
faraday (>= 0.7.4, < 1.0)
|
faraday-em_synchrony (1.0.0)
|
||||||
|
faraday-excon (1.1.0)
|
||||||
|
faraday-follow_redirects (0.3.0)
|
||||||
|
faraday (>= 1, < 3)
|
||||||
|
faraday-httpclient (1.0.1)
|
||||||
|
faraday-multipart (1.0.4)
|
||||||
|
multipart-post (~> 2)
|
||||||
|
faraday-net_http (1.0.1)
|
||||||
|
faraday-net_http_persistent (1.2.0)
|
||||||
|
faraday-patron (1.0.0)
|
||||||
|
faraday-rack (1.0.0)
|
||||||
|
faraday-retry (1.0.3)
|
||||||
ffi (1.15.5)
|
ffi (1.15.5)
|
||||||
ffi-compiler (1.0.1)
|
ffi-compiler (1.0.1)
|
||||||
ffi (>= 1.0.0)
|
ffi (>= 1.0.0)
|
||||||
|
|
@ -618,6 +639,7 @@ GEM
|
||||||
ruby-progressbar (1.11.0)
|
ruby-progressbar (1.11.0)
|
||||||
ruby-vips (2.1.4)
|
ruby-vips (2.1.4)
|
||||||
ffi (~> 1.12)
|
ffi (~> 1.12)
|
||||||
|
ruby2_keywords (0.0.5)
|
||||||
rubyzip (2.3.2)
|
rubyzip (2.3.2)
|
||||||
rugged (1.0.1)
|
rugged (1.0.1)
|
||||||
sass (3.4.25)
|
sass (3.4.25)
|
||||||
|
|
@ -707,7 +729,7 @@ GEM
|
||||||
unf (~> 0.1.0)
|
unf (~> 0.1.0)
|
||||||
typhoeus (1.4.0)
|
typhoeus (1.4.0)
|
||||||
ethon (>= 0.9.0)
|
ethon (>= 0.9.0)
|
||||||
tzinfo (2.0.4)
|
tzinfo (2.0.5)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
|
|
@ -778,14 +800,14 @@ DEPENDENCIES
|
||||||
devise (= 4.8.1)
|
devise (= 4.8.1)
|
||||||
devise-two-factor (= 4.0.2)
|
devise-two-factor (= 4.0.2)
|
||||||
devise_lastseenable (= 0.0.6)
|
devise_lastseenable (= 0.0.6)
|
||||||
diaspora_federation-json_schema (= 0.2.8)
|
diaspora_federation-json_schema (= 1.0.0)
|
||||||
diaspora_federation-rails (= 0.2.8)
|
diaspora_federation-rails (= 1.0.0)
|
||||||
diaspora_federation-test (= 0.2.8)
|
diaspora_federation-test (= 1.0.0)
|
||||||
eye (= 0.10.0)
|
eye (= 0.10.0)
|
||||||
factory_bot_rails (= 6.1.0)
|
factory_bot_rails (= 6.1.0)
|
||||||
faraday (= 0.17.5)
|
faraday (= 1.10.0)
|
||||||
faraday-cookie_jar (= 0.0.7)
|
faraday-cookie_jar (= 0.0.7)
|
||||||
faraday_middleware (= 0.14.0)
|
faraday-follow_redirects (= 0.3.0)
|
||||||
fixture_builder (= 0.5.2)
|
fixture_builder (= 0.5.2)
|
||||||
fog-aws (= 3.14.0)
|
fog-aws (= 3.14.0)
|
||||||
fuubar (= 2.5.1)
|
fuubar (= 2.5.1)
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,7 @@ module Workers
|
||||||
DiasporaFederation::Salmon::InvalidEncoding,
|
DiasporaFederation::Salmon::InvalidEncoding,
|
||||||
Diaspora::Federation::AuthorIgnored,
|
Diaspora::Federation::AuthorIgnored,
|
||||||
Diaspora::Federation::InvalidAuthor,
|
Diaspora::Federation::InvalidAuthor,
|
||||||
Diaspora::Federation::RecipientClosed,
|
Diaspora::Federation::RecipientClosed => e
|
||||||
# TODO: deprecated
|
|
||||||
DiasporaFederation::Salmon::MissingMagicEnvelope,
|
|
||||||
DiasporaFederation::Salmon::MissingAuthor,
|
|
||||||
DiasporaFederation::Salmon::MissingHeader,
|
|
||||||
DiasporaFederation::Salmon::InvalidHeader => e
|
|
||||||
logger.warn "don't retry for error: #{e.class}"
|
logger.warn "don't retry for error: #{e.class}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@
|
||||||
|
|
||||||
module Workers
|
module Workers
|
||||||
class ReceivePrivate < ReceiveBase
|
class ReceivePrivate < ReceiveBase
|
||||||
def perform(user_id, data, legacy)
|
def perform(user_id, data)
|
||||||
filter_errors_for_retry do
|
filter_errors_for_retry do
|
||||||
user_private_key = User.where(id: user_id).pluck(:serialized_private_key).first
|
user_private_key = User.where(id: user_id).pluck(:serialized_private_key).first
|
||||||
rsa_key = OpenSSL::PKey::RSA.new(user_private_key)
|
rsa_key = OpenSSL::PKey::RSA.new(user_private_key)
|
||||||
DiasporaFederation::Federation::Receiver.receive_private(data, rsa_key, user_id, legacy)
|
DiasporaFederation::Federation::Receiver.receive_private(data, rsa_key, user_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
module Workers
|
module Workers
|
||||||
class ReceivePublic < ReceiveBase
|
class ReceivePublic < ReceiveBase
|
||||||
def perform(data, legacy=false)
|
def perform(data)
|
||||||
filter_errors_for_retry do
|
filter_errors_for_retry do
|
||||||
DiasporaFederation::Federation::Receiver.receive_public(data, legacy)
|
DiasporaFederation::Federation::Receiver.receive_public(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ DiasporaFederation.configure do |config|
|
||||||
guid: person.guid,
|
guid: person.guid,
|
||||||
nickname: person.username,
|
nickname: person.username,
|
||||||
full_name: "#{person.profile.first_name} #{person.profile.last_name}".strip,
|
full_name: "#{person.profile.first_name} #{person.profile.last_name}".strip,
|
||||||
url: AppConfig.pod_uri,
|
|
||||||
photo_large_url: person.image_url,
|
photo_large_url: person.image_url,
|
||||||
photo_medium_url: person.image_url(size: :thumb_medium),
|
photo_medium_url: person.image_url(size: :thumb_medium),
|
||||||
photo_small_url: person.image_url(size: :thumb_small),
|
photo_small_url: person.image_url(size: :thumb_small),
|
||||||
|
|
@ -90,15 +89,15 @@ DiasporaFederation.configure do |config|
|
||||||
Diaspora::Federation::Entities.related_entity(entity) if entity
|
Diaspora::Federation::Entities.related_entity(entity) if entity
|
||||||
end
|
end
|
||||||
|
|
||||||
on :queue_public_receive do |xml, legacy=false|
|
on :queue_public_receive do |xml|
|
||||||
Workers::ReceivePublic.perform_async(xml, legacy)
|
Workers::ReceivePublic.perform_async(xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
on :queue_private_receive do |guid, xml, legacy=false|
|
on :queue_private_receive do |guid, xml|
|
||||||
person = Person.find_by_guid(guid)
|
person = Person.find_by_guid(guid)
|
||||||
|
|
||||||
(person.present? && person.owner_id.present?).tap do |user_found|
|
(person.present? && person.owner_id.present?).tap do |user_found|
|
||||||
Workers::ReceivePrivate.perform_async(person.owner.id, xml, legacy) if user_found
|
Workers::ReceivePrivate.perform_async(person.owner.id, xml) if user_found
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ options = {
|
||||||
}
|
}
|
||||||
|
|
||||||
Faraday.default_connection = Faraday::Connection.new(options) do |b|
|
Faraday.default_connection = Faraday::Connection.new(options) do |b|
|
||||||
b.use FaradayMiddleware::FollowRedirects, limit: 8
|
b.use Faraday::FollowRedirects::Middleware, limit: 8
|
||||||
b.use :cookie_jar
|
b.use :cookie_jar
|
||||||
b.adapter Faraday.default_adapter
|
b.adapter Faraday.default_adapter
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ class ConnectionTester
|
||||||
raise NetFailure, e.message
|
raise NetFailure, e.message
|
||||||
rescue Faraday::SSLError => e
|
rescue Faraday::SSLError => e
|
||||||
raise SSLFailure, e.message
|
raise SSLFailure, e.message
|
||||||
rescue ArgumentError, FaradayMiddleware::RedirectLimitReached, Faraday::ClientError => e
|
rescue ArgumentError, Faraday::FollowRedirects::RedirectLimitReached, Faraday::ClientError => e
|
||||||
raise HTTPFailure, e.message
|
raise HTTPFailure, e.message
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
unexpected_error(e)
|
unexpected_error(e)
|
||||||
|
|
@ -146,7 +146,7 @@ class ConnectionTester
|
||||||
def with_http_connection
|
def with_http_connection
|
||||||
@http ||= Faraday.new(@url) do |c|
|
@http ||= Faraday.new(@url) do |c|
|
||||||
c.use Faraday::Response::RaiseError
|
c.use Faraday::Response::RaiseError
|
||||||
c.use FaradayMiddleware::FollowRedirects, limit: 3
|
c.use Faraday::FollowRedirects::Middleware, limit: 3
|
||||||
c.adapter(Faraday.default_adapter)
|
c.adapter(Faraday.default_adapter)
|
||||||
c.headers[:user_agent] = "diaspora-connection-tester"
|
c.headers[:user_agent] = "diaspora-connection-tester"
|
||||||
c.options.timeout = 12
|
c.options.timeout = 12
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ class Pubsubhubbub
|
||||||
|
|
||||||
conn = Faraday.new do |c|
|
conn = Faraday.new do |c|
|
||||||
c.use Faraday::Request::UrlEncoded # encode request params as "www-form-urlencoded"
|
c.use Faraday::Request::UrlEncoded # encode request params as "www-form-urlencoded"
|
||||||
c.use Faraday::Adapter::NetHttp # perform requests with Net::HTTP
|
c.adapter Faraday::Adapter::NetHttp # perform requests with Net::HTTP
|
||||||
end
|
end
|
||||||
conn.post @hub, {'hub.url' => feed, 'hub.mode' => 'publish'}
|
conn.post @hub, {'hub.url' => feed, 'hub.mode' => 'publish'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ describe "diaspora federation callbacks" do
|
||||||
expect(hcard.guid).to eq(person.guid)
|
expect(hcard.guid).to eq(person.guid)
|
||||||
expect(hcard.nickname).to eq(person.username)
|
expect(hcard.nickname).to eq(person.username)
|
||||||
expect(hcard.full_name).to eq("#{person.profile.first_name} #{person.profile.last_name}")
|
expect(hcard.full_name).to eq("#{person.profile.first_name} #{person.profile.last_name}")
|
||||||
expect(hcard.url).to eq(AppConfig.pod_uri)
|
|
||||||
expect(hcard.photo_large_url).to eq(person.image_url)
|
expect(hcard.photo_large_url).to eq(person.image_url)
|
||||||
expect(hcard.photo_medium_url).to eq(person.image_url(size: :thumb_medium))
|
expect(hcard.photo_medium_url).to eq(person.image_url(size: :thumb_medium))
|
||||||
expect(hcard.photo_small_url).to eq(person.image_url(size: :thumb_small))
|
expect(hcard.photo_small_url).to eq(person.image_url(size: :thumb_small))
|
||||||
|
|
@ -310,9 +309,9 @@ describe "diaspora federation callbacks" do
|
||||||
describe ":queue_public_receive" do
|
describe ":queue_public_receive" do
|
||||||
it "enqueues a ReceivePublic job" do
|
it "enqueues a ReceivePublic job" do
|
||||||
data = "<diaspora/>"
|
data = "<diaspora/>"
|
||||||
expect(Workers::ReceivePublic).to receive(:perform_async).with(data, true)
|
expect(Workers::ReceivePublic).to receive(:perform_async).with(data)
|
||||||
|
|
||||||
DiasporaFederation.callbacks.trigger(:queue_public_receive, data, true)
|
DiasporaFederation.callbacks.trigger(:queue_public_receive, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -325,19 +324,19 @@ describe "diaspora federation callbacks" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enqueues a ReceivePrivate job" do
|
it "enqueues a ReceivePrivate job" do
|
||||||
expect(Workers::ReceivePrivate).to receive(:perform_async).with(alice.id, data, true)
|
expect(Workers::ReceivePrivate).to receive(:perform_async).with(alice.id, data)
|
||||||
|
|
||||||
DiasporaFederation.callbacks.trigger(:queue_private_receive, alice.person.guid, data, true)
|
DiasporaFederation.callbacks.trigger(:queue_private_receive, alice.person.guid, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if the no user is found" do
|
it "returns false if the no user is found" do
|
||||||
person = FactoryBot.create(:person)
|
person = FactoryBot.create(:person)
|
||||||
result = DiasporaFederation.callbacks.trigger(:queue_private_receive, person.guid, data, true)
|
result = DiasporaFederation.callbacks.trigger(:queue_private_receive, person.guid, data)
|
||||||
expect(result).to be_falsey
|
expect(result).to be_falsey
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if the no person is found" do
|
it "returns false if the no person is found" do
|
||||||
result = DiasporaFederation.callbacks.trigger(:queue_private_receive, "2398rq3948yftn", data, true)
|
result = DiasporaFederation.callbacks.trigger(:queue_private_receive, "2398rq3948yftn", data)
|
||||||
expect(result).to be_falsey
|
expect(result).to be_falsey
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,6 @@ def allow_callbacks(callbacks)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_relayable_entity(entity_name, parent, diaspora_id)
|
def create_relayable_entity(entity_name, parent, diaspora_id)
|
||||||
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
|
|
||||||
:fetch_private_key, alice.diaspora_handle
|
|
||||||
).at_least(1).times.and_return(nil) if parent == local_parent
|
|
||||||
|
|
||||||
Fabricate(
|
Fabricate(
|
||||||
entity_name,
|
entity_name,
|
||||||
parent_guid: parent.guid,
|
parent_guid: parent.guid,
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ describe Workers::ReceivePrivate do
|
||||||
rsa_key = double
|
rsa_key = double
|
||||||
|
|
||||||
expect(OpenSSL::PKey::RSA).to receive(:new).with(alice.serialized_private_key).and_return(rsa_key)
|
expect(OpenSSL::PKey::RSA).to receive(:new).with(alice.serialized_private_key).and_return(rsa_key)
|
||||||
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with(data, rsa_key, alice.id, true)
|
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with(data, rsa_key, alice.id)
|
||||||
|
|
||||||
Workers::ReceivePrivate.new.perform(alice.id, data, true)
|
Workers::ReceivePrivate.new.perform(alice.id, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "filters errors that would also fail on second try" do
|
it "filters errors that would also fail on second try" do
|
||||||
|
|
@ -17,11 +17,11 @@ describe Workers::ReceivePrivate do
|
||||||
|
|
||||||
expect(OpenSSL::PKey::RSA).to receive(:new).with(alice.serialized_private_key).and_return(rsa_key)
|
expect(OpenSSL::PKey::RSA).to receive(:new).with(alice.serialized_private_key).and_return(rsa_key)
|
||||||
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with(
|
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with(
|
||||||
data, rsa_key, alice.id, false
|
data, rsa_key, alice.id
|
||||||
).and_raise(DiasporaFederation::Salmon::InvalidSignature)
|
).and_raise(DiasporaFederation::Salmon::InvalidSignature)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
Workers::ReceivePrivate.new.perform(alice.id, data, false)
|
Workers::ReceivePrivate.new.perform(alice.id, data)
|
||||||
}.not_to raise_error
|
}.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -30,11 +30,11 @@ describe Workers::ReceivePrivate do
|
||||||
|
|
||||||
expect(OpenSSL::PKey::RSA).to receive(:new).with(alice.serialized_private_key).and_return(rsa_key)
|
expect(OpenSSL::PKey::RSA).to receive(:new).with(alice.serialized_private_key).and_return(rsa_key)
|
||||||
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with(
|
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_private).with(
|
||||||
data, rsa_key, alice.id, false
|
data, rsa_key, alice.id
|
||||||
).and_raise(DiasporaFederation::Federation::Fetcher::NotFetchable)
|
).and_raise(DiasporaFederation::Federation::Fetcher::NotFetchable)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
Workers::ReceivePrivate.new.perform(alice.id, data, false)
|
Workers::ReceivePrivate.new.perform(alice.id, data)
|
||||||
}.to raise_error DiasporaFederation::Federation::Fetcher::NotFetchable
|
}.to raise_error DiasporaFederation::Federation::Fetcher::NotFetchable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,28 +4,26 @@ describe Workers::ReceivePublic do
|
||||||
let(:data) { "<xml></xml>" }
|
let(:data) { "<xml></xml>" }
|
||||||
|
|
||||||
it "calls receive_public of federation gem" do
|
it "calls receive_public of federation gem" do
|
||||||
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_public).with(data, true)
|
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_public).with(data)
|
||||||
|
|
||||||
Workers::ReceivePublic.new.perform(data, true)
|
Workers::ReceivePublic.new.perform(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "filters errors that would also fail on second try" do
|
it "filters errors that would also fail on second try" do
|
||||||
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_public).with(
|
expect(DiasporaFederation::Federation::Receiver)
|
||||||
data, false
|
.to receive(:receive_public).with(data).and_raise(DiasporaFederation::Salmon::InvalidSignature)
|
||||||
).and_raise(DiasporaFederation::Salmon::InvalidSignature)
|
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
Workers::ReceivePublic.new.perform(data, false)
|
Workers::ReceivePublic.new.perform(data)
|
||||||
}.not_to raise_error
|
}.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not filter errors that would succeed on second try" do
|
it "does not filter errors that would succeed on second try" do
|
||||||
expect(DiasporaFederation::Federation::Receiver).to receive(:receive_public).with(
|
expect(DiasporaFederation::Federation::Receiver)
|
||||||
data, false
|
.to receive(:receive_public).with(data).and_raise(DiasporaFederation::Federation::Fetcher::NotFetchable)
|
||||||
).and_raise(DiasporaFederation::Federation::Fetcher::NotFetchable)
|
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
Workers::ReceivePublic.new.perform(data, false)
|
Workers::ReceivePublic.new.perform(data)
|
||||||
}.to raise_error DiasporaFederation::Federation::Fetcher::NotFetchable
|
}.to raise_error DiasporaFederation::Federation::Fetcher::NotFetchable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue