spec/auth_token_spec.rb in cloudinary-1.9.1 vs spec/auth_token_spec.rb in cloudinary-1.10.0
- old
+ new
@@ -1,28 +1,26 @@
require 'rspec'
require 'spec_helper'
require 'cloudinary'
describe 'auth_token' do
- before :all do
- @url_backup = ENV["CLOUDINARY_URL"]
- end
- before do
- Cloudinary.config_from_url "cloudinary://a:b@test123"
+
+ before :each do
+ Cloudinary.reset_config
+ Cloudinary.config_from_url 'cloudinary://a:b@test123'
Cloudinary.config.auth_token = { :key => KEY, :duration => 300, :start_time => 11111111 }
end
- after do
- ENV["CLOUDINARY_URL"] = @url_backup
- Cloudinary::config_from_url @url_backup
- end
it "should generate with start and duration" do
token = Cloudinary::Utils.generate_auth_token :start_time => 1111111111, :acl => "/image/*", :duration => 300
expect(token).to eq '__cld_token__=st=1111111111~exp=1111111411~acl=%2fimage%2f*~hmac=1751370bcc6cfe9e03f30dd1a9722ba0f2cdca283fa3e6df3342a00a7528cc51'
end
describe "authenticated url" do
- before do
+ before :each do
+ Cloudinary.class_variable_set :@@config, nil
+ Cloudinary.config_from_url 'cloudinary://a:b@test123'
Cloudinary.config :private_cdn => true
+ Cloudinary.config.auth_token = { :key => KEY, :duration => 300, :start_time => 11111111 }
end
it "should add token if authToken is globally set and signed = true" do
url = Cloudinary::Utils.cloudinary_url "sample.jpg", :sign_url => true, :resource_type => "image", :type => "authenticated", :version => "1486020273"
expect(url).to eq("http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3")