authy 2.7.4 → 2.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -2
- data/README.md +1 -1
- data/lib/authy/api.rb +3 -3
- data/lib/authy/config.rb +8 -0
- data/lib/authy/version.rb +1 -1
- data/spec/authy/api_spec.rb +4 -4
- data/spec/authy/config_spec.rb +21 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47e8f178518a9d550bc75f55f17ec06e1e984634977ed408db47a74916851300
|
4
|
+
data.tar.gz: 72c729ad9b44a3119aad7455c93d1029104b55c5099d3b7a358a2f80f2b73470
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3e7f285b4b0f7e4ff5b0522726a0def7fdcc77df18b9214bc7e0434cdc8bc5fee6cfcc47149662c0d86935420cd67386d9d4eb5ac774721410150a9f85caf94
|
7
|
+
data.tar.gz: 00b0af3f2d778f1ed2d9c4424c7563ba8ac27718ad8164fe00283d0336f05f8238f5971b375eceecf64cb2de18f837d5e18e32d479b5372cbbbdb1545e7e38c1
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Authy [![Build Status](https://travis-ci.org/
|
1
|
+
# Authy [![Build Status](https://travis-ci.org/twilio/authy-ruby.png?branch=master)](https://travis-ci.org/twilio/authy-ruby) [![Code Climate](https://codeclimate.com/github/authy/authy-ruby.png)](https://codeclimate.com/github/authy/authy-ruby)
|
2
2
|
|
3
3
|
Ruby library to access the Authy API
|
4
4
|
|
data/lib/authy/api.rb
CHANGED
@@ -8,14 +8,13 @@ module Authy
|
|
8
8
|
# Authy.api_uri = 'http://test-authy-api.heroku.com/'
|
9
9
|
#
|
10
10
|
class API
|
11
|
-
USER_AGENT = "AuthyRuby/#{Authy::VERSION} (#{RUBY_PLATFORM}, Ruby #{RUBY_VERSION})"
|
12
11
|
MIN_TOKEN_SIZE = 6
|
13
12
|
MAX_TOKEN_SIZE = 12
|
14
13
|
|
15
14
|
include Authy::URL
|
16
15
|
|
17
16
|
extend HTTPClient::IncludeClient
|
18
|
-
include_http_client
|
17
|
+
include_http_client
|
19
18
|
|
20
19
|
def self.register_user(attributes)
|
21
20
|
api_key = attributes.delete(:api_key) || Authy.api_key
|
@@ -172,7 +171,8 @@ module Authy
|
|
172
171
|
|
173
172
|
def self.default_header(api_key: nil, params: {})
|
174
173
|
header = {
|
175
|
-
"X-Authy-API-Key" => api_key || Authy.api_key
|
174
|
+
"X-Authy-API-Key" => api_key || Authy.api_key,
|
175
|
+
"User-Agent" => Authy.user_agent
|
176
176
|
}
|
177
177
|
|
178
178
|
api_key_ = params.delete(:api_key) || params.delete("api_key")
|
data/lib/authy/config.rb
CHANGED
@@ -17,5 +17,13 @@ module Authy
|
|
17
17
|
@api_uri || "https://api.authy.com"
|
18
18
|
end
|
19
19
|
alias :api_url :api_uri
|
20
|
+
|
21
|
+
def user_agent
|
22
|
+
@user_agent || "AuthyRuby/#{Authy::VERSION} (#{RUBY_PLATFORM}, Ruby #{RUBY_VERSION})"
|
23
|
+
end
|
24
|
+
|
25
|
+
def user_agent=(user_agent)
|
26
|
+
@user_agent = user_agent
|
27
|
+
end
|
20
28
|
end
|
21
29
|
end
|
data/lib/authy/version.rb
CHANGED
data/spec/authy/api_spec.rb
CHANGED
@@ -2,8 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Authy::API" do
|
4
4
|
describe "request headers" do
|
5
|
-
it "contains api key in header" do
|
6
|
-
expect_any_instance_of(HTTPClient).to receive(:request).twice.with(
|
5
|
+
it "contains api key and user agent in header" do
|
6
|
+
expect_any_instance_of(HTTPClient).to receive(:request).twice.with(any_args, hash_including(header: { "X-Authy-API-Key" => Authy.api_key, "User-Agent" => "AuthyRuby/#{Authy::VERSION} (#{RUBY_PLATFORM}, Ruby #{RUBY_VERSION})" }) ) { double(ok?: true, body: "", status: 200) }
|
7
7
|
|
8
8
|
url = "protected/json/foo/2"
|
9
9
|
Authy::API.get_request(url, {})
|
@@ -129,7 +129,7 @@ describe "Authy::API" do
|
|
129
129
|
|
130
130
|
it "should request qrcode" do
|
131
131
|
url = "#{Authy.api_uri}/protected/json/users/#{Authy::API.escape_for_url(@user.id)}/secret"
|
132
|
-
expect_any_instance_of(HTTPClient).to receive(:request).with(:post, url, body: "qr_size=300&label=example+app+name", header: {"X-Authy-API-Key" => Authy.api_key}) { double(ok?: true, body: "", status: 200) }
|
132
|
+
expect_any_instance_of(HTTPClient).to receive(:request).with(:post, url, body: "qr_size=300&label=example+app+name", header: {"X-Authy-API-Key" => Authy.api_key, "User-Agent" => "AuthyRuby/#{Authy::VERSION} (#{RUBY_PLATFORM}, Ruby #{RUBY_VERSION})"}) { double(ok?: true, body: "", status: 200) }
|
133
133
|
response = Authy::API.send("request_qr_code", id: @user.id, qr_size: 300, qr_label: "example app name")
|
134
134
|
expect(response).to be_ok
|
135
135
|
end
|
@@ -163,7 +163,7 @@ describe "Authy::API" do
|
|
163
163
|
it "should request a #{title} token" do
|
164
164
|
uri_param = kind == "phone_call" ? "call" : kind
|
165
165
|
url = "#{Authy.api_uri}/protected/json/#{uri_param}/#{Authy::API.escape_for_url(@user.id)}"
|
166
|
-
expect_any_instance_of(HTTPClient).to receive(:request).with(:get, url, {query:{}, header:{ "X-Authy-API-Key" => Authy.api_key }, follow_redirect:nil}) { double(ok?: true, body: "", status: 200) }
|
166
|
+
expect_any_instance_of(HTTPClient).to receive(:request).with(:get, url, {query:{}, header:{ "X-Authy-API-Key" => Authy.api_key, "User-Agent" => "AuthyRuby/#{Authy::VERSION} (#{RUBY_PLATFORM}, Ruby #{RUBY_VERSION})" }, follow_redirect:nil}) { double(ok?: true, body: "", status: 200) }
|
167
167
|
response = Authy::API.send("request_#{kind}", id: @user.id)
|
168
168
|
expect(response).to be_ok
|
169
169
|
end
|
data/spec/authy/config_spec.rb
CHANGED
@@ -12,7 +12,6 @@ describe 'Authy' do
|
|
12
12
|
Authy.api_key = @default_api_key
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
15
|
it "should set and read instance variable" do
|
17
16
|
Authy.api_key = 'foo'
|
18
17
|
expect(Authy.api_key).to eq 'foo'
|
@@ -44,4 +43,25 @@ describe 'Authy' do
|
|
44
43
|
expect(Authy.api_url).to eq 'https://api.authy.com'
|
45
44
|
end
|
46
45
|
end
|
46
|
+
|
47
|
+
describe "user_agent" do
|
48
|
+
before do
|
49
|
+
@default_user_agent = Authy.user_agent
|
50
|
+
Authy.user_agent = nil
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
Authy.user_agent = @default_user_agent
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set and read instance variable" do
|
58
|
+
Authy.user_agent = 'AuthyRuby NewUserAgent'
|
59
|
+
expect(Authy.user_agent).to eq 'AuthyRuby NewUserAgent'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should fallback to default value" do
|
63
|
+
Authy.user_agent = nil
|
64
|
+
expect(Authy.user_agent).to eq "AuthyRuby/#{Authy::VERSION} (#{RUBY_PLATFORM}, Ruby #{RUBY_VERSION})"
|
65
|
+
end
|
66
|
+
end
|
47
67
|
end
|
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.7.
|
4
|
+
version: 2.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Authy Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -182,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '0'
|
184
184
|
requirements: []
|
185
|
-
|
186
|
-
rubygems_version: 2.7.6
|
185
|
+
rubygems_version: 3.0.2
|
187
186
|
signing_key:
|
188
187
|
specification_version: 4
|
189
188
|
summary: Ruby library to access Authy services
|