authy 2.3.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/VERSION +1 -1
- data/lib/authy.rb +1 -0
- data/lib/authy/api.rb +4 -2
- data/lib/authy/phone_intelligence.rb +29 -0
- data/lib/authy/version.rb +1 -1
- data/spec/authy/api_spec.rb +17 -11
- data/spec/authy/phone_intelligence_spec.rb +92 -0
- data/spec/authy/response_spec.rb +2 -2
- metadata +50 -65
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 81735aedc17dacda72bd8f831b306961e07cdf2c
|
4
|
+
data.tar.gz: c49d07082ce397c88b41b8746d5ec3a73e3040d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 73266d8be9764af02b6f269365c0f7452722d32ef745bb308da4294911e3397e79485113a95f1a266b79a1f22951bf93ed9eece1f94e6828523ba3b607e6bfda
|
7
|
+
data.tar.gz: e785fb4a38699607e64b7c8f31c054348033275114a02f9ed88ef5395adda34f46768626b417b285abb45c454a4a4e32d02632c7d37df45340aded4c414b229d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.0
|
data/lib/authy.rb
CHANGED
data/lib/authy/api.rb
CHANGED
@@ -36,8 +36,10 @@ module Authy
|
|
36
36
|
params[:force] = true if params[:force].nil? && params['force'].nil?
|
37
37
|
|
38
38
|
get_request("protected/json/verify/:token/:user_id", params.merge({
|
39
|
-
|
40
|
-
|
39
|
+
"token" => token,
|
40
|
+
"user_id" => user_id
|
41
|
+
})
|
42
|
+
)
|
41
43
|
end
|
42
44
|
|
43
45
|
# options:
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Authy
|
2
|
+
class PhoneIntelligence < Authy::API
|
3
|
+
|
4
|
+
# options:
|
5
|
+
# :via (sms|call)
|
6
|
+
# :country_code Numeric calling country code of the country.
|
7
|
+
# :phone_number The persons phone number.
|
8
|
+
def self.verification_start(params)
|
9
|
+
params[:via] = "sms" unless %w(sms, call).include?(params[:via])
|
10
|
+
|
11
|
+
post_request("protected/json/phones/verification/start", params)
|
12
|
+
end
|
13
|
+
|
14
|
+
# options:
|
15
|
+
# :country_code Numeric calling country code of the country.
|
16
|
+
# :phone_number The persons phone number.
|
17
|
+
# :verification_code The verification code entered by the user.
|
18
|
+
def self.verification_check(params)
|
19
|
+
get_request("protected/json/phones/verification/check", params)
|
20
|
+
end
|
21
|
+
|
22
|
+
# options:
|
23
|
+
# :country_code Numeric calling country code of the country.
|
24
|
+
# :phone_number The persons phone number.
|
25
|
+
def self.info(params)
|
26
|
+
get_request("protected/json/phones/info", params)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/authy/version.rb
CHANGED
data/spec/authy/api_spec.rb
CHANGED
@@ -4,9 +4,11 @@ describe "Authy::API" do
|
|
4
4
|
describe "Registering users" do
|
5
5
|
|
6
6
|
it "should find or create a user" do
|
7
|
-
user = Authy::API.register_user(
|
8
|
-
|
9
|
-
|
7
|
+
user = Authy::API.register_user(
|
8
|
+
:email => generate_email,
|
9
|
+
:cellphone => generate_cellphone,
|
10
|
+
:country_code => 1
|
11
|
+
)
|
10
12
|
user.should be_kind_of(Authy::Response)
|
11
13
|
|
12
14
|
user.should be_kind_of(Authy::User)
|
@@ -16,19 +18,23 @@ describe "Authy::API" do
|
|
16
18
|
end
|
17
19
|
|
18
20
|
it "should return the error messages as a hash" do
|
19
|
-
user = Authy::API.register_user(
|
20
|
-
|
21
|
-
|
21
|
+
user = Authy::API.register_user(
|
22
|
+
:email => generate_email,
|
23
|
+
:cellphone => "abc-1234",
|
24
|
+
:country_code => 1
|
25
|
+
)
|
22
26
|
|
23
27
|
user.errors.should be_kind_of(Hash)
|
24
28
|
user.errors['cellphone'].should == 'is invalid'
|
25
29
|
end
|
26
30
|
|
27
31
|
it "should allow to override the API key" do
|
28
|
-
user = Authy::API.register_user(
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
user = Authy::API.register_user(
|
33
|
+
:email => generate_email,
|
34
|
+
:cellphone => generate_cellphone,
|
35
|
+
:country_code => 1,
|
36
|
+
:api_key => "invalid_api_key"
|
37
|
+
)
|
32
38
|
|
33
39
|
user.should_not be_ok
|
34
40
|
user.errors['message'].should =~ /invalid api key/i
|
@@ -50,7 +56,7 @@ describe "Authy::API" do
|
|
50
56
|
response = Authy::API.verify(:token => 'invalid_token', :id => @user.id)
|
51
57
|
|
52
58
|
response.should be_kind_of(Authy::Response)
|
53
|
-
response.
|
59
|
+
response.should_not be_ok
|
54
60
|
response.errors['message'].should == 'Token is invalid.'
|
55
61
|
end
|
56
62
|
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Authy::PhoneIntelligence" do
|
4
|
+
describe "Sending the verification code" do
|
5
|
+
|
6
|
+
it "should send the code via SMS" do
|
7
|
+
response = Authy::PhoneIntelligence.verification_start(
|
8
|
+
:via => "sms",
|
9
|
+
:country_code => "1",
|
10
|
+
:phone_number => "111-111-1111"
|
11
|
+
)
|
12
|
+
|
13
|
+
response.should be_kind_of(Authy::Response)
|
14
|
+
response.should be_ok
|
15
|
+
response.message.should == "Text message sent to +1 111-111-1111."
|
16
|
+
end
|
17
|
+
|
18
|
+
# it "should send the code via CALL" do
|
19
|
+
# response = Authy::PhoneIntelligence.verification_start(
|
20
|
+
# :via => "call",
|
21
|
+
# :country_code => "1",
|
22
|
+
# :phone_number => "111-111-1111"
|
23
|
+
# )
|
24
|
+
|
25
|
+
# response.should be_kind_of(Authy::Response)
|
26
|
+
# response.success.should be_true
|
27
|
+
# response.message.should == "Text message sent to +1 111-111-1111."
|
28
|
+
# end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "validate the fields required" do
|
32
|
+
it "should return an error. Country code is required" do
|
33
|
+
response = Authy::PhoneIntelligence.verification_start(
|
34
|
+
:via => "sms",
|
35
|
+
:phone_number => "111-111-1111"
|
36
|
+
)
|
37
|
+
|
38
|
+
response.should_not be_ok
|
39
|
+
response.errors['message'] =~ /Country code is mandatory/
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return an error. Cellphone is invalid" do
|
43
|
+
response = Authy::PhoneIntelligence.verification_start(
|
44
|
+
:via => "sms",
|
45
|
+
:country_code => "1",
|
46
|
+
:phone_number => "123"
|
47
|
+
)
|
48
|
+
|
49
|
+
response.should_not be_ok
|
50
|
+
response.errors['message'] =~ /Phone number is invalid/
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "Check the verification code" do
|
55
|
+
it "should return success true if code is correct" do
|
56
|
+
response = Authy::PhoneIntelligence.verification_check(
|
57
|
+
:country_code => "1",
|
58
|
+
:phone_number => "111-111-1111",
|
59
|
+
:verification_code => "0000"
|
60
|
+
)
|
61
|
+
|
62
|
+
response.should be_ok
|
63
|
+
response.message.should == "Verification code is correct."
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should return an error if code is incorrect" do
|
67
|
+
response = Authy::PhoneIntelligence.verification_check(
|
68
|
+
:country_code => "1",
|
69
|
+
:phone_number => "111-111-1111",
|
70
|
+
:verification_code => "1234"
|
71
|
+
)
|
72
|
+
|
73
|
+
response.should_not be_ok
|
74
|
+
response.message.should == "Verification code is incorrect."
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "Requesting phone number information" do
|
79
|
+
it "should return the phone information" do
|
80
|
+
response = Authy::PhoneIntelligence.info(
|
81
|
+
:country_code => "1",
|
82
|
+
:phone_number => "7754615609"
|
83
|
+
)
|
84
|
+
|
85
|
+
response.should be_ok
|
86
|
+
response.message.should =~ /Phone number information as of/
|
87
|
+
response.type.should == "voip"
|
88
|
+
response.provider.should == "Google Voice"
|
89
|
+
response.ported.should be_false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/spec/authy/response_spec.rb
CHANGED
@@ -14,11 +14,11 @@ describe "Authy::Response" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should be ok if the return code is 200" do
|
17
|
-
@response.
|
17
|
+
@response.should be_ok
|
18
18
|
|
19
19
|
@fake_response.status = 401
|
20
20
|
@response = Authy::Response.new(@fake_response)
|
21
|
-
@response.
|
21
|
+
@response.should_not be_ok
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should return the error message" do
|
metadata
CHANGED
@@ -1,142 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 2.3.1
|
4
|
+
version: 2.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Authy Inc
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
prerelease: false
|
16
|
-
type: :runtime
|
17
|
-
version_requirements: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
|
-
requirements:
|
20
|
-
- - ! '>='
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 2.3.4
|
23
14
|
name: httpclient
|
24
15
|
requirement: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
16
|
requirements:
|
27
|
-
- -
|
17
|
+
- - ">="
|
28
18
|
- !ruby/object:Gem::Version
|
29
19
|
version: 2.3.4
|
30
|
-
|
20
|
+
type: :runtime
|
31
21
|
prerelease: false
|
32
|
-
type: :development
|
33
22
|
version_requirements: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
23
|
requirements:
|
36
|
-
- -
|
24
|
+
- - ">="
|
37
25
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
26
|
+
version: 2.3.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
39
28
|
name: rake
|
40
29
|
requirement: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
30
|
requirements:
|
43
|
-
- -
|
31
|
+
- - ">="
|
44
32
|
- !ruby/object:Gem::Version
|
45
33
|
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
prerelease: false
|
48
34
|
type: :development
|
35
|
+
prerelease: false
|
49
36
|
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
55
42
|
name: rspec
|
56
43
|
requirement: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
44
|
requirements:
|
59
|
-
- -
|
45
|
+
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
47
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
prerelease: false
|
64
48
|
type: :development
|
49
|
+
prerelease: false
|
65
50
|
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
51
|
requirements:
|
68
|
-
- -
|
52
|
+
- - ">="
|
69
53
|
- !ruby/object:Gem::Version
|
70
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
71
56
|
name: pry
|
72
57
|
requirement: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
58
|
requirements:
|
75
|
-
- -
|
59
|
+
- - ">="
|
76
60
|
- !ruby/object:Gem::Version
|
77
61
|
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
prerelease: false
|
80
62
|
type: :development
|
63
|
+
prerelease: false
|
81
64
|
version_requirements: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
65
|
requirements:
|
84
|
-
- -
|
66
|
+
- - ">="
|
85
67
|
- !ruby/object:Gem::Version
|
86
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
87
70
|
name: yard
|
88
71
|
requirement: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
72
|
requirements:
|
91
|
-
- -
|
73
|
+
- - ">="
|
92
74
|
- !ruby/object:Gem::Version
|
93
75
|
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
prerelease: false
|
96
76
|
type: :development
|
77
|
+
prerelease: false
|
97
78
|
version_requirements: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
79
|
requirements:
|
100
|
-
- -
|
80
|
+
- - ">="
|
101
81
|
- !ruby/object:Gem::Version
|
102
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
103
84
|
name: rdoc
|
104
85
|
requirement: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
86
|
requirements:
|
107
|
-
- -
|
87
|
+
- - ">="
|
108
88
|
- !ruby/object:Gem::Version
|
109
89
|
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
prerelease: false
|
112
90
|
type: :development
|
91
|
+
prerelease: false
|
113
92
|
version_requirements: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
93
|
requirements:
|
116
|
-
- -
|
94
|
+
- - ">="
|
117
95
|
- !ruby/object:Gem::Version
|
118
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
119
98
|
name: simplecov
|
120
99
|
requirement: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
100
|
requirements:
|
123
|
-
- -
|
101
|
+
- - ">="
|
124
102
|
- !ruby/object:Gem::Version
|
125
103
|
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
prerelease: false
|
128
104
|
type: :development
|
105
|
+
prerelease: false
|
129
106
|
version_requirements: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
107
|
requirements:
|
132
|
-
- -
|
108
|
+
- - ">="
|
133
109
|
- !ruby/object:Gem::Version
|
134
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
135
112
|
name: reek
|
136
113
|
requirement: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
114
|
requirements:
|
139
|
-
- -
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
description: Ruby library to access Authy services
|
@@ -147,9 +130,9 @@ executables:
|
|
147
130
|
extensions: []
|
148
131
|
extra_rdoc_files: []
|
149
132
|
files:
|
150
|
-
- .document
|
151
|
-
- .gitignore
|
152
|
-
- .rspec
|
133
|
+
- ".document"
|
134
|
+
- ".gitignore"
|
135
|
+
- ".rspec"
|
153
136
|
- Gemfile
|
154
137
|
- LICENSE.txt
|
155
138
|
- README.md
|
@@ -163,40 +146,42 @@ files:
|
|
163
146
|
- lib/authy/config.rb
|
164
147
|
- lib/authy/core_ext.rb
|
165
148
|
- lib/authy/models/user.rb
|
149
|
+
- lib/authy/phone_intelligence.rb
|
166
150
|
- lib/authy/response.rb
|
167
151
|
- lib/authy/url_helpers.rb
|
168
152
|
- lib/authy/version.rb
|
169
153
|
- spec/authy/api_spec.rb
|
154
|
+
- spec/authy/phone_intelligence_spec.rb
|
170
155
|
- spec/authy/response_spec.rb
|
171
156
|
- spec/authy/url_helpers_spec.rb
|
172
157
|
- spec/spec_helper.rb
|
173
158
|
homepage: https://github.com/authy/authy-ruby
|
174
159
|
licenses:
|
175
160
|
- MIT
|
161
|
+
metadata: {}
|
176
162
|
post_install_message:
|
177
163
|
rdoc_options: []
|
178
164
|
require_paths:
|
179
165
|
- lib
|
180
166
|
required_ruby_version: !ruby/object:Gem::Requirement
|
181
|
-
none: false
|
182
167
|
requirements:
|
183
|
-
- -
|
168
|
+
- - ">="
|
184
169
|
- !ruby/object:Gem::Version
|
185
170
|
version: '0'
|
186
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
-
none: false
|
188
172
|
requirements:
|
189
|
-
- -
|
173
|
+
- - ">="
|
190
174
|
- !ruby/object:Gem::Version
|
191
175
|
version: '0'
|
192
176
|
requirements: []
|
193
177
|
rubyforge_project: authy
|
194
|
-
rubygems_version:
|
178
|
+
rubygems_version: 2.2.2
|
195
179
|
signing_key:
|
196
|
-
specification_version:
|
180
|
+
specification_version: 4
|
197
181
|
summary: Ruby library to access Authy services
|
198
182
|
test_files:
|
199
183
|
- spec/authy/api_spec.rb
|
184
|
+
- spec/authy/phone_intelligence_spec.rb
|
200
185
|
- spec/authy/response_spec.rb
|
201
186
|
- spec/authy/url_helpers_spec.rb
|
202
187
|
- spec/spec_helper.rb
|