spec/authy/api_spec.rb in authy-2.4.0 vs spec/authy/api_spec.rb in authy-2.4.1
- old
+ new
@@ -54,11 +54,11 @@
it "should fail to validate a given token if the user is not registered" do
response = Authy::API.verify(:token => 'invalid_token', :id => @user.id)
response.should be_kind_of(Authy::Response)
- response.should_not be_ok
+ response.ok?.should be_falsey
response.errors['message'].should == 'Token is invalid.'
end
it "should allow to override the API key" do
response = Authy::API.verify(:token => 'invalid_token', :id => @user['id'], :api_key => "invalid_api_key")
@@ -71,10 +71,16 @@
expect {
Authy::API.verify(:token => '[=#%@$&#(!@);.,', :id => @user['id'])
}.to_not raise_error
end
+ it "should escape the params if have white spaces" do
+ expect {
+ Authy::API.verify(:token => "token with space", :id => @user['id'])
+ }.to_not raise_error
+ end
+
it "should fail if a param is missing" do
response = Authy::API.verify(:id => @user['id'])
response.should be_kind_of(Authy::Response)
response.should_not be_ok
response["message"] =~ /token is blank/
@@ -101,17 +107,21 @@
response = Authy::API.send("request_#{kind}", :id => @user.id, :api_key => "invalid_api_key")
response.should_not be_ok
response.errors['message'].should =~ /invalid api key/i
end
+ it "should request a #{title} token using custom actions" do
+ response = Authy::API.send("request_#{kind}", id: @user.id, action: "custom action?", action_message: "Action message $%^?@#")
+ response.should be_ok
+ end
+
context "user doesn't exist" do
it "should not be ok" do
response = Authy::API.send("request_#{kind}", :id => "tony")
response.errors['message'].should == "User not found."
response.should_not be_ok
end
end
-
end
end
describe "delete users" do
context "user doesn't exist" do