authy 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "authy"
8
- s.version = "0.1.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Authy", "David A. Cuadrado"]
12
- s.date = "2013-01-24"
12
+ s.date = "2013-02-04"
13
13
  s.description = "Ruby library to access Authy services"
14
14
  s.email = "krawek@gmail.com"
15
15
  s.executables = ["authy-api-console"]
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'pry'
3
4
  require 'bundler/setup'
4
5
  Bundler.require
5
6
 
@@ -30,6 +30,7 @@ module Authy
30
30
  def self.verify(params)
31
31
  token = params.delete(:token) || params.delete('token')
32
32
  user_id = params.delete(:id) || params.delete('id')
33
+ params[:force] = true if params[:force].nil? && params['force'].nil?
33
34
 
34
35
  url = "#{Authy.api_uri}/protected/json/verify/#{escape_for_url(token)}/#{escape_for_url(user_id)}"
35
36
  response = http_client.get(url, {:api_key => Authy.api_key}.merge(params))
@@ -4,7 +4,9 @@ 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(:email => generate_email, :cellphone => generate_cellphone, :country_code => 1)
7
+ user = Authy::API.register_user(:email => generate_email,
8
+ :cellphone => generate_cellphone,
9
+ :country_code => 1)
8
10
  user.should be_kind_of(Authy::Response)
9
11
 
10
12
  user.should be_kind_of(Authy::User)
@@ -14,14 +16,19 @@ describe "Authy::API" do
14
16
  end
15
17
 
16
18
  it "should return the error messages as a hash" do
17
- user = Authy::API.register_user(:email => generate_email, :cellphone => "abc-1234", :country_code => 1)
19
+ user = Authy::API.register_user(:email => generate_email,
20
+ :cellphone => "abc-1234",
21
+ :country_code => 1)
18
22
 
19
23
  user.errors.should be_kind_of(Hash)
20
24
  user.errors['cellphone'].should == 'must be a valid cellphone number.'
21
25
  end
22
26
 
23
27
  it "should allow to override the API key" do
24
- user = Authy::API.register_user(:email => generate_email, :cellphone => generate_cellphone, :country_code => 1, :api_key => "invalid_api_key")
28
+ user = Authy::API.register_user(:email => generate_email,
29
+ :cellphone => generate_cellphone,
30
+ :country_code => 1,
31
+ :api_key => "invalid_api_key")
25
32
 
26
33
  user.should_not be_ok
27
34
  user.errors['message'].should =~ /invalid api key/i
@@ -30,19 +37,22 @@ describe "Authy::API" do
30
37
 
31
38
  describe "verificating tokens" do
32
39
  before do
33
- @user = Authy::API.register_user(:email => generate_email, :cellphone => generate_cellphone, :country_code => 1)
40
+ @user = Authy::API.register_user(:email => generate_email,
41
+ :cellphone => generate_cellphone,
42
+ :country_code => 1)
34
43
  @user.should be_ok
35
44
  end
36
45
 
37
- it "should validate a given token if the user is not registered when the verification is not forced" do
38
- response = Authy::API.verify(:token => 'invalid_token', :id => @user['id'])
46
+ #it "should validate a given token if the user is not registered when the verification is not forced" do
47
+ #pending "Sandbox api always auto-confirm all users so there's no way check this atm"
48
+ #response = Authy::API.verify(:token => 'invalid_token', :id => @user['id'], :force => false)
39
49
 
40
- response.should be_kind_of(Authy::Response)
41
- response.ok?.should be_true
42
- end
50
+ #response.should be_kind_of(Authy::Response)
51
+ #response.ok?.should be_true
52
+ #end
43
53
 
44
- it "should fail to validate a given token if the user is not registered when force=true is given" do
45
- response = Authy::API.verify(:token => 'invalid_token', :id => @user['id'], :force => true)
54
+ it "should fail to validate a given token if the user is not registered" do
55
+ response = Authy::API.verify(:token => 'invalid_token', :id => @user['id'])
46
56
 
47
57
  response.should be_kind_of(Authy::Response)
48
58
  response.ok?.should be_false
@@ -50,7 +60,7 @@ describe "Authy::API" do
50
60
  end
51
61
 
52
62
  it "should allow to override the API key" do
53
- response = Authy::API.verify(:token => 'invalid_token', :id => @user['id'], :force => true, :api_key => "invalid_api_key")
63
+ response = Authy::API.verify(:token => 'invalid_token', :id => @user['id'], :api_key => "invalid_api_key")
54
64
 
55
65
  response.should_not be_ok
56
66
  response.errors['message'].should =~ /invalid api key/i
@@ -11,8 +11,8 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
11
 
12
12
  RSpec.configure do |config|
13
13
  config.before(:suite) do
14
- Authy.api_uri = 'http://localhost:4567'
15
- Authy.api_key = 'testing_ruby_api_key'
14
+ Authy.api_uri = 'http://sandbox-api.authy.com'
15
+ Authy.api_key = 'bf12974d70818a08199d17d5e2bae630'
16
16
  end
17
17
 
18
18
  config.before(:each) do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: authy
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Authy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-24 00:00:00.000000000 Z
13
+ date: 2013-02-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  version_requirements: !ruby/object:Gem::Requirement
@@ -182,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
182
  - !ruby/object:Gem::Version
183
183
  segments:
184
184
  - 0
185
- hash: -14009376793020186
185
+ hash: -2890998156297207065
186
186
  version: '0'
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  none: false