libgss 0.7.2 → 0.7.3

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: a77c17af378bc6038a7ce58b8a07e4d60757fab3
4
- data.tar.gz: aaf5b60ce2937cacce2f6fc35a398d446fcd0e9f
3
+ metadata.gz: d53665633c09d8a6f5ca84777c9de59b69f26ca0
4
+ data.tar.gz: 099b87fa95d54caac1aadb658a9aed566073d185
5
5
  SHA512:
6
- metadata.gz: fb962ff05a56236c77dda5c1a85c29bb5d9230a285c07784379d63b109db944f24641690f34e680095f8e388aa3a9ca3e500a09a655421e1faa9febed8e5b11a
7
- data.tar.gz: e91b141a88aee2001402312a5c0b968707d37e3324fea35686ab9825316b68019424ede486313f023a01c212f84c2b98f1ae95f9f2d2a68093602ad12d1a7f8b
6
+ metadata.gz: 48963d4fe7b7a7f02629fa5a0a92cef7030f6c9ebd8651624b0efa7203aba63f798417f91cebe0003cde45a4d7a1537bf73a317593564ec82dfcb1ffda1047cb
7
+ data.tar.gz: cf7df2a141e586bf514a485cc1a2e135572067e1413ce86b1fcd6a1c1bd5dd32983ae3924cda5bc58fb1db87c7f81e6efac33a45007d9d6ee5b7f9c8d76676d8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- libgss (0.7.2)
4
+ libgss (0.7.3)
5
5
  httpclient
6
6
  json
7
7
  oauth
@@ -22,9 +22,13 @@ module Libgss
22
22
  headers = {
23
23
  "oauth_consumer_key" => network.consumer_key || "",
24
24
  "oauth_token" => network.auth_token,
25
- "oauth_nonce" => oauth_nonce,
26
- "oauth_timestamp" => oauth_timestamp,
27
25
  }
