mirror of
https://github.com/wahyd4/ruby-sdk.git
synced 2026-08-09 04:46:10 +10:00
调整测试代码。
This commit is contained in:
+14
-11
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user