|
10 | 10 | @url_backup = ENV["CLOUDINARY_URL"] |
11 | 11 | end |
12 | 12 | before do |
13 | | - Cloudinary.config_from_url "cloudinary://a:b@test123?load_strategies=false" |
| 13 | + Cloudinary.config_from_url "cloudinary://a:b@test123" |
14 | 14 | Cloudinary.config.auth_token = { :key => KEY, :duration => 300, :start_time => 11111111 } |
15 | 15 | end |
16 | 16 | after do |
|
19 | 19 | end |
20 | 20 | it "should generate with start and duration" do |
21 | 21 | token = Cloudinary::Utils.generate_auth_token :start_time => 1111111111, :acl => "/image/*", :duration => 300 |
22 | | - expect(token).to eq '__cld_token__=st=1111111111~exp=1111111411~acl=/image/*~hmac=0854e8b6b6a46471a80b2dc28c69bd352d977a67d031755cc6f3486c121b43af' |
| 22 | + expect(token).to eq '__cld_token__=st=1111111111~exp=1111111411~acl=%2fimage%2f%2a~hmac=0d5b0c9c1485ee162c459879fe62e06caa23bc26fec92d58bd100f2e1592eac6' |
23 | 23 | end |
24 | 24 |
|
25 | 25 | describe "authenticated url" do |
|
58 | 58 | expect(url).to eq("http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3") |
59 | 59 |
|
60 | 60 | end |
| 61 | + it "should throw if expiration and duration are not provided" do |
| 62 | + token = { :key => KEY, :expiration => 0, :duration => 0 } |
| 63 | + expect{Cloudinary::Utils.generate_auth_token(token)}.to raise_exception |
| 64 | + end |
61 | 65 | end |
62 | 66 | describe "authentication token" do |
63 | 67 | it "should generate token string" do |
64 | 68 | user = "foobar" # we can't rely on the default "now" value in tests |
65 | 69 | tokenOptions = { :key => KEY, :duration => 300, :acl => "/*/t_#{user}" } |
66 | 70 | tokenOptions[:start_time] = 222222222 # we can't rely on the default "now" value in tests |
67 | 71 | cookieToken = Cloudinary::Utils.generate_auth_token tokenOptions |
68 | | - expect(cookieToken).to eq("__cld_token__=st=222222222~exp=222222522~acl=/*/t_foobar~hmac=eb5e2266c8ec9573f696025f075b92998080347e1c12ac39a26c94d7d712704a") |
| 72 | + expect(cookieToken).to eq("__cld_token__=st=222222222~exp=222222522~acl=%2f%2a%2ft_foobar~hmac=1284376353c1c43d6f6a98f2813c5596f4ff6f34d837cd853fd8c3c9e7f8428c") |
69 | 73 |
|
70 | 74 | end |
71 | 75 | end |
|
0 commit comments