libgss 0.8.4 → 0.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 285cbb5ffec91a5e1b2af1bbd04ff75ce0e1e2f0
4
- data.tar.gz: a5c7c601dc9912c03aca809c1883979d3ae5c73c
3
+ metadata.gz: 7851a6116163ca2eb6bf2af61af08bebd7a59383
4
+ data.tar.gz: ef4dcbd1330729b3d27d63a643b600abee0e5af9
5
5
  SHA512:
6
- metadata.gz: a52d307846effba78bea970e8967290d8210316c43d4e556e9818b8204bfd1948683e16b7bdff13f3a30b17adea738be009901604e8850e787e3a17d5c7e123a
7
- data.tar.gz: 14dae11aaf40f74e4e47f7452bf7169a1b825bfaa75393b6d9fe469380b23546d71c76c61bbe37de15f95058fe692fe93cc87d8c61bd4ad50d593717af18361e
6
+ metadata.gz: 17085bf8a1bd853273cfcd6bce736eb5f64aba253d09161bfc99cd9f898acd463430143c6cc80cfde8517f1c5dd5c99ef901466371932e481fd850d2e4e8d7ec
7
+ data.tar.gz: 6f09c4a77661bc89bb5981ddd1981c51df36f2df209060e8b3b1abf3eee18371af0842777470b85ee2f707f4c73512336d474703ce5e9d6961871993127b7d25
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- libgss (0.8.3)
4
+ libgss (0.9.0)
5
5
  httpclient
6
6
  json
7
7
  oauth
@@ -1,3 +1,3 @@
1
1
  module Libgss
2
- VERSION = "0.8.4"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -2,6 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  require 'uuid'
5
+ require 'securerandom'
5
6
 
6
7
  describe Libgss::Network do
7
8
 
@@ -153,6 +154,118 @@ describe Libgss::Network do
153
154
 
154
155
  end
155
156
 
157
+ describe "#login(with Cathedral)" do
158
+ before do
159
+ @gdkey = SecureRandom.uuid
160
+ @extras = {udkey: SecureRandom.uuid, gdkey: @gdkey, device_cd: "10"}
161
+ network.player_id = nil
162
+ network.platform = 'cathedral'
163
+ network.client_version = "2013073101"
164
+ network.device_type_cd = 1
165
+ end
166
+
167
+ context "success" do
168
+ shared_examples_for "Libgss::Network#login(cathedral) success" do |block, after_block = nil|
169
+ before(&block) if block
170
+ after(&after_block) if after_block
171
+
172
+ it do
173
+ network.platform.should eq 'cathedral'
174
+ network.auth_token.should eq nil
175
+ network.signature_key.should eq nil
176
+
177
+ res = network.login(@extras)
178
+ res.should eq true
179
+ network.auth_token.should_not eq nil
180
+ network.signature_key.should_not eq nil
181
+
182
+ req = network.new_action_request
183
+ req.get_by_player
184
+ req.send_request do |outputs|
185
+ outputs.should have(1).results
186
+ outputs[0].should have_key('result')
187
+ @result = outputs[0]['result']
188
+ end
189
+ end
190
+ end
191
+
192
+ it_should_behave_like("Libgss::Network#login(cathedral) success",
193
+ nil, Proc.new{
194
+ network.player_id.should eq @gdkey
195
+ @result['player_id'].should eq @gdkey
196
+ })
197
+
198
+ it_should_behave_like("Libgss::Network#login(cathedral) success",
199
+ Proc.new{ @extras = @extras.update({udkey: nil}) },
200
+ Proc.new{
201
+ network.player_id.should eq @gdkey
202
+ @result['player_id'].should eq @gdkey
203
+ })
204
+
205
+ it_should_behave_like("Libgss::Network#login(cathedral) success",
206
+ Proc.new{ @extras = @extras.update({device_cd: nil}) },
207
+ Proc.new{
208
+ network.player_id.should eq @gdkey
209
+ @result['player_id'].should eq @gdkey
210
+ })
211
+ end
212
+
213
+ context "failure with gdkey is brank" do
214
+ it "by using login" do
215
+ res = network.login({gdkey: nil})
216
+ network.auth_token.should == nil
217
+ network.signature_key.should == nil
218
+ res.should == false
219
+ end
220
+ it "by using login!" do
221
+ expect{ network.login!({gdkey: nil}) }.to raise_error(Libgss::Network::Error)
222
+ end
223
+ end
224
+
225
+ context "error" do
226
+ shared_examples_for "Libgss::Network#login failure" do
227
+ it "by using login"do
228
+ network.auth_token.should == nil
229
+ network.signature_key.should == nil
230
+ res = network.login(@extras)
231
+ network.auth_token.should == nil
232
+ network.signature_key.should == nil
233
+ res.should == false
234
+ end
235
+ it "by using login"do
236
+ network.auth_token.should == nil
237
+ network.signature_key.should == nil
238
+ expect{ network.login!(@extras) }.to raise_error(Libgss::Network::Error)
239
+ end
240
+ end
241
+
242
+ [300, 400, 500].map{|n| (1..10).map{|i| n + i} }.flatten.each do |status_code|
243
+ context "status_code is #{status_code}" do
244
+ before do
245
+ res = double(:reponse)
246
+ res.should_receive(:status).and_return(status_code)
247
+ HTTPClient.any_instance.should_receive(:post).and_return(res)
248
+ end
249
+ it_should_behave_like "Libgss::Network#login failure"
250
+ end
251
+ end
252
+
253
+ context "JSON parse Error" do
254
+ before do
255
+ $stderr.stub(:puts).with(an_instance_of(String)) # $stderrにメッセージが出力されます
256
+ res = double(:reponse)
257
+ res.stub(:status).and_return(200)
258
+ res.should_receive(:content).twice.and_return("invalid JSON format string")
259
+ HTTPClient.any_instance.should_receive(:post).and_return(res)
260
+ end
261
+
262
+ it_should_behave_like "Libgss::Network#login failure"
263
+ end
264
+
265
+ end
266
+
267
+ end
268
+
156
269
  describe "#new_action_request" do
157
270
 
158
271
  let(:req){ network.new_action_request }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libgss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - akima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler