authy 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/authy/api.rb +5 -0
- data/lib/authy/version.rb +1 -1
- data/spec/authy/api_spec.rb +32 -7
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.1
|
data/lib/authy/api.rb
CHANGED
@@ -66,6 +66,11 @@ module Authy
|
|
66
66
|
post_request("protected/json/users/delete/:user_id", params.merge({"user_id" =>user_id}))
|
67
67
|
end
|
68
68
|
|
69
|
+
def self.user_status(params)
|
70
|
+
user_id = params.delete(:id) || params.delete("id")
|
71
|
+
get_request("protected/json/users/:user_id/status", params.merge({"user_id" => user_id}))
|
72
|
+
end
|
73
|
+
|
69
74
|
private
|
70
75
|
|
71
76
|
def self.post_request(uri, params = {})
|
data/lib/authy/version.rb
CHANGED
data/spec/authy/api_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe "Authy::API" do
|
|
21
21
|
:country_code => 1)
|
22
22
|
|
23
23
|
user.errors.should be_kind_of(Hash)
|
24
|
-
user.errors['cellphone'].should == '
|
24
|
+
user.errors['cellphone'].should == 'is invalid'
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should allow to override the API key" do
|
@@ -38,18 +38,20 @@ describe "Authy::API" do
|
|
38
38
|
|
39
39
|
describe "verificating tokens" do
|
40
40
|
before do
|
41
|
-
@
|
42
|
-
|
41
|
+
@email = generate_email
|
42
|
+
@cellphone = generate_cellphone
|
43
|
+
@user = Authy::API.register_user(:email => @email,
|
44
|
+
:cellphone => @cellphone,
|
43
45
|
:country_code => 1)
|
44
46
|
@user.should be_ok
|
45
47
|
end
|
46
48
|
|
47
49
|
it "should fail to validate a given token if the user is not registered" do
|
48
|
-
response = Authy::API.verify(:token => 'invalid_token', :id => @user
|
50
|
+
response = Authy::API.verify(:token => 'invalid_token', :id => @user.id)
|
49
51
|
|
50
52
|
response.should be_kind_of(Authy::Response)
|
51
53
|
response.ok?.should be_false
|
52
|
-
response.errors['message'].should == '
|
54
|
+
response.errors['message'].should == 'Token is invalid.'
|
53
55
|
end
|
54
56
|
|
55
57
|
it "should allow to override the API key" do
|
@@ -98,7 +100,7 @@ describe "Authy::API" do
|
|
98
100
|
context "user doesn't exist" do
|
99
101
|
it "should not be ok" do
|
100
102
|
response = Authy::API.send("request_#{kind}", :id => "tony")
|
101
|
-
response.errors['message'].should == "User
|
103
|
+
response.errors['message'].should == "User not found."
|
102
104
|
response.should_not be_ok
|
103
105
|
end
|
104
106
|
end
|
@@ -110,7 +112,7 @@ describe "Authy::API" do
|
|
110
112
|
context "user doesn't exist" do
|
111
113
|
it "should not be ok" do
|
112
114
|
response = Authy::API.delete_user(:id => "tony")
|
113
|
-
response.errors['message'].should == "User
|
115
|
+
response.errors['message'].should == "User not found."
|
114
116
|
response.should_not be_ok
|
115
117
|
end
|
116
118
|
end
|
@@ -129,6 +131,29 @@ describe "Authy::API" do
|
|
129
131
|
end
|
130
132
|
end
|
131
133
|
|
134
|
+
describe "user status" do
|
135
|
+
context "user doesn't exist" do
|
136
|
+
it "should not be ok" do
|
137
|
+
response = Authy::API.user_status(:id => "tony")
|
138
|
+
response.errors["message"].should == "User not found."
|
139
|
+
response.should_not be_ok
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "user exists" do
|
144
|
+
before do
|
145
|
+
@user = Authy::API.register_user(:email => generate_email, :cellphone => generate_cellphone, :country_code => 1)
|
146
|
+
@user.should be_ok
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should be ok" do
|
150
|
+
response = Authy::API.user_status(:id => @user.id)
|
151
|
+
response.status.should be_kind_of(Hash)
|
152
|
+
response.should be_ok
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
132
157
|
describe "blank params" do
|
133
158
|
before do
|
134
159
|
@user = Authy::API.register_user(:email => generate_email, :cellphone => generate_cellphone, :country_code => 1)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: authy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.3.
|
5
|
+
version: 2.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Authy Inc
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|