Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
test:
Expand All @@ -14,10 +15,10 @@ jobs:
matrix:
ruby-version:
- '3.1.7'
- '3.2.8'
- '3.3.8'
- '3.4.4'
- '4.0.0-preview3'
- '3.2.9'
- '3.3.10'
- '3.4.8'
- '4.0.0'

runs-on: ubuntu-22.04

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ the [Ruby on Rails SDK Guide](https://cloudinary.com/documentation/rails_integra

## Version Support

| SDK Version | Ruby 1.9.3 | Ruby 2.x | Ruby 3.x |
|-------------|------------|----------|----------|
| 1.x | | ✔ | ✔ |
| 2.x | | | ✔ |

| SDK Version | Rails 5.x | Rails 6.x | Rails 7.x |
|-------------|-----------|-----------|-----------|
| 1.x | ✔ | ✔ | ✔ |
| 2.x | | ✔ | ✔ |
| SDK Version | Ruby 1.9.3 | Ruby 2.x | Ruby 3.x | Ruby 4.x |
|-------------|------------|----------|----------|----------|
| 2.x | ✘ | ✘ | ✔ | ✔ |
| 1.x | | | ✔ | ✘ |

| SDK Version | Rails 5.x | Rails 6.x | Rails 7.x | Rails 8.x |
|-------------|-----------|-----------|-----------|-----------|
| 2.x | ✘ | ✔ | ✔ | ✔ |
| 1.x | | ✔ | ✔ | ✘ |

## Installation

Expand Down
10 changes: 5 additions & 5 deletions cloudinary.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ Gem::Specification.new do |s|
s.add_dependency "faraday-follow_redirects", "~> 0.5"
s.add_dependency "ostruct"

s.add_development_dependency "rails", ">= 6.1.7", "< 8.0.0"
s.add_development_dependency "rails", ">= 6.1.7", "< 9.0.0"
s.add_development_dependency "rexml", ">= 3.2.5", "< 4.0.0"
s.add_development_dependency "actionpack", ">= 6.1.7", "< 8.0.0"
s.add_development_dependency "actionpack", ">= 6.1.7", "< 9.0.0"
s.add_development_dependency "nokogiri", ">= 1.12.5", "< 2.0.0"
s.add_development_dependency "rake", ">= 13.0.6", "< 14.0.0"
s.add_development_dependency "sqlite3", ">= 1.4.2", "< 2.0.0"
s.add_development_dependency "sqlite3", ">= 1.4.2", "< 3.0.0"
s.add_development_dependency "rspec", ">= 3.11.2", "< 4.0.0"
s.add_development_dependency "rspec-retry", ">= 0.6.2", "< 1.0.0"
s.add_development_dependency "railties", ">= 6.0.4", "< 8.0.0"
s.add_development_dependency "rspec-rails", ">= 6.0.4", "< 7.0.0"
s.add_development_dependency "railties", ">= 6.0.4", "< 9.0.0"
s.add_development_dependency "rspec-rails", ">= 6.0.4", "< 9.0.0"
s.add_development_dependency "rubyzip", ">= 2.3.0", "< 3.0.0"
s.add_development_dependency "simplecov", ">= 0.21.2", "< 1.0.0"
end
2 changes: 1 addition & 1 deletion samples/basic-rails/.ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
4.0.0
2 changes: 1 addition & 1 deletion samples/basic/.ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
4.0.0
2 changes: 1 addition & 1 deletion samples/photo_album/.ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
4.0.0
2 changes: 1 addition & 1 deletion samples/user_profiles_active_storage/.ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
4.0.0
8 changes: 7 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
require 'active_storage/test_helper'
require 'cloudinary'

# Replacement for CGI.parse
def parse_query_params(query_string)
URI.decode_www_form(query_string.to_s).each_with_object(Hash.new { |h, k| h[k] = [] }) do |(k, v), h|
h[k] << v
end
end

Cloudinary.config.enhance_image_tag = true

DUMMY_CLOUD = "test123"
Expand Down Expand Up @@ -551,4 +558,3 @@ def execute(options = {})
MockedApi.call_api(:post, uri, to_h, options)
end
end

32 changes: 16 additions & 16 deletions spec/utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1307,23 +1307,23 @@

it "should use signature version 1 (without parameter encoding) for backward compatibility" do
public_id_with_ampersand = 'tests/logo&version=2'

expected_signature_v1 = Cloudinary::Utils.api_sign_request(
{ :public_id => public_id_with_ampersand, :version => test_version },
SIGNATURE_VERIFICATION_API_SECRET,
nil,
1
)

expected_signature_v2 = Cloudinary::Utils.api_sign_request(
{ :public_id => public_id_with_ampersand, :version => test_version },
SIGNATURE_VERIFICATION_API_SECRET,
nil,
2
)

expect(expected_signature_v1).not_to eq(expected_signature_v2)

# verify_api_response_signature should use version 1 for backward compatibility
expect(
Cloudinary::Utils.verify_api_response_signature(
Expand All @@ -1332,7 +1332,7 @@
expected_signature_v1
)
).to be true

expect(
Cloudinary::Utils.verify_api_response_signature(
public_id_with_ampersand,
Expand Down Expand Up @@ -1457,13 +1457,13 @@
expect(url_from_urls).to include("urls[]=#{url1}")
expect(url_from_urls).to include("urls[]=#{url2}")

parameters = CGI::parse(url_from_tag)
parameters = parse_query_params(URI(url_from_tag).query)
expect(parameters["tag"]).to eq([sprite_test_tag])
expect(parameters["mode"]).to eq([Cloudinary::Utils::MODE_DOWNLOAD])
expect(parameters["timestamp"]).not_to be_nil
expect(parameters["signature"]).not_to be_nil

parameters = CGI::parse(url_from_urls)
parameters = parse_query_params(URI(url_from_urls).query)
expect(parameters["mode"]).to eq([Cloudinary::Utils::MODE_DOWNLOAD])
expect(parameters["timestamp"]).not_to be_nil
expect(parameters["signature"]).not_to be_nil
Expand All @@ -1473,18 +1473,18 @@
let(:public_id) { 'tests/logo.png' }
let(:test_version) { 1234 }
let(:test_api_secret) { SIGNATURE_VERIFICATION_API_SECRET }

before do
Cloudinary.config.update(:api_secret => test_api_secret)
end

describe "api_sign_request signature_version parameter support" do
it "should support signature_version parameter in api_sign_request" do
params = { :public_id => public_id, :version => test_version }

signature_v1 = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, 1)
signature_v2 = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, 2)

expect(signature_v1).to be_a(String)
expect(signature_v2).to be_a(String)
expect(signature_v1).to eq(signature_v2) # No & in values, so should be the same
Expand All @@ -1493,20 +1493,20 @@
it "should use default signature_version from config" do
Cloudinary.config.signature_version = 2
params = { :public_id => public_id, :version => test_version }

signature_with_nil = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, nil)
signature_with_v2 = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, 2)

expect(signature_with_nil).to eq(signature_with_v2)
end

it "should default to version 2 when no config is set" do
Cloudinary.config.signature_version = nil
params = { :public_id => public_id, :version => test_version }

signature_with_nil = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, nil)
signature_with_v2 = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, 2)

expect(signature_with_nil).to eq(signature_with_v2)
end
end
Expand All @@ -1527,13 +1527,13 @@
expect(url_from_urls).to include("urls[]=#{url1}")
expect(url_from_urls).to include("urls[]=#{url2}")

parameters = CGI::parse(url_from_tag)
parameters = parse_query_params(URI(url_from_tag).query)
expect(parameters["tag"]).to eq([multi_test_tag])
expect(parameters["mode"]).to eq([Cloudinary::Utils::MODE_DOWNLOAD])
expect(parameters["timestamp"]).not_to be_nil
expect(parameters["signature"]).not_to be_nil

parameters = CGI::parse(url_from_urls)
parameters = parse_query_params(URI(url_from_urls).query)
expect(parameters["mode"]).to eq([Cloudinary::Utils::MODE_DOWNLOAD])
expect(parameters["timestamp"]).not_to be_nil
expect(parameters["signature"]).not_to be_nil
Expand Down