From 80ba4c0db75d28e8a2110181955f4ac377ce0142 Mon Sep 17 00:00:00 2001 From: Roberto Miranda Date: Thu, 28 Nov 2024 15:09:08 +0000 Subject: [PATCH] Fix sinatra 4.1 host authorization --- test/avro_deserializer_test.rb | 6 +++--- test/avro_event_test.rb | 6 +++--- .../authorized_fake_confluent_schema_registry_server.rb | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 test/support/authorized_fake_confluent_schema_registry_server.rb diff --git a/test/avro_deserializer_test.rb b/test/avro_deserializer_test.rb index 68a81bd..38d74e6 100644 --- a/test/avro_deserializer_test.rb +++ b/test/avro_deserializer_test.rb @@ -1,5 +1,5 @@ require "test_helper" -require "avro_turf/test/fake_confluent_schema_registry_server" +require_relative "support/authorized_fake_confluent_schema_registry_server" require "webmock/minitest" require "ostruct" @@ -9,8 +9,8 @@ def setup Streamy.configuration.avro_schema_registry_url = "http://registry.example.com" Streamy.configuration.avro_schemas_path = "test/fixtures/schemas" Serializers::AvroSerializer.clear_messaging_cache - FakeConfluentSchemaRegistryServer.clear - stub_request(:any, /^#{Streamy.configuration.avro_schema_registry_url}/).to_rack(FakeConfluentSchemaRegistryServer) + stub_request(:any, /^#{Streamy.configuration.avro_schema_registry_url}/).to_rack(AuthorizedFakeConfluentSchemaRegistryServer) + AuthorizedFakeConfluentSchemaRegistryServer.clear end class TestEvent < AvroEvent diff --git a/test/avro_event_test.rb b/test/avro_event_test.rb index a08b689..55d7d09 100644 --- a/test/avro_event_test.rb +++ b/test/avro_event_test.rb @@ -1,5 +1,5 @@ require "test_helper" -require "avro_turf/test/fake_confluent_schema_registry_server" +require_relative "support/authorized_fake_confluent_schema_registry_server" require "webmock/minitest" module Streamy @@ -8,8 +8,8 @@ def setup Streamy.configuration.avro_schema_registry_url = "http://registry.example.com" Streamy.configuration.avro_schemas_path = "test/fixtures/schemas" Serializers::AvroSerializer.clear_messaging_cache - FakeConfluentSchemaRegistryServer.clear - stub_request(:any, /^#{Streamy.configuration.avro_schema_registry_url}/).to_rack(FakeConfluentSchemaRegistryServer) + stub_request(:any, /^#{Streamy.configuration.avro_schema_registry_url}/).to_rack(AuthorizedFakeConfluentSchemaRegistryServer) + AuthorizedFakeConfluentSchemaRegistryServer.clear end class TestEvent < AvroEvent diff --git a/test/support/authorized_fake_confluent_schema_registry_server.rb b/test/support/authorized_fake_confluent_schema_registry_server.rb new file mode 100644 index 0000000..02ed10e --- /dev/null +++ b/test/support/authorized_fake_confluent_schema_registry_server.rb @@ -0,0 +1,5 @@ +require "avro_turf/test/fake_confluent_schema_registry_server" + +class AuthorizedFakeConfluentSchemaRegistryServer < FakeConfluentSchemaRegistryServer + set :host_authorization, permitted_hosts: ['example.org', 'registry.example.com'] +end