diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f4ebf82c0..9fa72d8cf 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,6 +9,13 @@ concurrency: defaults: run: shell: bash +env: + SDK_PAM_SUB_KEY: ${{ secrets.SDK_PAM_SUB_KEY }} + SDK_PAM_PUB_KEY: ${{ secrets.SDK_PAM_PUB_KEY }} + SDK_PAM_SEC_KEY: ${{ secrets.SDK_PAM_SEC_KEY }} + SDK_SUB_KEY: ${{ secrets.SDK_SUB_KEY }} + SDK_PUB_KEY: ${{ secrets.SDK_PUB_KEY }} + jobs: diff --git a/.pubnub.yml b/.pubnub.yml index d3a0c87a4..fdc8df67a 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,6 +1,11 @@ --- -version: "5.3.3" +version: "5.3.4" changelog: + - date: 2024-04-29 + version: v5.3.4 + changes: + - type: bug + text: "Fix issue because of which client didn't encode App Context get all event `filter` query value." - date: 2024-01-29 version: v5.3.3 changes: @@ -571,7 +576,7 @@ sdks: - x86-64 - distribution-type: package distribution-repository: RubyGems - package-name: pubnub-5.3.3.gem + package-name: pubnub-5.3.4.gem location: https://rubygems.org/gems/pubnub requires: - name: addressable @@ -676,8 +681,8 @@ sdks: - x86-64 - distribution-type: library distribution-repository: GitHub release - package-name: pubnub-5.3.3.gem - location: https://github.com/pubnub/ruby/releases/download/v5.3.3/pubnub-5.3.3.gem + package-name: pubnub-5.3.4.gem + location: https://github.com/pubnub/ruby/releases/download/v5.3.4/pubnub-5.3.4.gem requires: - name: addressable min-version: 2.0.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 000b3e16c..02d500434 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v5.3.4 +April 29 2024 + +#### Fixed +- Fix issue because of which client didn't encode App Context get all event `filter` query value. + ## v5.3.3 January 29 2024 diff --git a/Gemfile.lock b/Gemfile.lock index 1bcc6f03c..f329a3c63 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - pubnub (5.3.3) + pubnub (5.3.4) addressable (>= 2.0.0) concurrent-ruby (~> 1.1.5) concurrent-ruby-edge (~> 0.5.0) diff --git a/VERSION b/VERSION index 74664af74..e0a61e6a8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.3.3 +5.3.4 diff --git a/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata_with_filter_and_secret.yml b/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata_with_filter_and_secret.yml new file mode 100644 index 000000000..099fbc0ae --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata_with_filter_and_secret.yml @@ -0,0 +1,73 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?include=1&pnsdk=PubNub-Ruby/5.3.3&signature=v2.YxJFOwRREFlkCGawTu7x8DVs-aBylBL0Ol5316h32Y4×tamp=1714133102&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"name":"some_name","custom":{"XXX":"YYYY"}}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Fri, 26 Apr 2024 12:05:02 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 26 Apr 2024 12:05:02 GMT + Content-Type: + - application/json + Content-Length: + - '161' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"updated":"2024-04-26T10:27:32.517008Z","eTag":"52da053241bacffd8c951390d273e7c9"}}' + recorded_at: Fri, 26 Apr 2024 12:05:02 GMT +- request: + method: get + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels?count=1&filter=(name==%22some_name%22)&include=custom&l_obj=0.576&limit=5&pnsdk=PubNub-Ruby/5.3.3&signature=v2.lVw9ZV0HvyHhhZ1WAU6rVFuvoZbMjuND5TwWhktrbgs×tamp=1714133102&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Fri, 26 Apr 2024 12:05:02 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 26 Apr 2024 12:05:03 GMT + Content-Type: + - application/json + Content-Length: + - '366' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"id":"[\"rb_channel\"]","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2020-10-13T11:43:29.824332Z","eTag":"AZTUtcvx6NDGLQ"},{"id":"rb_channel","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2024-04-26T10:27:32.517008Z","eTag":"52da053241bacffd8c951390d273e7c9"}],"totalCount":2,"next":"Mg"}' + recorded_at: Fri, 26 Apr 2024 12:05:03 GMT +recorded_with: VCR 6.2.0 diff --git a/lib/pubnub/event/signature.rb b/lib/pubnub/event/signature.rb index 53dbbe83f..773adca20 100644 --- a/lib/pubnub/event/signature.rb +++ b/lib/pubnub/event/signature.rb @@ -39,12 +39,13 @@ def super_admin_signature(http_method, body) def variables_for_signature unsorted_params = parameters(true) - sorted_keys = unsorted_params.sort_by {|k, v| k.to_s} + sorted_keys = unsorted_params.sort_by { |k, v| k.to_s } sorted_keys.map do |k, v| - if %w[meta ortt].include?(k.to_s) - encoded_value = URI.encode_www_form_component(v.to_json).gsub('+', '%20') + if %w[meta ortt filter].include?(k.to_s) + value_for_encoding = v.is_a?(String) ? v : v.to_json + encoded_value = URI.encode_www_form_component(value_for_encoding).gsub('+', '%20') "#{k}=#{encoded_value}" - elsif %w[t state filter-expr sort filter].include?(k.to_s) + elsif %w[t state filter-expr sort].include?(k.to_s) "#{k}=#{v}" else "#{k}=#{URI.encode_www_form_component(v.to_s).gsub('+', '%20')}" diff --git a/lib/pubnub/formatter.rb b/lib/pubnub/formatter.rb index 094c17691..9704b2927 100644 --- a/lib/pubnub/formatter.rb +++ b/lib/pubnub/formatter.rb @@ -118,10 +118,11 @@ def parse_json(string) def params_hash_to_url_params(hash) params = '' hash.sort_by { |k, _v| k.to_s }.to_h.each do |key, value| - if %w[meta ortt].include?(key.to_s) - encoded_value = URI.encode_www_form_component(value.to_json).gsub('+', '%20') + if %w[meta ortt filter].include?(key.to_s) + value_for_encoding = value.is_a?(String) ? value : value.to_json + encoded_value = URI.encode_www_form_component(value_for_encoding).gsub('+', '%20') params << "#{key}=#{encoded_value}&" - elsif %w[t state filter filter-expr].include?(key.to_s) + elsif %w[t state filter-expr].include?(key.to_s) params << "#{key}=#{value}&" else params << "#{key}=#{URI.encode_www_form_component(value).gsub('+', '%20')}&" diff --git a/lib/pubnub/version.rb b/lib/pubnub/version.rb index d85f14e57..c9b2da8d1 100644 --- a/lib/pubnub/version.rb +++ b/lib/pubnub/version.rb @@ -1,4 +1,4 @@ # Toplevel Pubnub module. module Pubnub - VERSION = '5.3.3'.freeze + VERSION = '5.3.4'.freeze end diff --git a/spec/lib/events/channel_metadata_spec.rb b/spec/lib/events/channel_metadata_spec.rb index 3a9f1fcae..8d41845ad 100644 --- a/spec/lib/events/channel_metadata_spec.rb +++ b/spec/lib/events/channel_metadata_spec.rb @@ -44,6 +44,35 @@ end end + it "get_all_channels_metadata_with_filter_and_secret" do + VCR.use_cassette("lib/events/get_all_channels_metadata_with_filter_and_secret", record: :once) do + Pubnub::GetAllChannelsMetadata.any_instance.stub(:current_time).and_return "1714133102" + pubnub = Pubnub.new( + :subscribe_key => 'sub-a-mock-key', # ENV['SDK_PAM_SUB_KEY'], + :publish_key => 'sub-a-mock-key', # ENV['SDK_PAM_PUB_KEY'], + :secret_key => 'sec-a-mock-key', # ENV['SDK_PAM_SEC_KEY'], + :user_id => "ruby-test-uuid", + ) + + pubnub.set_channel_metadata( + channel: "rb_channel", + metadata: { name: "some_name", custom: { XXX: "YYYY" } }, + include: { custom: true }, + http_sync: true + ) + + envelope = pubnub.get_all_channels_metadata( + limit: 5, + include: { custom: true }, + filter: '(name=="some_name")', + http_sync: true + ) + + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + end + end + it "remove_channel_metadata_works" do VCR.use_cassette("lib/events/remove_channel_metadata", record: :once) do envelope = @pubnub.remove_channel_metadata(channel: "rb_channel").value