26
+ unless @network.ignore_oauth_nonce
27
+ headers.update({
28
+ "oauth_nonce" => oauth_nonce,
29
+ "oauth_timestamp" => oauth_timestamp,
30
+ })
31
+ end
28
32
  oauth_params = {
29
33
  "body" => body,
30
34
  "oauth_signature_method" => "HMAC-SHA1"
@@ -56,9 +60,13 @@ module Libgss
56
60
  headers = {
57
61
  "oauth_consumer_key" => network.consumer_key || "",
58
62
  "oauth_token" => network.auth_token,
59
- "oauth_nonce" => oauth_nonce,
60
- "oauth_timestamp" => oauth_timestamp,
61
63
  }
64
+ unless @network.ignore_oauth_nonce
65
+ headers.update({
66
+ "oauth_nonce" => oauth_nonce,
67
+ "oauth_timestamp" => oauth_timestamp,
68
+ })
69
+ end
62
70
  oauth_params = {
63
71
  "body" => '',
64
72
  "oauth_signature_method" => "HMAC-SHA1"
@@ -109,11 +117,11 @@ module Libgss
109
117
  end
110
118
 
111
119
  def oauth_nonce
112
- SecureRandom.uuid.to_s
120
+ @network.oauth_nonce || SecureRandom.uuid.to_s
113
121
  end
114
122
 
115
123
  def oauth_timestamp
116
- Time.now.utc.to_i
124
+ @network.oauth_timestamp || Time.now.utc.to_i
117
125
  end
118
126
 
119
127
  class Signature
@@ -25,6 +25,9 @@ module Libgss
25
25
 
26
26
  attr_accessor :consumer_secret
27
27
  attr_accessor :consumer_key
28
+ attr_accessor :ignore_oauth_nonce
29
+ attr_accessor :oauth_nonce
30
+ attr_accessor :oauth_timestamp
28
31
 
29
32
  attr_accessor :api_version
30
33
  attr_accessor :platform
@@ -49,6 +52,9 @@ module Libgss
49
52
  # @option options [String] :platform 接続先のGSSサーバの認証のプラットフォーム。デフォルトは"fontana"。
50
53
  # @option options [String] :player_id 接続に使用するプレイヤのID
51
54
  # @option options [String] :consumer_secret GSSサーバとクライアントの間で行う署名の検証に使用される文字列。
55
+ # @option options [Boolean] :ignore_oauth_nonce OAuth認証時にoauth_nonceとoauth_timestampを使用しないかどうか。
56
+ # @option options [String] :oauth_nonce OAuth認証のoauth_nonceパラメータ
57
+ # @option options [Integer] :oauth_timestamp OAuth認証のoauth_timestampパラメータ
52
58
  # @option options [Boolean] :ssl_disabled SSLを無効にするかどうか。
53
59
  # @option options [Boolean] :ignore_signature_key シグネチャキーによる署名を行うかどうか
54
60
  # @option options [Integer] :device_type_cd GSS/fontanaに登録されたデバイス種別
@@ -71,6 +77,9 @@ module Libgss
71
77
 
72
78
  @consumer_secret = options[:consumer_secret] || ENV["CONSUMER_SECRET"]
73
79
  @ignore_signature_key = !!options[:ignore_signature_key]
80
+ @ignore_oauth_nonce = !!options[:ignore_oauth_nonce]
81
+ @oauth_nonce = options[:oauth_nonce] || nil
82
+ @oauth_timestamp = options[:oauth_timestamp] || nil
74
83
 
75
84
  @device_type_cd = options[:device_type_cd]
76
85
  @client_version = options[:client_version]
@@ -1,3 +1,3 @@
1
1
  module Libgss
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  end
@@ -19,6 +19,9 @@ describe Libgss::Network do
19
19
  network.player_id.should_not == nil
20
20
  network.auth_token.should_not == nil
21
21
  network.signature_key.should_not == nil
22
+ network.ignore_oauth_nonce.should == false
23
+ network.oauth_nonce.should == nil
24
+ network.oauth_timestamp.should == nil
22
25
  res.should == true
23
26
  end
24
27
  end
@@ -63,7 +66,6 @@ describe Libgss::Network do
63
66
  it_should_behave_like "Libgss::Network#login success",
64
67
  Proc.new{ network.player_id = nil },
65
68
  Proc.new{ network.player_id.should_not == nil }
66
-
67
69
  end
68
70
 
69
71
  context "failure with unregistered (maybe invalid) player_id" do
@@ -184,4 +186,42 @@ describe Libgss::Network do
184
186
  end
185
187
  end
186
188
 
189
+ describe "with oauth options" do
190
+
191
+ def spec_with_network_options(opts={}, &block)
192
+ r = new_network_with_options(opts).tap(&:login).new_action_request
193
+ r.server_time
194
+ r.send_request do |outputs|
195
+ outputs.length.should == 1
196
+ result = outputs.first['result']
197
+ yield(result) if block_given?
198
+ end
199
+ end
200
+
201
+ context "success" do
202
+ it "with ignore_oauth_nonce" do
203
+ spec_with_network_options({ignore_oauth_nonce: true})
204
+ end
205
+ it "with oauth_nonce" do
206
+ spec_with_network_options({oauth_nonce: UUID.new.generate})
207
+ end
208
+ it "with oauth_timestamp" do
209
+ time = Time.now
210
+ spec_with_network_options({oauth_timestamp: time.to_i})
211
+ end
212
+ end
213
+ context "401 error" do
214
+ it "with empty oauth_nonce" do
215
+ proc{
216
+ spec_with_network_options({oauth_nonce: ''})
217
+ }.should raise_error(::Libgss::ActionRequest::Error)
218
+ end
219
+ it "with old oauth_timestamp" do
220
+ time = Time.local(2013,7,1,12,0,0)
221
+ proc{
222
+ spec_with_network_options({oauth_timestamp: time.to_i})
223
+ }.should raise_error(::Libgss::ActionRequest::Error)
224
+ end
225
+ end
226
+ end
187
227
  end
data/spec/spec_helper.rb CHANGED
@@ -21,3 +21,15 @@ def new_network(url = "http://localhost:4000", player_id = "1000001")
21
21
  }
22
22
  Libgss::Network.new(url, opts)
23
23
  end
24
+
25
+ def new_network_with_options(opts={}, url = "http://localhost:4000", player_id = "1000001")
26
+ config = YAML.load_file(File.expand_path("../../fontana_sample/config/app_garden.yml", __FILE__))
27
+ opts = {
28
+ device_type_cd: 1,
29
+ client_version: "2013073101",
30
+ consumer_secret: config["consumer_secret"],
31
+ player_id: player_id,
32
+ # ssl_disabled: true,
33
+ }.update(opts)
34
+ Libgss::Network.new(url, opts)
35
+ end
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.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - akima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-13 00:00:00.000000000 Z
11
+ date: 2013-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -209,4 +209,3 @@ test_files:
209
209
  - spec/protected_assets/Icon.png
210
210
  - spec/public_assets/Default.png
211
211
  - spec/spec_helper.rb
212
- has_rdoc: