@@ -64,6 +64,16 @@ def test_explicit_authToken_should_override_global_setting(self):
6464 "w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac"
6565 "=55cfe516530461213fe3b3606014533b1eca8ff60aeab79d1bb84c9322eebc1f" )
6666
67+ def test_should_set_url_signature (self ):
68+ cloudinary .config (private_cdn = True )
69+ url , _ = cloudinary .utils .cloudinary_url ("sample.jpg" , sign_url = True ,
70+ auth_token = {"key" : ALT_KEY , "start_time" : 222222222 , "duration" : 100 ,
71+ "set_url_signature" : True },
72+ type = "authenticated" , transformation = {"crop" : "scale" , "width" : 300 })
73+ self .assertEqual ("http://test123-res.cloudinary.com/image/authenticated/s--Ok4O32K7--/"
74+ "c_scale,w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac"
75+ "=92a55aaed531b2dab074074bbd1430120119f9cb1b901656925dda2e514a63cc" , url )
76+
6777 def test_should_compute_expiration_as_start_time_plus_duration (self ):
6878 cloudinary .config (private_cdn = True )
6979 token = {"key" : KEY , "start_time" : 11111111 , "duration" : 300 }
@@ -75,8 +85,7 @@ def test_should_compute_expiration_as_start_time_plus_duration(self):
7585
7686 def test_generate_token_string (self ):
7787 user = "foobar" # we can't rely on the default "now" value in tests
78- token_options = {"key" : KEY , "duration" : 300 , "acl" : "/*/t_%s" % user }
79- token_options ["start_time" ] = 222222222 # we can't rely on the default "now" value in tests
88+ token_options = {"key" : KEY , "duration" : 300 , "acl" : "/*/t_%s" % user , "start_time" : 222222222 }
8089 cookie_token = cloudinary .utils .generate_auth_token (** token_options )
8190 self .assertEqual (
8291 cookie_token ,
@@ -97,8 +106,8 @@ def test_should_ignore_url_if_acl_is_provided(self):
97106 )
98107
99108 def test_should_support_multiple_acls (self ):
100- token_options = {"key" : KEY , "duration" : 3600 ,
101- "acl" : ["/i/a/*" , "/i/a/*" , "/i/a/*" ],
109+ token_options = {"key" : KEY , "duration" : 3600 ,
110+ "acl" : ["/i/a/*" , "/i/a/*" , "/i/a/*" ],
102111 "start_time" : 222222222 }
103112
104113 cookie_token = cloudinary .utils .generate_auth_token (** token_options )
@@ -128,6 +137,5 @@ def test_should_support_url_without_acl(self):
128137 )
129138
130139
131-
132140if __name__ == '__main__' :
133141 unittest .main ()
0 commit comments