qiniu-rs 3.4.6 → 3.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +8 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -3
- data/lib/qiniu/rs.rb +2 -2
- data/lib/qiniu/rs/auth.rb +1 -66
- data/lib/qiniu/rs/config.rb +2 -2
- data/lib/qiniu/rs/rs.rb +2 -2
- data/lib/qiniu/rs/utils.rb +4 -1
- data/lib/qiniu/rs/version.rb +1 -1
- data/qiniu-rs.gemspec +2 -2
- data/spec/qiniu/rs/rs_spec.rb +8 -3
- data/spec/qiniu/rs_spec.rb +6 -3
- metadata +13 -37
- data/spec/qiniu/rs/auth_spec.rb +0 -58
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ddf083b2df630fdf57286a4c9395f2cb029ee0d4
|
4
|
+
data.tar.gz: 4a7c0cf9a120bd8c7da77387347915e49c25d5b9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cec69bf917c779f6694bb03e9ad0b8a5a61fe1c5ecffcd696a229535f3f694421d8506aa670ca3a517e0cfaa19a18ddce0f00c251c723954559dc9023b81992a
|
7
|
+
data.tar.gz: 358319b26b7e9cdc619c2c38dc08465966abf721ad44bdb6cffaf02fd3b747d506c97f6399b4e9345a013b33db08dd91ca64201d23514041aca1e7da25e5ea04
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## CHANGE LOG
|
2
2
|
|
3
|
+
### v3.4.7
|
4
|
+
|
5
|
+
- 停止追加新功能,仅进行Bug修正维护。
|
6
|
+
|
3
7
|
### v3.4.6
|
4
8
|
|
5
9
|
- `Qiniu::RS.generate_download_token()` 方法的 `:pattern` 调整为必选项。
|
@@ -7,13 +11,13 @@
|
|
7
11
|
### v3.4.5
|
8
12
|
|
9
13
|
- `Qiniu::RS.generate_upload_token()` 方法新增 `:callback_body` 和 `return_url` 选项。
|
10
|
-
- 选项含义参考: <http://
|
14
|
+
- 选项含义参考: <http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-callback-body>
|
11
15
|
|
12
16
|
### v3.4.2
|
13
17
|
|
14
18
|
- `Qiniu::RS.generate_upload_token()` 方法新增 `:return_body` 选项。
|
15
19
|
|
16
|
-
该选项(`:return_body`)可设置文件上传成功后,执行七牛云存储规定的回调API,并以 JSON 响应格式返回其执行结果。参考 [uploadToken 之 returnBody 说明](http://
|
20
|
+
该选项(`:return_body`)可设置文件上传成功后,执行七牛云存储规定的回调API,并以 JSON 响应格式返回其执行结果。参考 [uploadToken 之 returnBody 说明](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-return-body)。
|
17
21
|
|
18
22
|
### v3.4.1
|
19
23
|
|
@@ -44,9 +48,9 @@ Ruby 宿主环境如下
|
|
44
48
|
|
45
49
|
### v3.3.0
|
46
50
|
|
47
|
-
私有资源下载新版实现,添加 Qiniu::RS.generate_download_token() 方法。参考 [downloadToken](http://
|
51
|
+
私有资源下载新版实现,添加 Qiniu::RS.generate_download_token() 方法。参考 [downloadToken](http://developer.qiniu.com/docs/v6/api/reference/security/download-token.html)
|
48
52
|
|
49
|
-
详见 [Ruby SDK 使用文档之私有资源下载](http://
|
53
|
+
详见 [Ruby SDK 使用文档之私有资源下载](http://developer.qiniu.com/docs/v6/api/overview/dn/security.html)
|
50
54
|
|
51
55
|
### v3.2.2
|
52
56
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
-
# Qiniu Resource (Cloud) Storage SDK for Ruby
|
1
|
+
# Qiniu Resource (Cloud) Storage SDK for Ruby
|
2
|
+
|
3
|
+
# 版本说明
|
4
|
+
|
5
|
+
此版本不再进行技术升级,仅做Bug修正维护。
|
6
|
+
请移步 [https://github.com/qiniu/ruby-sdk](https://github.com/qiniu/ruby-sdk) 查看最新版本。
|
2
7
|
|
3
8
|
# 关于
|
4
9
|
|
5
|
-
此 Ruby SDK 适用于 Ruby 1.8.x, 1.9.x, jruby, rbx, ree 版本,基于 [七牛云存储官方API](http://
|
10
|
+
此 Ruby SDK 适用于 Ruby 1.8.x, 1.9.x, jruby, rbx, ree 版本,基于 [七牛云存储官方API](http://developer.qiniu.com/docs/v6/index.html) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
|
6
11
|
|
7
12
|
## 安装
|
8
13
|
|
@@ -20,7 +25,7 @@
|
|
20
25
|
|
21
26
|
## 使用
|
22
27
|
|
23
|
-
参考文档:[七牛云存储 Ruby SDK 使用指南](http://
|
28
|
+
参考文档:[七牛云存储 Ruby SDK 使用指南](http://developer.qiniu.com/docs/v6/sdk/ruby-sdk.html)
|
24
29
|
|
25
30
|
## 贡献代码
|
26
31
|
|
data/lib/qiniu/rs.rb
CHANGED
@@ -182,12 +182,12 @@ module Qiniu
|
|
182
182
|
end
|
183
183
|
|
184
184
|
def batch_copy(*args)
|
185
|
-
code, data = RS.batch_copy(args)
|
185
|
+
code, data = RS.batch_copy(*args)
|
186
186
|
code == StatusOK
|
187
187
|
end
|
188
188
|
|
189
189
|
def batch_move(*args)
|
190
|
-
code, data = RS.batch_move(args)
|
190
|
+
code, data = RS.batch_move(*args)
|
191
191
|
code == StatusOK
|
192
192
|
end
|
193
193
|
|
data/lib/qiniu/rs/auth.rb
CHANGED
@@ -8,78 +8,13 @@ module Qiniu
|
|
8
8
|
class << self
|
9
9
|
include Utils
|
10
10
|
|
11
|
-
def exchange_by_password!(username, password)
|
12
|
-
@username = username
|
13
|
-
@password = password
|
14
|
-
post_data = {
|
15
|
-
:client_id => Config.settings[:client_id],
|
16
|
-
:grant_type => "password",
|
17
|
-
:username => username,
|
18
|
-
:password => password
|
19
|
-
}
|
20
|
-
code, data = http_request Config.settings[:auth_url], post_data
|
21
|
-
reset_token(data["access_token"], data["refresh_token"]) if Utils.is_response_ok?(code)
|
22
|
-
[code, data]
|
23
|
-
end
|
24
|
-
|
25
|
-
def exchange_by_refresh_token!(refresh_token)
|
26
|
-
post_data = {
|
27
|
-
:client_id => Config.settings[:client_id],
|
28
|
-
:grant_type => "refresh_token",
|
29
|
-
:refresh_token => refresh_token
|
30
|
-
}
|
31
|
-
code, data = http_request Config.settings[:auth_url], post_data
|
32
|
-
reset_token(data["access_token"], data["refresh_token"]) if Utils.is_response_ok?(code)
|
33
|
-
[code, data]
|
34
|
-
end
|
35
|
-
|
36
|
-
def reset_token(access_token, refresh_token)
|
37
|
-
@access_token = access_token
|
38
|
-
@refresh_token = refresh_token
|
39
|
-
end
|
40
|
-
|
41
|
-
def call_with_logged_in(url, data, retry_times = 0)
|
42
|
-
raise MissingAccessToken if @access_token.nil?
|
43
|
-
code, data = http_request url, data, {:access_token => @access_token}
|
44
|
-
if code == 401
|
45
|
-
raise MissingRefreshToken if @refresh_token.nil?
|
46
|
-
code, data = exchange_by_refresh_token!(@refresh_token)
|
47
|
-
if code == 401
|
48
|
-
raise MissingUsernameOrPassword if (@username.nil? || @password.nil?)
|
49
|
-
code, data = exchange_by_password!(@username, @password)
|
50
|
-
end
|
51
|
-
if Utils.is_response_ok?(code)
|
52
|
-
retry_times += 1
|
53
|
-
if Config.settings[:auto_reconnect] && retry_times < Config.settings[:max_retry_times]
|
54
|
-
return call_with_logged_in(url, data, retry_times)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
[code, data]
|
59
|
-
end
|
60
|
-
|
61
11
|
def call_with_signature(url, data, retry_times = 0, options = {})
|
62
|
-
code, data = http_request url, data, options.merge({:qbox_signature_token => generate_qbox_signature(url, data)})
|
12
|
+
code, data = http_request url, data, options.merge({:qbox_signature_token => generate_qbox_signature(url, data, options[:mime])})
|
63
13
|
[code, data]
|
64
14
|
end
|
65
15
|
|
66
16
|
def request(url, data = nil, options = {})
|
67
|
-
begin
|
68
|
-
if Config.settings[:access_key].empty? || Config.settings[:secret_key].empty?
|
69
|
-
code, data = Auth.call_with_logged_in(url, data)
|
70
|
-
else
|
71
17
|
code, data = Auth.call_with_signature(url, data, 0, options)
|
72
|
-
end
|
73
|
-
rescue MissingAccessToken => e
|
74
|
-
Log.logger.error e
|
75
|
-
code, data = 401, {}
|
76
|
-
rescue MissingRefreshToken => e
|
77
|
-
Log.logger.error e
|
78
|
-
code, data = 401, {}
|
79
|
-
rescue MissingUsernameOrPassword => e
|
80
|
-
Log.logger.error e
|
81
|
-
code, data = 401, {}
|
82
|
-
end
|
83
18
|
[code, data]
|
84
19
|
end
|
85
20
|
|
data/lib/qiniu/rs/config.rb
CHANGED
@@ -20,9 +20,9 @@ module Qiniu
|
|
20
20
|
:method => :post,
|
21
21
|
:content_type => 'application/x-www-form-urlencoded',
|
22
22
|
:auth_url => "https://acc.qbox.me/oauth2/token",
|
23
|
-
:rs_host => "http://rs.
|
23
|
+
:rs_host => "http://rs.qiniu.com",
|
24
24
|
:io_host => "http://iovip.qbox.me",
|
25
|
-
:up_host => "http://up.
|
25
|
+
:up_host => "http://up.qiniu.com",
|
26
26
|
:pub_host => "http://pu.qbox.me:10200",
|
27
27
|
:eu_host => "http://eu.qbox.me",
|
28
28
|
:client_id => "a75604760c4da4caaa456c0c5895c061c3065c5a",
|
data/lib/qiniu/rs/rs.rb
CHANGED
@@ -60,7 +60,7 @@ module Qiniu
|
|
60
60
|
encoded_uri = encode_entry_uri(bucket, key)
|
61
61
|
execs << "op=/#{command}/#{encoded_uri}"
|
62
62
|
end
|
63
|
-
Auth.request Config.settings[:rs_host] + "/batch
|
63
|
+
Auth.request Config.settings[:rs_host] + "/batch", execs.join("&"), {:mime => "application/x-www-form-urlencoded" }
|
64
64
|
end
|
65
65
|
|
66
66
|
def batch_get(bucket, keys)
|
@@ -108,7 +108,7 @@ module Qiniu
|
|
108
108
|
op_args.each do |e|
|
109
109
|
execs << 'op=' + _generate_cp_or_mv_opstr(command, e[0], e[1], e[2], e[3]) if e.size == 4
|
110
110
|
end
|
111
|
-
Auth.request Config.settings[:rs_host] + "/batch
|
111
|
+
Auth.request Config.settings[:rs_host] + "/batch", execs.join("&"), {:mime => "application/x-www-form-urlencoded" }
|
112
112
|
end
|
113
113
|
|
114
114
|
end
|
data/lib/qiniu/rs/utils.rb
CHANGED
@@ -127,7 +127,7 @@ module Qiniu
|
|
127
127
|
File.open(filepath, "rb") { |f| Zlib.crc32 f.read }
|
128
128
|
end
|
129
129
|
|
130
|
-
def generate_qbox_signature(url, params)
|
130
|
+
def generate_qbox_signature(url, params, mime = nil)
|
131
131
|
access_key = Config.settings[:access_key]
|
132
132
|
secret_key = Config.settings[:secret_key]
|
133
133
|
uri = URI.parse(url)
|
@@ -139,6 +139,9 @@ module Qiniu
|
|
139
139
|
params_string = generate_query_string(params)
|
140
140
|
signature += params_string
|
141
141
|
end
|
142
|
+
if mime.is_a?(String) && mime == "application/x-www-form-urlencoded" && params.is_a?(String)
|
143
|
+
signature += params
|
144
|
+
end
|
142
145
|
hmac = HMAC::SHA1.new(secret_key)
|
143
146
|
hmac.update(signature)
|
144
147
|
encoded_digest = urlsafe_base64_encode(hmac.digest)
|
data/lib/qiniu/rs/version.rb
CHANGED
data/qiniu-rs.gemspec
CHANGED
@@ -5,9 +5,9 @@ require File.expand_path('../lib/qiniu/rs/version', __FILE__)
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.authors = ["why404"]
|
7
7
|
gem.email = ["why404@gmail.com"]
|
8
|
-
gem.description = %q{Qiniu Resource (Cloud) Storage SDK for Ruby. See: http://
|
8
|
+
gem.description = %q{Qiniu Resource (Cloud) Storage SDK for Ruby. See: http://developer.qiniu.com/docs/v6/sdk/ruby-sdk.html}
|
9
9
|
gem.summary = %q{Qiniu Resource (Cloud) Storage SDK for Ruby}
|
10
|
-
gem.homepage = "https://github.com/qiniu/ruby-sdk"
|
10
|
+
gem.homepage = "https://github.com/qiniu/ruby-sdk/tree/qiniu-rs"
|
11
11
|
|
12
12
|
gem.files = `git ls-files`.split($\)
|
13
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/spec/qiniu/rs/rs_spec.rb
CHANGED
@@ -92,19 +92,24 @@ module Qiniu
|
|
92
92
|
|
93
93
|
context ".batch_copy" do
|
94
94
|
it "should works" do
|
95
|
-
code, data = Qiniu::RS::RS.batch_copy
|
95
|
+
code, data = Qiniu::RS::RS.batch_copy @bucket, @key, @bucket, @key2
|
96
96
|
code.should == 200
|
97
97
|
puts data.inspect
|
98
98
|
|
99
99
|
#code2, data2 = Qiniu::RS::RS.stat(@bucket, @key2)
|
100
100
|
#code2.should == 200
|
101
101
|
#puts data2.inspect
|
102
|
+
#
|
103
|
+
code, data = Qiniu::RS::RS.delete(@bucket, @key2)
|
104
|
+
code.should == 200
|
105
|
+
puts data.inspect
|
106
|
+
|
102
107
|
end
|
103
108
|
end
|
104
109
|
|
105
110
|
context ".batch_move" do
|
106
111
|
it "should works" do
|
107
|
-
code, data = Qiniu::RS::RS.batch_move
|
112
|
+
code, data = Qiniu::RS::RS.batch_move @bucket, @key, @bucket, @key2
|
108
113
|
code.should == 200
|
109
114
|
puts data.inspect
|
110
115
|
|
@@ -112,7 +117,7 @@ module Qiniu
|
|
112
117
|
#code2.should == 200
|
113
118
|
#puts data2.inspect
|
114
119
|
|
115
|
-
code3, data3 = Qiniu::RS::RS.batch_move
|
120
|
+
code3, data3 = Qiniu::RS::RS.batch_move @bucket, @key2, @bucket, @key
|
116
121
|
code3.should == 200
|
117
122
|
puts data3.inspect
|
118
123
|
end
|
data/spec/qiniu/rs_spec.rb
CHANGED
@@ -298,23 +298,26 @@ module Qiniu
|
|
298
298
|
|
299
299
|
context ".batch_copy" do
|
300
300
|
it "should works" do
|
301
|
-
result = Qiniu::RS.batch_copy
|
301
|
+
result = Qiniu::RS.batch_copy @bucket, @key, @bucket, @key2
|
302
302
|
result.should_not be_false
|
303
303
|
|
304
304
|
#result2 = Qiniu::RS.stat(@bucket, @key2)
|
305
305
|
#result2.should_not be_false
|
306
|
+
|
307
|
+
result = Qiniu::RS.delete @bucket, @key2
|
308
|
+
result.should_not be_false
|
306
309
|
end
|
307
310
|
end
|
308
311
|
|
309
312
|
context ".batch_move" do
|
310
313
|
it "should works" do
|
311
|
-
result = Qiniu::RS
|
314
|
+
result = Qiniu::RS.batch_move @bucket, @key, @bucket, @key2
|
312
315
|
result.should_not be_false
|
313
316
|
|
314
317
|
#result2 = Qiniu::RS.stat(@bucket, @key2)
|
315
318
|
#result2.should_not be_false
|
316
319
|
|
317
|
-
result3 = Qiniu::RS.batch_move
|
320
|
+
result3 = Qiniu::RS.batch_move @bucket, @key2, @bucket, @key
|
318
321
|
result3.should_not be_false
|
319
322
|
end
|
320
323
|
end
|
metadata
CHANGED
@@ -1,52 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiniu-rs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
5
|
-
prerelease:
|
4
|
+
version: 3.4.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- why404
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0.9'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0.9'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '2.11'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '2.11'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: fakeweb
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: json
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rest-client
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: mime-types
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,7 +97,6 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: ruby-hmac
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - ~>
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,12 +104,11 @@ dependencies:
|
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - ~>
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0.4'
|
126
|
-
description:
|
111
|
+
description: 'Qiniu Resource (Cloud) Storage SDK for Ruby. See: http://developer.qiniu.com/docs/v6/sdk/ruby-sdk.html'
|
127
112
|
email:
|
128
113
|
- why404@gmail.com
|
129
114
|
executables: []
|
@@ -161,7 +146,6 @@ files:
|
|
161
146
|
- lib/qiniu/tokens/upload_token.rb
|
162
147
|
- qiniu-rs.gemspec
|
163
148
|
- spec/qiniu/rs/abstract_spec.rb
|
164
|
-
- spec/qiniu/rs/auth_spec.rb
|
165
149
|
- spec/qiniu/rs/eu_spec.rb
|
166
150
|
- spec/qiniu/rs/image_logo_for_test.png
|
167
151
|
- spec/qiniu/rs/image_spec.rb
|
@@ -174,39 +158,31 @@ files:
|
|
174
158
|
- spec/qiniu/rs_spec.rb
|
175
159
|
- spec/qiniu/tokens/qbox_token_spec.rb
|
176
160
|
- spec/spec_helper.rb
|
177
|
-
homepage: https://github.com/qiniu/ruby-sdk
|
161
|
+
homepage: https://github.com/qiniu/ruby-sdk/tree/qiniu-rs
|
178
162
|
licenses: []
|
163
|
+
metadata: {}
|
179
164
|
post_install_message:
|
180
165
|
rdoc_options: []
|
181
166
|
require_paths:
|
182
167
|
- lib
|
183
168
|
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
-
none: false
|
185
169
|
requirements:
|
186
|
-
- -
|
170
|
+
- - '>='
|
187
171
|
- !ruby/object:Gem::Version
|
188
172
|
version: '0'
|
189
|
-
segments:
|
190
|
-
- 0
|
191
|
-
hash: 4277870360728960910
|
192
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
|
-
none: false
|
194
174
|
requirements:
|
195
|
-
- -
|
175
|
+
- - '>='
|
196
176
|
- !ruby/object:Gem::Version
|
197
177
|
version: '0'
|
198
|
-
segments:
|
199
|
-
- 0
|
200
|
-
hash: 4277870360728960910
|
201
178
|
requirements: []
|
202
179
|
rubyforge_project:
|
203
|
-
rubygems_version:
|
180
|
+
rubygems_version: 2.0.3
|
204
181
|
signing_key:
|
205
|
-
specification_version:
|
182
|
+
specification_version: 4
|
206
183
|
summary: Qiniu Resource (Cloud) Storage SDK for Ruby
|
207
184
|
test_files:
|
208
185
|
- spec/qiniu/rs/abstract_spec.rb
|
209
|
-
- spec/qiniu/rs/auth_spec.rb
|
210
186
|
- spec/qiniu/rs/eu_spec.rb
|
211
187
|
- spec/qiniu/rs/image_logo_for_test.png
|
212
188
|
- spec/qiniu/rs/image_spec.rb
|
data/spec/qiniu/rs/auth_spec.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'qiniu/rs/auth'
|
5
|
-
|
6
|
-
module Qiniu
|
7
|
-
module RS
|
8
|
-
describe Auth do
|
9
|
-
|
10
|
-
before :all do
|
11
|
-
@username = "qboxtest"
|
12
|
-
@password = "qboxtest123"
|
13
|
-
|
14
|
-
code, data = Qiniu::RS::Auth.exchange_by_password!(@username, @password)
|
15
|
-
code.should == 200
|
16
|
-
data.should be_an_instance_of(Hash)
|
17
|
-
data["access_token"].should_not be_empty
|
18
|
-
data["refresh_token"].should_not be_empty
|
19
|
-
data["refresh_token"].should_not be_empty
|
20
|
-
|
21
|
-
@access_token = data["access_token"]
|
22
|
-
@refresh_token = data["refresh_token"]
|
23
|
-
puts data.inspect
|
24
|
-
end
|
25
|
-
|
26
|
-
context ".exchange_by_password" do
|
27
|
-
it "should sign in failed when pass a non-existent username" do
|
28
|
-
code, data = Qiniu::RS::Auth.exchange_by_password!("a_non_existent_user@example.com", "password")
|
29
|
-
code.should == 401
|
30
|
-
data["error_code"].should == 11
|
31
|
-
data["error"].should == "failed_authentication"
|
32
|
-
puts data.inspect
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should sign in failed when pass a wrong password" do
|
36
|
-
code, data = Qiniu::RS::Auth.exchange_by_password!(@username, "a-wrong-password")
|
37
|
-
code.should == 401
|
38
|
-
data["error_code"].should == 11
|
39
|
-
data["error"].should == "failed_authentication"
|
40
|
-
puts data.inspect
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context ".exchange_by_refresh_token" do
|
45
|
-
it "should works" do
|
46
|
-
@refresh_token.should_not be_empty
|
47
|
-
code, data = Qiniu::RS::Auth.exchange_by_refresh_token!(@refresh_token)
|
48
|
-
code.should == 200
|
49
|
-
data["access_token"].should_not be_empty
|
50
|
-
data["refresh_token"].should_not be_empty
|
51
|
-
data["expires_in"].should_not be_zero
|
52
|
-
puts data.inspect
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|