avro_turf 1.17.0 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22e1ca443d93f4f1c38b9626ad1a83db6352a4aac397256a8a3bfae2ca462d9c
4
- data.tar.gz: 2621ae9378b2511cee81522247c5f4df883ee9c25efe92839cdc5af22543bc1f
3
+ metadata.gz: 1c6f4cafa2c752c6b0dbe23703a4d2efccf558e11cec1c33db5a1af911cca43a
4
+ data.tar.gz: 61c9bc9c1963bb89f8b00c01ad0c4195d8cf48473ea191b3d91afa88361c7aa5
5
5
  SHA512:
6
- metadata.gz: 56f2e3885be65423da7be65fe067151b3fd270ce13af76455a0f71cccbf6d68b09661e75f882c50ea9745f9cdc21e78ce8bd527d8123fa4b0c094dfaf6baa03a
7
- data.tar.gz: 4b8e92503870f8c83c8af5457786da3c83823706d957a96986488f2800166ae02846141e9eeb28c261c6b0e0f5d7922244f65dfb47e39bbc96a9a29fea075e55
6
+ metadata.gz: 1b7792365879b2d4dab3f7a160687ba7308c8f5cb6f9d788506ad087bfb56056f867328bc5357ab011917588bb7e67219300c00e3cadcdef389b927f8cf398de
7
+ data.tar.gz: 834dcc062ca3e2a6f6b4eafecd8425abacad9ca64d972bbe03100def4e7af2adb706d2fcde541d31d6ff199e9b3ce51f47774269adc55191a7b6d9dc2ed5e224
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## v1.18.0
6
+
7
+ - Add `compatibility_issues` method to `ConfluentSchemaRegistry` to debug compatibility issues between a schema versions for a given subject (#212)
8
+ - Update tests to support `sinatra` version 4.1 that includes a new `host_authorization` parameter to permit only authorized requests
9
+
5
10
  ## v1.17.0
6
11
 
7
12
  - Add `register_schemas` option to `encode` method [#210](https://github.com/dasch/avro_turf/pull/210)
data/README.md CHANGED
@@ -254,6 +254,9 @@ registry = AvroTurf::ConfluentSchemaRegistry.new("http://my-registry:8081/")
254
254
 
255
255
  # Returns true if the schema is compatible, nil if the subject or version is not registered, and false if incompatible.
256
256
  registry.compatible?("person", schema)
257
+
258
+ # Returns an array of any breaking changes, nil if the subject or version is not registered
259
+ registry.compatibility_issues("person", schema)
257
260
  ```
258
261
 
259
262
  The ConfluentSchemaRegistry client can also change the global compatibility level or the compatibility level for an individual subject using the [Config API](http://docs.confluent.io/3.1.2/schema-registry/docs/api.html#config):
@@ -270,17 +273,23 @@ fake schema registry server depends on Sinatra but it is _not_ listed as a runti
270
273
  dependency for AvroTurf. Sinatra must be added to your Gemfile or gemspec in order
271
274
  to use the fake server.
272
275
 
276
+ Given the recent update in `sinatra` to fix [CVE-2024-21510](https://github.com/advisories/GHSA-hxx2-7vcw-mqr3) that included a new `HostAuthorization` middleware, the `FakeConfluentSchemaRegistryServer` is provided as a base implementation that has to be inherited into a new class and configured by the user so requests are properly authorised to the test registry host.
277
+
273
278
  Example using RSpec:
274
279
 
275
280
  ```ruby
276
281
  require 'avro_turf/test/fake_confluent_schema_registry_server'
277
282
  require 'webmock/rspec'
278
283
 
284
+ class AuthorizedFakeConfluentSchemaRegistryServer < FakeConfluentSchemaRegistryServer
285
+ set :host_authentication, permitted_hosts: ['registry.example.com']
286
+ end
287
+
279
288
  # within an example
280
289
  let(:registry_url) { "http://registry.example.com" }
281
290
  before do
282
- stub_request(:any, /^#{registry_url}/).to_rack(FakeConfluentSchemaRegistryServer)
283
- FakeConfluentSchemaRegistryServer.clear
291
+ stub_request(:any, /^#{registry_url}/).to_rack(AuthorizedFakeConfluentSchemaRegistryServer)
292
+ AuthorizedFakeConfluentSchemaRegistryServer.clear
284
293
  end
285
294
 
286
295
  # Messaging objects created with the same registry_url will now use the fake server.
@@ -101,6 +101,18 @@ class AvroTurf::ConfluentSchemaRegistry
101
101
  data.fetch('is_compatible', false) unless data.has_key?('error_code')
102
102
  end
103
103
 
104
+ # Check for specific schema compatibility issues
105
+ # Returns:
106
+ # - nil if the subject or version does not exist
107
+ # - a list of compatibility issues
108
+ # https://docs.confluent.io/platform/current/schema-registry/develop/api.html#sr-api-compatibility
109
+ def compatibility_issues(subject, schema, version = 'latest')
110
+ data = post("/compatibility/subjects/#{@schema_context_prefix}#{subject}/versions/#{version}",
111
+ expects: [200, 404], body: { schema: schema.to_s }.to_json, query: { verbose: true }, idempotent: true)
112
+
113
+ data.fetch('messages', []) unless data.has_key?('error_code')
114
+ end
115
+
104
116
  # Get global config
105
117
  def global_config
106
118
  get("/config", idempotent: true)
@@ -92,6 +92,6 @@ class AvroTurf::SchemaStore
92
92
 
93
93
  def build_schema_path(fullname)
94
94
  *namespace, schema_name = fullname.split(".")
95
- schema_path = File.join(@path, *namespace, schema_name + ".avsc")
95
+ File.join(@path, *namespace, "#{schema_name}.avsc")
96
96
  end
97
97
  end
@@ -1,3 +1,3 @@
1
1
  class AvroTurf
2
- VERSION = "1.17.0"
2
+ VERSION = "1.18.0"
3
3
  end
@@ -1,7 +1,5 @@
1
1
  require 'webmock/rspec'
2
2
  require 'avro_turf/messaging'
3
- require 'avro_turf/test/fake_confluent_schema_registry_server'
4
- require 'avro_turf/test/fake_prefixed_confluent_schema_registry_server'
5
3
 
6
4
  describe AvroTurf::Messaging do
7
5
  let(:registry_url) { "http://registry.example.com" }
@@ -61,8 +59,8 @@ describe AvroTurf::Messaging do
61
59
  end
62
60
 
63
61
  before do
64
- stub_request(:any, /^#{registry_url}/).to_rack(FakeConfluentSchemaRegistryServer)
65
- FakeConfluentSchemaRegistryServer.clear
62
+ stub_request(:any, /^#{registry_url}/).to_rack(AuthorizedFakeConfluentSchemaRegistryServer)
63
+ AuthorizedFakeConfluentSchemaRegistryServer.clear
66
64
  end
67
65
 
68
66
  before do
@@ -474,8 +472,8 @@ describe AvroTurf::Messaging do
474
472
  }
475
473
 
476
474
  before do
477
- stub_request(:any, /^#{registry_url}/).to_rack(FakePrefixedConfluentSchemaRegistryServer)
478
- FakePrefixedConfluentSchemaRegistryServer.clear
475
+ stub_request(:any, /^#{registry_url}/).to_rack(AuthorizedFakePrefixedConfluentSchemaRegistryServer)
476
+ AuthorizedFakePrefixedConfluentSchemaRegistryServer.clear
479
477
  end
480
478
 
481
479
  it_behaves_like "encoding and decoding with the schema from schema store"
@@ -0,0 +1,5 @@
1
+ require 'avro_turf/test/fake_confluent_schema_registry_server'
2
+
3
+ class AuthorizedFakeConfluentSchemaRegistryServer < FakeConfluentSchemaRegistryServer
4
+ set :host_authorization, permitted_hosts: ['example.org', 'registry.example.com']
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'avro_turf/test/fake_prefixed_confluent_schema_registry_server'
2
+
3
+ class AuthorizedFakePrefixedConfluentSchemaRegistryServer < FakePrefixedConfluentSchemaRegistryServer
4
+ set :host_authorization, permitted_hosts: ['example.org', 'registry.example.com']
5
+ end
@@ -26,9 +26,9 @@ shared_examples_for "a confluent schema registry client" do |schema_context: nil
26
26
  before do
27
27
  stub_request(:any, /^#{registry_url}/)
28
28
  .with(headers: headers)
29
- .to_rack(FakeConfluentSchemaRegistryServer)
29
+ .to_rack(AuthorizedFakeConfluentSchemaRegistryServer)
30
30
 
31
- FakeConfluentSchemaRegistryServer.clear
31
+ AuthorizedFakeConfluentSchemaRegistryServer.clear
32
32
  end
33
33
 
34
34
  describe "#register and #fetch" do
@@ -1,10 +1,9 @@
1
1
  require 'rack/test'
2
- require 'avro_turf/test/fake_confluent_schema_registry_server'
3
2
 
4
3
  describe FakeConfluentSchemaRegistryServer do
5
4
  include Rack::Test::Methods
6
5
 
7
- def app; described_class; end
6
+ def app; AuthorizedFakeConfluentSchemaRegistryServer; end
8
7
 
9
8
  describe 'POST /subjects/:subject/versions' do
10
9
  it 'returns the same schema ID when invoked with same schema and same subject' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avro_turf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
4
+ version: 1.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-26 00:00:00.000000000 Z
11
+ date: 2024-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro
@@ -236,6 +236,8 @@ files:
236
236
  - spec/schema_store_spec.rb
237
237
  - spec/schema_to_avro_patch_spec.rb
238
238
  - spec/spec_helper.rb
239
+ - spec/support/authorized_fake_confluent_schema_registry_server.rb
240
+ - spec/support/authorized_fake_prefixed_confluent_schema_registry_server.rb
239
241
  - spec/support/confluent_schema_registry_context.rb
240
242
  - spec/test/fake_confluent_schema_registry_server_spec.rb
241
243
  homepage: https://github.com/dasch/avro_turf
@@ -266,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
268
  - !ruby/object:Gem::Version
267
269
  version: '0'
268
270
  requirements: []
269
- rubygems_version: 3.5.11
271
+ rubygems_version: 3.5.22
270
272
  signing_key:
271
273
  specification_version: 4
272
274
  summary: A library that makes it easier to use the Avro serialization format from
@@ -290,5 +292,7 @@ test_files:
290
292
  - spec/schema_store_spec.rb
291
293
  - spec/schema_to_avro_patch_spec.rb
292
294
  - spec/spec_helper.rb
295
+ - spec/support/authorized_fake_confluent_schema_registry_server.rb
296
+ - spec/support/authorized_fake_prefixed_confluent_schema_registry_server.rb
293
297
  - spec/support/confluent_schema_registry_context.rb
294
298
  - spec/test/fake_confluent_schema_registry_server_spec.rb