aliyunsdkcore 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b91a1f18e37ba166b834f1eae8c3de8260a7f2f94036cbb3f0c2473ac87deea0
4
- data.tar.gz: 8ee808dd7056fa847b6b89eaa46c0441719d75bab0d591eda5cee3e9442b43ed
3
+ metadata.gz: 581d5102e54082d1ca78dc3d44b6bd726c9a5f80975429c5bdb1475c3f6e765f
4
+ data.tar.gz: ad731df5501c98b5e041dbeda8919d3373ddc93dba736b8d7775b8eea4b75aa2
5
5
  SHA512:
6
- metadata.gz: 27556d5341ae7189049c4824f393bc2134c21a3ca5e2ad68e59632a64e4c55611a3cf72e31cc330590634299fbf21e2ac173fd9067e56c0dbde6a665c6218e7b
7
- data.tar.gz: 82b71633d0d92792e3520aacf3adc2244f448a2b2171a9c71152c16cde27fc4057486bf6bb8b6c08161ea81009916d8954c5acbb420890e4e235a58501b3b683
6
+ metadata.gz: 8758835e68a3c9aa352f2d07a2d954b7645faae7165c02e1923535f2c8565f05a4f444a3511dcb6dc62d1d4bf3f15e4e2e59d6e48c531d44c58dce02bf3486ba
7
+ data.tar.gz: b4aaa9363a1edaca92d3106beccb3dbadb6adb37d0b12803a7aab63631b69ff8e700fd5fa8d2400544451a4d79a012afc7499e01b5988248fb06b8e949465c5d
@@ -2,5 +2,5 @@ require_relative './rpc_client'
2
2
  require_relative './roa_client'
3
3
 
4
4
  module AliyunSDKCore
5
- VERSION = "0.0.5"
5
+ VERSION = "0.0.6"
6
6
  end
@@ -36,18 +36,23 @@ class RPCClient
36
36
  signature = Base64.encode64(OpenSSL::HMAC.digest('sha1', key, string_to_sign)).strip
37
37
  normalized.push(['Signature', encode(signature)])
38
38
 
39
- uri = opts[:method] == 'POST' ? '/' : "/?#{canonicalize(normalized)}"
39
+ querystring = canonicalize(normalized)
40
+
41
+ uri = opts[:method] == 'POST' ? '/' : "/?#{querystring}"
42
+
40
43
  response = connection.send(method.downcase, uri) do |request|
41
44
  if opts[:method] == 'POST'
42
45
  request.headers['Content-Type'] = 'application/x-www-form-urlencoded'
43
- request.body = canonicalize(normalized)
46
+ request.body = querystring
44
47
  end
45
48
  end
49
+
46
50
  response_body = JSON.parse(response.body)
47
51
  if response_body['Code'] && !self.codes.include?(response_body['Code'])
48
52
  raise StandardError, "#{response_body['Message']}, URL: #{uri}"
49
53
  end
50
- response
54
+
55
+ response_body
51
56
  end
52
57
 
53
58
  private
@@ -71,7 +76,8 @@ class RPCClient
71
76
  end
72
77
 
73
78
  def encode(string)
74
- CGI.escape string
79
+ encoded = CGI.escape string
80
+ encoded.gsub(/[\+]/, '%20')
75
81
  end
76
82
 
77
83
  def format_params(param_hash)
@@ -19,17 +19,24 @@ describe 'rpc request' do
19
19
  params = { key: (1..11).to_a.map(&:to_s) }
20
20
  request_option = { method: 'POST', timeout: 15000 }
21
21
  response = rpc_client.request(action: 'DescribeRegions', params: params, opts: request_option)
22
- response_body = JSON.parse(response.body)
23
- expect(response_body.keys.include?('Regions')).to be true
24
- expect(response_body.keys.include?('RequestId')).to be true
22
+ expect(response.keys.include?('Regions')).to be true
23
+ expect(response.keys.include?('RequestId')).to be true
25
24
  end
26
25
 
27
26
  it 'should ok with repeat list less 10 item' do
28
27
  params = { key: (1..9).to_a.map(&:to_s) }
29
28
  request_option = { method: 'POST', timeout: 15000 }
30
29
  response = rpc_client.request(action: 'DescribeRegions', params: params, opts: request_option)
31
- response_body = JSON.parse(response.body)
32
- expect(response_body.keys.include?('Regions')).to be true
33
- expect(response_body.keys.include?('RequestId')).to be true
30
+ expect(response.keys.include?('Regions')).to be true
31
+ expect(response.keys.include?('RequestId')).to be true
34
32
  end
33
+
34
+ it 'should ok with space' do
35
+ params = { key: 'the string with spaces' }
36
+ request_option = { method: 'POST', timeout: 15000 }
37
+ response = rpc_client.request(action: 'DescribeRegions', params: params, opts: request_option)
38
+ expect(response.keys.include?('Regions')).to be true
39
+ expect(response.keys.include?('RequestId')).to be true
40
+ end
41
+
35
42
  end
@@ -108,7 +108,7 @@ describe 'rpc core' do
108
108
  access_key_secret: 'access_key_secret',
109
109
  )
110
110
  stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 200, body: {}.to_json)
111
- expect(rpc_client.request(action: 'action').body).to eq({}.to_json)
111
+ expect(rpc_client.request(action: 'action')).to eql({})
112
112
  end
113
113
  end
114
114
 
@@ -126,33 +126,25 @@ describe 'rpc core' do
126
126
 
127
127
  it 'should ok' do
128
128
  stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 200, body: {}.to_json)
129
- expect(rpc_client.request(action: 'action').body).to eq({}.to_json)
129
+ expect(rpc_client.request(action: 'action')).to eql({})
130
130
  end
131
131
 
132
132
  it 'should ok with format_action' do
133
133
  stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 200, body: {}.to_json)
134
134
  response = rpc_client.request(action: 'action', opts: { format_action: false })
135
- expect(response.body).to eq({}.to_json)
135
+ expect(response).to eql({})
136
136
  end
137
137
 
138
138
  it 'should ok with format_params' do
139
139
  stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 200, body: {}.to_json)
140
140
  response = rpc_client.request(action: 'action', opts: { format_params: false })
141
- expect(response.body).to eq({}.to_json)
141
+ expect(response).to eql({})
142
142
  end
143
143
 
144
144
  it 'get with raw body should ok' do
145
145
  stub_request(:post, "https://ecs.aliyuncs.com").to_return(status: 200, body: {}.to_json)
146
146
  response = rpc_client.request(action: 'action', opts: { method: 'POST' })
147
- expect(response.body).to eq({}.to_json)
148
- end
149
-
150
- it 'get with verbose should ok' do
151
- stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 200, body: {}.to_json)
152
- response = rpc_client.request(action: 'action')
153
- expect(response.status).to eq 200
154
- expect(response.success?).to be true
155
- expect(response.body).to eq({}.to_json)
147
+ expect(response).to eql({})
156
148
  end
157
149
  end
158
150
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliyunsdkcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alibaba Cloud SDK
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-25 00:00:00.000000000 Z
11
+ date: 2019-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday