删除过时的测试案例,并为新改动逻辑添加新案例。

This commit is contained in:
Liang Tao
2014-01-28 16:04:55 +08:00
parent b0335577e5
commit 3302ecde6a
7 changed files with 105 additions and 60 deletions
+2 -2
View File
@@ -20,9 +20,9 @@ module Qiniu
:method => :post,
:content_type => 'application/x-www-form-urlencoded',
:auth_url => "https://acc.qbox.me/oauth2/token",
:rs_host => "http://rs.qbox.me",
:rs_host => "http://rs.qiniu.com",
:io_host => "http://iovip.qbox.me",
:up_host => "http://up.qbox.me",
:up_host => "http://up.qiniu.com",
:pub_host => "http://pu.qbox.me:10200",
:eu_host => "http://eu.qbox.me",
:client_id => "a75604760c4da4caaa456c0c5895c061c3065c5a",
+2
View File
@@ -103,6 +103,7 @@ module Qiniu
%Q(/#{command}/#{source_encoded_entry_uri}/#{target_encoded_entry_uri})
end
=begin
def _batch_cp_or_mv(command, *op_args)
execs = []
op_args.each do |e|
@@ -110,6 +111,7 @@ module Qiniu
end
Auth.request Config.settings[:rs_host] + "/batch?" + execs.join("&")
end
=end
end
end
-58
View File
@@ -1,58 +0,0 @@
# -*- encoding: utf-8 -*-
require 'spec_helper'
require 'qiniu/rs/auth'
module Qiniu
module RS
describe Auth do
before :all do
@username = "qboxtest"
@password = "qboxtest123"
code, data = Qiniu::RS::Auth.exchange_by_password!(@username, @password)
code.should == 200
data.should be_an_instance_of(Hash)
data["access_token"].should_not be_empty
data["refresh_token"].should_not be_empty
data["refresh_token"].should_not be_empty
@access_token = data["access_token"]
@refresh_token = data["refresh_token"]
puts data.inspect
end
context ".exchange_by_password" do
it "should sign in failed when pass a non-existent username" do
code, data = Qiniu::RS::Auth.exchange_by_password!("a_non_existent_user@example.com", "password")
code.should == 401
data["error_code"].should == 11
data["error"].should == "failed_authentication"
puts data.inspect
end
it "should sign in failed when pass a wrong password" do
code, data = Qiniu::RS::Auth.exchange_by_password!(@username, "a-wrong-password")
code.should == 401
data["error_code"].should == 11
data["error"].should == "failed_authentication"
puts data.inspect
end
end
context ".exchange_by_refresh_token" do
it "should works" do
@refresh_token.should_not be_empty
code, data = Qiniu::RS::Auth.exchange_by_refresh_token!(@refresh_token)
code.should == 200
data["access_token"].should_not be_empty
data["refresh_token"].should_not be_empty
data["expires_in"].should_not be_zero
puts data.inspect
end
end
end
end
end
+2
View File
@@ -66,12 +66,14 @@ module Qiniu
end
end
=begin
context ".exif" do
it "should works" do
code, data = Qiniu::RS::Image.exif(@source_image_url)
puts data.inspect
end
end
=end
context ".mogrify_preview_url" do
it "should works" do
+2
View File
@@ -90,6 +90,7 @@ module Qiniu
end
end
=begin
context ".batch_copy" do
it "should works" do
code, data = Qiniu::RS::RS.batch_copy [@bucket, @key, @bucket, @key2]
@@ -117,6 +118,7 @@ module Qiniu
puts data3.inspect
end
end
=end
=begin
context ".publish" do
+93
View File
@@ -15,6 +15,18 @@ module Qiniu
@bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s
@key = Digest::SHA1.hexdigest(@localfile+Time.now.to_s)
@localfile2 = "bigfile2.txt"
File.open(@localfile2, "w"){|f| (1 << 22).times{f.write(rand(9).to_s)}}
@key2 = Digest::SHA1.hexdigest(@localfile2+Time.now.to_s)
@localfile3 = "bigfile3.txt"
File.open(@localfile3, "w"){|f| (1 << 23).times{f.write(rand(9).to_s)}}
@key3 = Digest::SHA1.hexdigest(@localfile3+Time.now.to_s)
@localfile4 = "smallfile.txt"
File.open(@localfile4, "w"){|f| (1 << 20).times{f.write(rand(9).to_s)}}
@key4 = Digest::SHA1.hexdigest(@localfile4+Time.now.to_s)
code, data = Qiniu::RS::RS.mkbucket(@bucket)
puts [code, data].inspect
code.should == 200
@@ -22,6 +34,9 @@ module Qiniu
after :all do
File.unlink(@localfile) if File.exists?(@localfile)
File.unlink(@localfile2) if File.exists?(@localfile2)
File.unlink(@localfile3) if File.exists?(@localfile3)
File.unlink(@localfile4) if File.exists?(@localfile4)
code, data = Qiniu::RS::RS.drop(@bucket)
puts [code, data].inspect
@@ -54,6 +69,84 @@ module Qiniu
end
end
context ".upload_with_token2" do
it "should works" do
upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
uptoken = Qiniu::RS.generate_upload_token(upopts)
code, data = Qiniu::RS::UP.upload_with_token(uptoken, @localfile2, @bucket, @key2)
puts data.inspect
(code/100).should == 2
end
end
context ".stat" do
it "should exists" do
code, data = Qiniu::RS::RS.stat(@bucket, @key2)
puts data.inspect
code.should == 200
end
end
context ".delete" do
it "should works" do
code, data = Qiniu::RS::RS.delete(@bucket, @key2)
puts data.inspect
code.should == 200
end
end
context ".upload_with_token3" do
it "should works" do
upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
uptoken = Qiniu::RS.generate_upload_token(upopts)
code, data = Qiniu::RS::UP.upload_with_token(uptoken, @localfile3, @bucket, @key3)
puts data.inspect
(code/100).should == 2
end
end
context ".stat" do
it "should exists" do
code, data = Qiniu::RS::RS.stat(@bucket, @key3)
puts data.inspect
code.should == 200
end
end
context ".delete" do
it "should works" do
code, data = Qiniu::RS::RS.delete(@bucket, @key3)
puts data.inspect
code.should == 200
end
end
context ".upload_with_token4" do
it "should works" do
upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
uptoken = Qiniu::RS.generate_upload_token(upopts)
code, data = Qiniu::RS::UP.upload_with_token(uptoken, @localfile4, @bucket, @key4)
puts data.inspect
(code/100).should == 2
end
end
context ".stat" do
it "should exists" do
code, data = Qiniu::RS::RS.stat(@bucket, @key4)
puts data.inspect
code.should == 200
end
end
context ".delete" do
it "should works" do
code, data = Qiniu::RS::RS.delete(@bucket, @key4)
puts data.inspect
code.should == 200
end
end
end
end
end
+4
View File
@@ -296,6 +296,7 @@ module Qiniu
end
=end
=begin
context ".batch_copy" do
it "should works" do
result = Qiniu::RS.batch_copy [@bucket, @key, @bucket, @key2]
@@ -318,6 +319,7 @@ module Qiniu
result3.should_not be_false
end
end
=end
context ".move" do
it "should works" do
@@ -369,6 +371,7 @@ module Qiniu
end
end
=begin
context ".image_exif" do
it "should works" do
data = Qiniu::RS.get(@test_image_bucket, @test_image_key)
@@ -379,6 +382,7 @@ module Qiniu
puts result.inspect
end
end
=end
context ".image_mogrify_save_as" do
it "should works" do