@@ -5,10 +5,12 @@ utils = cloudinary.utils
55KEY = " 00112233FF99"
66ALT_KEY = " CCBB2233FF00"
77describe " authToken" , ->
8- urlBackup = process .env .CLOUDINARY_URL
8+ urlBackup = null
9+ before ->
10+ urlBackup = process .env .CLOUDINARY_URL
911
1012 beforeEach ->
11- process .env .CLOUDINARY_URL = " cloudinary://a:b@test123?load_strategies=false "
13+ process .env .CLOUDINARY_URL = " cloudinary://a:b@test123"
1214 cloudinary .config true
1315 cloudinary .config ().auth_token = {key : KEY, duration : 300 , start_time : 11111111 }
1416 after ->
@@ -27,24 +29,24 @@ describe "authToken", ->
2729 url = cloudinary .url " sample.jpg" , sign_url : true , resource_type : " image" , type : " authenticated" , version : " 1486020273"
2830 expect (url).to .eql (" http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3" )
2931
30- it " should add token for 'public' resource" , ->
32+ it " should add token for 'public' resource" , ->
3133 url = cloudinary .url " sample.jpg" , sign_url : true , resource_type : " image" , type : " public" , version : " 1486020273"
3234 expect (url).to .eql (" http://test123-res.cloudinary.com/image/public/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=c2b77d9f81be6d89b5d0ebc67b671557e88a40bcf03dd4a6997ff4b994ceb80e" )
3335
34- it " should not add token if signed is false" , ->
36+ it " should not add token if signed is false" , ->
3537 url = cloudinary .url " sample.jpg" , type : " authenticated" , version : " 1486020273"
3638 expect (url).to .eql (" http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg" )
3739
38- it " should not add token if authToken is globally set but null auth token is explicitly set and signed = true" , ->
40+ it " should not add token if authToken is globally set but null auth token is explicitly set and signed = true" , ->
3941 url = cloudinary .url " sample.jpg" , auth_token : false , sign_url : true , type : " authenticated" , version : " 1486020273"
4042 expect (url).to .eql (" http://test123-res.cloudinary.com/image/authenticated/s--v2fTPYTu--/v1486020273/sample.jpg" )
4143
42- it " explicit authToken should override global setting" , ->
44+ it " explicit authToken should override global setting" , ->
4345 url = cloudinary .url " sample.jpg" , sign_url : true , auth_token : {key : ALT_KEY, start_time : 222222222 , duration : 100 }, type : " authenticated" , transformation : {crop : " scale" , width : 300 }
4446 expect (url).to .eql (" http://test123-res.cloudinary.com/image/authenticated/c_scale,w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac=7d276841d70c4ecbd0708275cd6a82e1f08e47838fbb0bceb2538e06ddfa3029" )
4547
46- it " should compute expiration as start time + duration" , ->
47- token = {key : KEY, start_time : 11111111 , duration : 300 }
48+ it " should compute expiration as start time + duration" , ->
49+ token = {start_time : 11111111 , duration : 300 }
4850 url = cloudinary .url " sample.jpg" , sign_url : true , auth_token : token, resource_type : " image" , type : " authenticated" , version : " 1486020273"
4951 expect (url).to .eql (" http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3" )
5052
0 commit comments