From 6e2cea0f14a44e848738b39bdd0a4c42b971e674 Mon Sep 17 00:00:00 2001 From: Syphax bouazzouni Date: Fri, 10 May 2024 18:02:31 +0200 Subject: [PATCH] handle ssl error exception when federated call to a collection --- lib/ontologies_api_client/collection.rb | 2 +- test/models/test_federation.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/ontologies_api_client/collection.rb b/lib/ontologies_api_client/collection.rb index 5ef779b..a4d34c2 100644 --- a/lib/ontologies_api_client/collection.rb +++ b/lib/ontologies_api_client/collection.rb @@ -46,7 +46,7 @@ def uri_from_context(object, media_type) def entry_point(media_type, params = {}) params = { include: @include_attrs, display_links: false, display_context: false}.merge(params) federated_get(params) do |url| - uri_from_context(top_level_links(url), media_type) + uri_from_context(top_level_links(url), media_type) rescue nil end end diff --git a/test/models/test_federation.rb b/test/models/test_federation.rb index f66d8db..4890af5 100644 --- a/test/models/test_federation.rb +++ b/test/models/test_federation.rb @@ -108,4 +108,15 @@ def test_federated_analytics analytics = LinkedData::Client::Analytics.last_month refute_empty analytics.onts end + + + def test_federation_ssl_error + WebMock.enable! + WebMock.stub_request(:get, "#{LinkedData::Client.settings.rest_url.chomp('/')}") + .to_raise(Faraday::SSLError) + ontologies_federate_one = LinkedData::Client::Models::Ontology.all(display_links: false, display_context: false, invalidate_cache: true) + + refute_nil ontologies_federate_one.first.errors + WebMock.disable! + end end \ No newline at end of file