File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,20 +12,20 @@ module AuthToken
1212
1313 def self . generate ( options = { } )
1414 key = options [ :key ]
15- throw "Missing auth token key configuration" unless key
16- name = options [ :token_name ] || "__cld_token__"
17- start = options [ :start_time ]
18- expiration = options [ :expiration ]
19- ip = options [ :ip ]
20- acl = options [ :acl ]
21- duration = options [ :duration ]
22- url = options [ :url ]
15+ raise "Missing auth token key configuration" unless key
16+ name = options [ :token_name ] || "__cld_token__"
17+ start = options [ :start_time ]
18+ expiration = options [ :expiration ]
19+ ip = options [ :ip ]
20+ acl = options [ :acl ]
21+ duration = options [ :duration ]
22+ url = options [ :url ]
2323 start = Time . new . getgm . to_i if start == 'now'
2424 if expiration . nil? || expiration == 0
2525 if !( duration . nil? || duration == 0 )
2626 expiration = ( start || Time . new . getgm . to_i ) + duration
2727 else
28- throw 'Must provide either expiration or duration'
28+ raise 'Must provide either expiration or duration'
2929 end
3030 end
3131
Original file line number Diff line number Diff line change 5858 expect ( url ) . to eq ( "http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3" )
5959
6060 end
61- it "should throw if expiration and duration are not provided" do
61+ it "should raise if key is not provided" do
62+ Cloudinary . config . auth_token [ :key ] = nil
63+ token = { :expiration => 111111 , :duration => 0 }
64+ expect { Cloudinary ::Utils . generate_auth_token ( token ) } . to raise_error
65+ end
66+ it "should raise if expiration and duration are not provided" do
6267 token = { :key => KEY , :expiration => 0 , :duration => 0 }
63- expect { Cloudinary ::Utils . generate_auth_token ( token ) } . to raise_exception
68+ expect { Cloudinary ::Utils . generate_auth_token ( token ) } . to raise_error
6469 end
6570 end
6671 describe "authentication token" do
You can’t perform that action at this time.
0 commit comments