mirror of
https://github.com/wahyd4/ruby-sdk.git
synced 2026-08-09 12:56:21 +10:00
+2
-2
@@ -5,5 +5,5 @@ rvm:
|
||||
- 2.1.1
|
||||
- jruby-19mode
|
||||
before_script:
|
||||
- export QINIU_ACCESS_KEY=LGRqJsjX7LAvtdtX6hhyxs861lS57HwnOQmJsOuX
|
||||
- export QINIU_SECRET_KEY=g_OxhuN5iJ1O7BoA6YdXyF6zSszk34UZFKDfdIIW
|
||||
- export QINIU_ACCESS_KEY=QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm
|
||||
- export QINIU_SECRET_KEY=Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz
|
||||
|
||||
+2
-23
@@ -14,22 +14,6 @@ module Qiniu
|
||||
return HTTP.management_post(url)
|
||||
end # buckets
|
||||
|
||||
PRIVATE_BUCKET = 0
|
||||
PUBLIC_BUCKET = 1
|
||||
|
||||
def mkbucket(bucket_name, is_public = PUBLIC_BUCKET)
|
||||
url = Config.settings[:rs_host] + '/mkbucket2/' + bucket_name + '/public/' + is_public.to_s
|
||||
return HTTP.management_post(url)
|
||||
end # mkbucket
|
||||
|
||||
def make_a_private_bucket(bucket_name)
|
||||
return mkbucket(bucket_name, PRIVATE_BUCKET)
|
||||
end # make_a_private_bucket
|
||||
|
||||
def make_a_public_bucket(bucket_name)
|
||||
return mkbucket(bucket_name, PUBLIC_BUCKET)
|
||||
end # make_a_public_bucket
|
||||
|
||||
def stat(bucket, key)
|
||||
url = Config.settings[:rs_host] + '/stat/' + encode_entry_uri(bucket, key)
|
||||
return HTTP.management_post(url)
|
||||
@@ -60,11 +44,6 @@ module Qiniu
|
||||
return HTTP.management_post(url)
|
||||
end # delete
|
||||
|
||||
def drop(bucket)
|
||||
url = Config.settings[:rs_host] + "/drop/#{bucket}"
|
||||
return HTTP.management_post(url)
|
||||
end # drop
|
||||
|
||||
def batch(command, bucket, keys)
|
||||
execs = []
|
||||
keys.each do |key|
|
||||
@@ -117,9 +96,9 @@ module Qiniu
|
||||
|
||||
def _batch_cp_or_mv(command, *op_args)
|
||||
execs = []
|
||||
op_args.each do |e|
|
||||
op_args.each do |e|
|
||||
execs << 'op=' + _generate_cp_or_mv_opstr(command, e[0], e[1], e[2], e[3]) if e.size == 4
|
||||
end
|
||||
end
|
||||
url = Config.settings[:rs_host] + "/batch"
|
||||
return HTTP.management_post(url, execs.join("&"))
|
||||
end # _batch_cp_or_mv
|
||||
|
||||
@@ -7,20 +7,13 @@ require 'qiniu/storage'
|
||||
require 'digest/sha1'
|
||||
|
||||
module Qiniu
|
||||
module Auth
|
||||
module Auth
|
||||
describe Auth do
|
||||
|
||||
before :all do
|
||||
@bucket = 'RubySDK-Test-Private'
|
||||
@bucket = make_unique_bucket(@bucket)
|
||||
|
||||
### 尝试创建Bucket
|
||||
result = Qiniu::Storage.make_a_private_bucket(@bucket)
|
||||
puts result.inspect
|
||||
@bucket = 'rubysdk'
|
||||
end
|
||||
|
||||
after :all do
|
||||
### 不删除Bucket以备下次使用
|
||||
end
|
||||
|
||||
### 测试私有资源下载
|
||||
|
||||
@@ -10,15 +10,7 @@ module Qiniu
|
||||
describe Fop do
|
||||
|
||||
before :all do
|
||||
|
||||
### 复用RubySDK-Test-Storage空间
|
||||
@bucket = 'RubySDK-Test-Storage'
|
||||
@bucket = make_unique_bucket(@bucket)
|
||||
|
||||
### 尝试创建空间
|
||||
result = Qiniu.mkbucket(@bucket)
|
||||
puts result.inspect
|
||||
|
||||
@bucket = 'rubysdk'
|
||||
pic_fname = "image_logo_for_test.png"
|
||||
@key = make_unique_key_in_bucket(pic_fname)
|
||||
|
||||
@@ -57,7 +49,6 @@ module Qiniu
|
||||
end
|
||||
|
||||
after :all do
|
||||
### 不删除Bucket以备下次使用
|
||||
end
|
||||
|
||||
context ".info" do
|
||||
|
||||
@@ -12,12 +12,7 @@ module Qiniu
|
||||
describe Storage do
|
||||
|
||||
before :all do
|
||||
@bucket = 'RubySDK-Test-Management'
|
||||
@bucket = make_unique_bucket(@bucket)
|
||||
|
||||
### 尝试创建Bucket
|
||||
result = Qiniu.mkbucket(@bucket)
|
||||
puts result.inspect
|
||||
@bucket = 'rubysdk'
|
||||
|
||||
@key = Digest::SHA1.hexdigest((Time.now.to_i+rand(100)).to_s)
|
||||
@key = make_unique_key_in_bucket(@key)
|
||||
@@ -26,7 +21,6 @@ module Qiniu
|
||||
end
|
||||
|
||||
after :all do
|
||||
### 不删除Bucket以备下次使用
|
||||
end
|
||||
|
||||
### 准备数据
|
||||
|
||||
@@ -10,16 +10,10 @@ module Qiniu
|
||||
describe Misc do
|
||||
|
||||
before :all do
|
||||
### 复用RubySDK-Test-Management空间
|
||||
@bucket = 'RubySDK-Test-Management'
|
||||
@bucket = make_unique_bucket(@bucket)
|
||||
|
||||
result = Qiniu.mkbucket(@bucket)
|
||||
puts result.inspect
|
||||
@bucket = 'rubysdk'
|
||||
end
|
||||
|
||||
after :all do
|
||||
### 不删除Bucket以备下次使用
|
||||
end
|
||||
|
||||
context ".set_protected" do
|
||||
|
||||
+1
-10
@@ -12,15 +12,7 @@ module Qiniu
|
||||
describe Persistance do
|
||||
|
||||
before :all do
|
||||
### 复用RubySDK-Test-Storage空间
|
||||
@bucket = 'RubySDK-Test-Storage'
|
||||
@bucket = make_unique_bucket(@bucket)
|
||||
|
||||
### 尝试创建空间
|
||||
code, data, headers = Qiniu::Storage.make_a_public_bucket(@bucket)
|
||||
puts code.inspect
|
||||
puts data.inspect
|
||||
puts headers.inspect
|
||||
@bucket = 'rubysdk'
|
||||
|
||||
pic_fname = "image_logo_for_test.png"
|
||||
@key = make_unique_key_in_bucket(pic_fname)
|
||||
@@ -44,7 +36,6 @@ module Qiniu
|
||||
end
|
||||
|
||||
after :all do
|
||||
### 不删除Bucket以备下次使用
|
||||
end
|
||||
|
||||
context ".pfop" do
|
||||
|
||||
@@ -9,15 +9,10 @@ module Qiniu
|
||||
describe Qiniu do
|
||||
|
||||
before :all do
|
||||
@bucket = 'RubySDK-Test'
|
||||
@bucket = make_unique_bucket(@bucket)
|
||||
@bucket = 'rubysdk'
|
||||
|
||||
@test_image_bucket = @bucket
|
||||
|
||||
### 尝试创建Bucket
|
||||
result = Qiniu.mkbucket(@bucket)
|
||||
puts result.inspect
|
||||
|
||||
@key = Digest::SHA1.hexdigest Time.now.to_s
|
||||
@key = make_unique_key_in_bucket(@key)
|
||||
|
||||
@@ -34,7 +29,6 @@ module Qiniu
|
||||
end
|
||||
|
||||
after :all do
|
||||
### 不删除Bucket以备下次使用
|
||||
end
|
||||
|
||||
context ".buckets" do
|
||||
|
||||
@@ -11,12 +11,7 @@ module Qiniu
|
||||
describe Storage do
|
||||
|
||||
before :all do
|
||||
@bucket = 'RubySDK-Test-Storage'
|
||||
@bucket = make_unique_bucket(@bucket)
|
||||
|
||||
### 尝试创建Bucket
|
||||
result = Qiniu.mkbucket(@bucket)
|
||||
puts result.inspect
|
||||
@bucket = 'rubysdk'
|
||||
|
||||
@key = Digest::SHA1.hexdigest((Time.now.to_i+rand(100)).to_s)
|
||||
@key = make_unique_key_in_bucket(@key)
|
||||
@@ -53,8 +48,6 @@ module Qiniu
|
||||
File.unlink(@localfile_4m) if File.exists?(@localfile_4m)
|
||||
File.unlink(@localfile_8m) if File.exists?(@localfile_8m)
|
||||
File.unlink(@localfile_1m) if File.exists?(@localfile_1m)
|
||||
|
||||
### 不删除Bucket以备下次使用
|
||||
end
|
||||
|
||||
### 测试单文件直传
|
||||
|
||||
@@ -26,8 +26,8 @@ module Qiniu
|
||||
context ".send_request_with" do
|
||||
it "should works" do
|
||||
FakeWeb.allow_net_connect = false
|
||||
FakeWeb.register_uri(:get, "http://docs.qiniutek.com/", :body => {:abc => 123}.to_json)
|
||||
res = Utils.send_request_with 'http://docs.qiniutek.com/', nil, :method => :get
|
||||
FakeWeb.register_uri(:get, "http://develoepr.qiniu.com/", :body => {:abc => 123}.to_json)
|
||||
res = Utils.send_request_with 'http://develoepr.qiniu.com/', nil, :method => :get
|
||||
res.should == [200, {"abc" => 123}, {}]
|
||||
end
|
||||
|
||||
@@ -35,9 +35,9 @@ module Qiniu
|
||||
context "upstream return http #{code}" do
|
||||
it "should raise RestClient::RequestFailed" do
|
||||
FakeWeb.allow_net_connect = false
|
||||
FakeWeb.register_uri(:get, "http://docs.qiniutek.com/", :status => code)
|
||||
FakeWeb.register_uri(:get, "http://develoepr.qiniu.com/", :status => code)
|
||||
lambda {
|
||||
res = Utils.send_request_with 'http://docs.qiniutek.com/', nil, :method => :get
|
||||
res = Utils.send_request_with 'http://develoepr.qiniu.com/', nil, :method => :get
|
||||
}.should raise_error RestClient::RequestFailed
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user