authy 2.4.0 → 2.4.1

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
  SHA1:
3
- metadata.gz: 81735aedc17dacda72bd8f831b306961e07cdf2c
4
- data.tar.gz: c49d07082ce397c88b41b8746d5ec3a73e3040d3
3
+ metadata.gz: d74edf29538ab74b640b9d840ca2427c1ce3962e
4
+ data.tar.gz: 09863c91aaf19dff2199a5b664efbb296a0e5286
5
5
  SHA512:
6
- metadata.gz: 73266d8be9764af02b6f269365c0f7452722d32ef745bb308da4294911e3397e79485113a95f1a266b79a1f22951bf93ed9eece1f94e6828523ba3b607e6bfda
7
- data.tar.gz: e785fb4a38699607e64b7c8f31c054348033275114a02f9ed88ef5395adda34f46768626b417b285abb45c454a4a4e32d02632c7d37df45340aded4c414b229d
6
+ metadata.gz: 4bf749b8b377b812e3e970f4eadbec0a83fff06e306a25f02da41344e795061646b7fd7c8d6fbdee530b047469066cfd01f3085ce0f97cde55197a9c571fb6fb
7
+ data.tar.gz: eb30e6c90600f610c21ae4565b9204b7afeecb4698f51224d5d373377f8e954d2699663d87af0a836dd7222e8ec088df8ad06c7313399076c03bbd06be8b3745
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'httpclient', ">= 2.3.4"
3
+ gem 'httpclient', ">= 2.5.3.3"
4
4
 
5
5
  group :development do
6
6
  gem "rspec"
data/README.md CHANGED
@@ -11,6 +11,8 @@ Ruby library to access the Authy API
11
11
  Authy.api_uri = 'https://api.authy.com/'
12
12
  ```
13
13
 
14
+ Using Ruby on Rails? _Put this in **config/initializers** and create a new file called **authy.rb**._
15
+
14
16
  ## Registering a user
15
17
 
16
18
  __NOTE: User is matched based on cellphone and country code not e-mail.
@@ -117,6 +119,21 @@ This call will be ignored if the user is using the Authy Mobile App. If you ensu
117
119
  end
118
120
  ```
119
121
 
122
+ ## User status
123
+
124
+ `Authy::API.user_status` takes the authy_id of the user that you want to get the status from your app.
125
+
126
+ ```ruby
127
+ response = Authy::API.user_status(:id => user.authy_id)
128
+
129
+ if response.ok?
130
+ # do something with user status
131
+ else
132
+ response.errors
133
+ # the user doesn't exist
134
+ end
135
+ ```
136
+
120
137
  ### Contributing to authy
121
138
 
122
139
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.0
1
+ 2.4.1
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency('httpclient', '>= 2.3.4')
23
+ s.add_dependency('httpclient', '>= 2.5.3.3')
24
24
 
25
25
  s.add_development_dependency('rake')
26
26
  s.add_development_dependency('rspec')
@@ -95,7 +95,7 @@ module Authy
95
95
  response = if state
96
96
  url = "#{Authy.api_uri}/#{eval_uri(uri, params)}"
97
97
  params = clean_uri_params(uri_params, params)
98
- http_client.get(url, escape_params({:api_key => Authy.api_key}.merge(params)))
98
+ http_client.get(url, {:api_key => Authy.api_key}.merge(params))
99
99
  else
100
100
  build_error_response(error)
101
101
  end
@@ -5,7 +5,7 @@ module Authy
5
5
  end
6
6
 
7
7
  def api_key
8
- @api_key
8
+ @api_key || ENV["AUTHY_API_KEY"]
9
9
  end
10
10
 
11
11
  def api_uri=(uri)
@@ -1,3 +1,3 @@
1
1
  module Authy
2
- VERSION = "2.4.0"
2
+ VERSION = "2.4.1"
3
3
  end
@@ -56,7 +56,7 @@ describe "Authy::API" do
56
56
  response = Authy::API.verify(:token => 'invalid_token', :id => @user.id)
57
57
 
58
58
  response.should be_kind_of(Authy::Response)
59
- response.should_not be_ok
59
+ response.ok?.should be_falsey
60
60
  response.errors['message'].should == 'Token is invalid.'
61
61
  end
62
62
 
@@ -73,6 +73,12 @@ describe "Authy::API" do
73
73
  }.to_not raise_error
74
74
  end
75
75
 
