bnet-authenticator 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +3 -1
- data/Rakefile +9 -1
- data/bnet-authenticator.gemspec +1 -0
- data/lib/bnet/authenticator.rb +7 -10
- data/lib/bnet/authenticator/core.rb +1 -3
- data/lib/bnet/authenticator/errors.rb +10 -0
- data/lib/bnet/authenticator/version.rb +1 -1
- data/lib/bnet/command.rb +1 -1
- data/test/test_battlenet_authenticator.rb +22 -12
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 365b40fb792dd5b40f624f03a201736bf0d6222d
|
4
|
+
data.tar.gz: c2ca91aa7707d402b6d162877b9617c13ed14585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd923341d7be293c46ebc458a709377fd3922fe387a2199db6c049cb7e08b7361923b032fdc71510967dde0fdcab860702196e48315b7387038dfb45e05f4eb7
|
7
|
+
data.tar.gz: 45e7208d2a4886676db024ae730093e0de9edc0e236ca9fdc3c899f3098bbb0db7163a8090abd0b4d2041cb0d1baa1523cb111d7185101344f6f395ab7b779df
|
data/README.md
CHANGED
@@ -2,7 +2,9 @@ Bnet::Authenticator
|
|
2
2
|
====
|
3
3
|
Ruby implementation of the Battle.net Mobile Authenticator.
|
4
4
|
|
5
|
-
[](http://badge.fury.io/rb/bnet-authenticator)
|
6
|
+
|
7
|
+
[](https://travis-ci.org/dorentus/bnet-authenticator) [](https://gemnasium.com/dorentus/bnet-authenticator) [](https://coveralls.io/r/dorentus/bnet-authenticator)
|
6
8
|
|
7
9
|
Installation
|
8
10
|
====
|
data/Rakefile
CHANGED
@@ -5,4 +5,12 @@ Rake::TestTask.new do |t|
|
|
5
5
|
end
|
6
6
|
|
7
7
|
desc "Run tests"
|
8
|
-
|
8
|
+
|
9
|
+
if ENV["TRAVIS"] == "true"
|
10
|
+
require 'coveralls/rake/task'
|
11
|
+
Coveralls::RakeTask.new
|
12
|
+
|
13
|
+
task :default => [:test, 'coveralls:push']
|
14
|
+
else
|
15
|
+
task :default => :test
|
16
|
+
end
|
data/bnet-authenticator.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
if s.respond_to?(:add_development_dependency)
|
20
20
|
s.add_development_dependency 'rake', '~> 0'
|
21
21
|
s.add_development_dependency 'yard', '~> 0'
|
22
|
+
s.add_development_dependency 'coveralls', '~> 0.7'
|
22
23
|
end
|
23
24
|
|
24
25
|
s.files = `git ls-files`.split("\n") - %w(.travis.yml .gitignore)
|
data/lib/bnet/authenticator.rb
CHANGED
@@ -41,19 +41,16 @@ module Bnet
|
|
41
41
|
#
|
42
42
|
# == Parameters:
|
43
43
|
# options:
|
44
|
-
# A
|
44
|
+
# A Hash. Valid key combanations are:
|
45
45
|
#
|
46
|
-
# -
|
46
|
+
# - :serial and :secret
|
47
|
+
# Create a new authenticator with given serial and secret.
|
47
48
|
#
|
48
|
-
#
|
49
|
+
# - :region
|
50
|
+
# Request for a new authenticator using given region.
|
49
51
|
#
|
50
|
-
# -
|
51
|
-
#
|
52
|
-
# Request for a new authenticator using given `region`
|
53
|
-
#
|
54
|
-
# - `:serial` & `:restorecode`
|
55
|
-
#
|
56
|
-
# Reqeust to restore an authenticator using given `serial` and `restorecode`
|
52
|
+
# - :serial and :restorecode
|
53
|
+
# Reqeust to restore an authenticator using given serial and restoration code.
|
57
54
|
#
|
58
55
|
def initialize(options = {})
|
59
56
|
options = Core.normalize_options(options)
|
@@ -2,14 +2,12 @@ require 'digest/sha1'
|
|
2
2
|
require 'digest/hmac'
|
3
3
|
require 'net/http'
|
4
4
|
require 'bnet/support'
|
5
|
+
require 'bnet/authenticator/errors'
|
5
6
|
|
6
7
|
module Bnet
|
7
8
|
|
8
9
|
class Authenticator
|
9
10
|
|
10
|
-
class RequestFailedError < StandardError; end
|
11
|
-
class BadInputError < StandardError; end
|
12
|
-
|
13
11
|
module Core
|
14
12
|
|
15
13
|
RSA_MOD = 104890018807986556874007710914205443157030159668034197186125678960287470894290830530618284943118405110896322835449099433232093151168250152146023319326491587651685252774820340995950744075665455681760652136576493028733914892166700899109836291180881063097461175643998356321993663868233366705340758102567742483097
|
data/lib/bnet/command.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear_merged!
|
3
|
+
|
1
4
|
require 'test/unit'
|
2
5
|
require 'bnet/authenticator'
|
3
6
|
|
@@ -13,39 +16,46 @@ class Bnet::AuthenticatorTest < Test::Unit::TestCase
|
|
13
16
|
end
|
14
17
|
|
15
18
|
def test_argument_error
|
16
|
-
assert_raise ::Bnet::BadInputError do
|
19
|
+
assert_raise ::Bnet::Authenticator::BadInputError do
|
17
20
|
Bnet::Authenticator.new
|
18
21
|
end
|
19
22
|
|
20
|
-
assert_raise ::Bnet::BadInputError do
|
23
|
+
assert_raise ::Bnet::Authenticator::BadInputError do
|
21
24
|
Bnet::Authenticator.new(:serial => 'ABC')
|
22
25
|
end
|
23
26
|
|
24
|
-
assert_raise ::Bnet::BadInputError do
|
27
|
+
assert_raise ::Bnet::Authenticator::BadInputError do
|
25
28
|
Bnet::Authenticator.new(:region => 'SG')
|
26
29
|
end
|
27
30
|
|
28
|
-
assert_raise ::Bnet::BadInputError do
|
31
|
+
assert_raise ::Bnet::Authenticator::BadInputError do
|
29
32
|
Bnet::Authenticator.new(:restorecode => 'DDDD')
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
def test_request_new_serial
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
begin
|
38
|
+
authenticator = Bnet::Authenticator.new(:region => :US)
|
39
|
+
assert_equal :US, authenticator.region
|
40
|
+
assert_not_nil authenticator.serial
|
41
|
+
assert_not_nil authenticator.secret
|
42
|
+
assert_not_nil authenticator.restorecode
|
43
|
+
rescue Bnet::Authenticator::RequestFailedError
|
44
|
+
end
|
39
45
|
end
|
40
46
|
|
41
47
|
def test_restore
|
42
|
-
|
43
|
-
|
48
|
+
begin
|
49
|
+
authenticator = Bnet::Authenticator.new(:serial => DEFAULT_SERIAL, :restorecode => DEFAULT_RSCODE)
|
50
|
+
is_default_authenticator authenticator
|
51
|
+
rescue Bnet::Authenticator::RequestFailedError
|
52
|
+
end
|
44
53
|
end
|
45
54
|
|
46
55
|
def test_request_server_time
|
47
|
-
|
56
|
+
begin
|
48
57
|
Bnet::Authenticator.request_server_time :EU
|
58
|
+
rescue Bnet::Authenticator::RequestFailedError
|
49
59
|
end
|
50
60
|
end
|
51
61
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bnet-authenticator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZHANG Yi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coveralls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.7'
|
41
55
|
description: Ruby implementation of the Battle.net Mobile Authenticator
|
42
56
|
email:
|
43
57
|
- zhangyi.cn@gmail.com
|
@@ -55,6 +69,7 @@ files:
|
|
55
69
|
- bnet-authenticator.gemspec
|
56
70
|
- lib/bnet/authenticator.rb
|
57
71
|
- lib/bnet/authenticator/core.rb
|
72
|
+
- lib/bnet/authenticator/errors.rb
|
58
73
|
- lib/bnet/authenticator/version.rb
|
59
74
|
- lib/bnet/command.rb
|
60
75
|
- lib/bnet/commands/help.rb
|
@@ -90,3 +105,4 @@ specification_version: 4
|
|
90
105
|
summary: Battle.net Mobile Authenticator
|
91
106
|
test_files:
|
92
107
|
- test/test_battlenet_authenticator.rb
|
108
|
+
has_rdoc:
|