diff --git a/spec/qiniu/auth_spec.rb b/spec/qiniu/auth_spec.rb index 6405702..62cb503 100755 --- a/spec/qiniu/auth_spec.rb +++ b/spec/qiniu/auth_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' require 'qiniu/auth' +require 'qiniu/config' require 'qiniu/storage' require 'digest/sha1' @@ -72,19 +73,21 @@ module Qiniu ### 测试回调签名 context ".authenticate_callback_request" do - url = '/test.php' - body = 'name=xxx&size=1234' - false.should == Qiniu::Auth.authenticate_callback_request('ABCD', url, body) - false.should == Qiniu::Auth.authenticate_callback_request(Config.settings[:access_key], url, body) - false.should == Qiniu::Auth.authenticate_callback_request('QBox ' + Config.settings[:access_key] + ':', url, body) - false.should == Qiniu::Auth.authenticate_callback_request('QBox ' + Config.settings[:access_key] + ':????', url, body) + it "should works" do + url = '/test.php' + body = 'name=xxx&size=1234' + false.should == Qiniu::Auth.authenticate_callback_request('ABCD', url, body) + false.should == Qiniu::Auth.authenticate_callback_request(Config.settings[:access_key], url, body) + false.should == Qiniu::Auth.authenticate_callback_request('QBox ' + Config.settings[:access_key] + ':', url, body) + false.should == Qiniu::Auth.authenticate_callback_request('QBox ' + Config.settings[:access_key] + ':????', url, body) - acctoken = Qiniu::Auth.generate_acctoken(url, body) - auth_str = 'QBox ' + acctoken + acctoken = Qiniu::Auth.generate_acctoken(url, body) + auth_str = 'QBox ' + acctoken - false.should == Qiniu::Auth.authenticate_callback_request(auth_str + ' ', url, body) - true.should == Qiniu::Auth.authenticate_callback_request(auth_str, url, body) - true.should == Qiniu::Auth.authenticate_callback_request(acctoken, url, body) + false.should == Qiniu::Auth.authenticate_callback_request(auth_str + ' ', url, body) + true.should == Qiniu::Auth.authenticate_callback_request(auth_str, url, body) + true.should == Qiniu::Auth.authenticate_callback_request(acctoken, url, body) + end end end # module Auth