76
+ it "should escape the params if have white spaces" do
77
+ expect {
78
+ Authy::API.verify(:token => "token with space", :id => @user['id'])
79
+ }.to_not raise_error
80
+ end
81
+
76
82
  it "should fail if a param is missing" do
77
83
  response = Authy::API.verify(:id => @user['id'])
78
84
  response.should be_kind_of(Authy::Response)
@@ -103,6 +109,11 @@ describe "Authy::API" do
103
109
  response.errors['message'].should =~ /invalid api key/i
104
110
  end
105
111
 
112
+ it "should request a #{title} token using custom actions" do
113
+ response = Authy::API.send("request_#{kind}", id: @user.id, action: "custom action?", action_message: "Action message $%^?@#")
114
+ response.should be_ok
115
+ end
116
+
106
117
  context "user doesn't exist" do
107
118
  it "should not be ok" do
108
119
  response = Authy::API.send("request_#{kind}", :id => "tony")
@@ -110,7 +121,6 @@ describe "Authy::API" do
110
121
  response.should_not be_ok
111
122
  end
112
123
  end
113
-
114
124
  end
115
125
  end
116
126
 
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Authy" do
4
+ describe "api_key" do
5
+ before(:each) do
6
+ @default_api_key = Authy.api_key
7
+ Authy.api_key = nil
8
+ ENV["AUTHY_API_KEY"] = nil
9
+ end
10
+
11
+ after(:each) do
12
+ Authy.api_key = @default_api_key
13
+ end
14
+
15
+
16
+ it "should set and read instance variable" do
17
+ Authy.api_key = "foo"
18
+ Authy.api_key.should == "foo"
19
+ end
20
+
21
+ it "should fallback to ENV variable" do
22
+ ENV["AUTHY_API_KEY"] = "bar"
23
+ Authy.api_key.should == "bar"
24
+ end
25
+ end
26
+
27
+ describe "api_url" do
28
+ before(:each) do
29
+ @default_api_url = Authy.api_url
30
+ Authy.api_url = nil
31
+ end
32
+
33
+ after(:each) do
34
+ Authy.api_url = @default_api_url
35
+ end
36
+
37
+ it "should set and read instance variable" do
38
+ Authy.api_url = "https://example.com/"
39
+ Authy.api_url.should == "https://example.com/"
40
+ end
41
+
42
+ it "should fallback to default value" do
43
+ Authy.api_url = nil
44
+ Authy.api_url.should == "https://api.authy.com"
45
+ end
46
+ end
47
+ end
@@ -23,7 +23,7 @@ describe "Authy::PhoneIntelligence" do
23
23
  # )
24
24
 
25
25
  # response.should be_kind_of(Authy::Response)
26
- # response.success.should be_true
26
+ # response.success.should be_truthy
27
27
  # response.message.should == "Text message sent to +1 111-111-1111."
28
28
  # end
29
29
  end
@@ -86,7 +86,7 @@ describe "Authy::PhoneIntelligence" do
86
86
  response.message.should =~ /Phone number information as of/
87
87
  response.type.should == "voip"
88
88
  response.provider.should == "Google Voice"
89
- response.ported.should be_false
89
+ response.ported.should be_falsey
90
90
  end
91
91
  end
92
92
  end
@@ -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.should be_ok
17
+ @response.ok?.should be_truthy
18
18
 
19
19
  @fake_response.status = 401
20
20
  @response = Authy::Response.new(@fake_response)
21
- @response.should_not be_ok
21
+ @response.ok?.should be_falsey
22
22
  end
23
23
 
24
24
  it "should return the error message" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Authy Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-02 00:00:00.000000000 Z
11
+ date: 2015-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.4
19
+ version: 2.5.3.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.4
26
+ version: 2.5.3.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +151,7 @@ files:
151
151
  - lib/authy/url_helpers.rb
152
152
  - lib/authy/version.rb
153
153
  - spec/authy/api_spec.rb
154
+ - spec/authy/config_spec.rb
154
155
  - spec/authy/phone_intelligence_spec.rb
155
156
  - spec/authy/response_spec.rb
156
157
  - spec/authy/url_helpers_spec.rb
@@ -181,6 +182,7 @@ specification_version: 4
181
182
  summary: Ruby library to access Authy services
182
183
  test_files:
183
184
  - spec/authy/api_spec.rb
185
+ - spec/authy/config_spec.rb
184
186
  - spec/authy/phone_intelligence_spec.rb
185
187
  - spec/authy/response_spec.rb
186
188
  - spec/authy/url_helpers_spec.rb