diff options
author | jessib <jessib@riseup.net> | 2013-04-08 11:04:01 -0700 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2013-04-08 11:04:01 -0700 |
commit | 176845b45f6982b0bf26aa69e7432562eed97c69 (patch) | |
tree | 1dd74d5afcdb8cfb96588937eda612b37449923c /users/test/integration | |
parent | 602229c463c58be9ffb909570155d14d59f6b4d5 (diff) | |
parent | 654ab25fa4659119d5ddaa9ae116fce69a386ab1 (diff) |
Merge pull request #41 from azul/feature/allow-getting-salt
Allow getting salt and proper error messages for invalid login attempts
Diffstat (limited to 'users/test/integration')
-rw-r--r-- | users/test/integration/api/account_flow_test.rb | 23 | ||||
-rw-r--r-- | users/test/integration/api/login_test.rb | 16 | ||||
-rw-r--r-- | users/test/integration/api/rack_test.rb | 12 |
3 files changed, 36 insertions, 15 deletions
diff --git a/users/test/integration/api/account_flow_test.rb b/users/test/integration/api/account_flow_test.rb index e618541..1698105 100644 --- a/users/test/integration/api/account_flow_test.rb +++ b/users/test/integration/api/account_flow_test.rb @@ -1,18 +1,9 @@ require 'test_helper' +require_relative 'rack_test' -CONFIG_RU = (Rails.root + 'config.ru').to_s -OUTER_APP = Rack::Builder.parse_file(CONFIG_RU).first +class AccountFlowTest < RackTest -class AccountFlowTest < ActiveSupport::TestCase - include Rack::Test::Methods - include Warden::Test::Helpers - include LeapWebCore::AssertResponses - - def app - OUTER_APP - end - - def setup + setup do @login = "integration_test_user" User.find_by_login(@login).tap{|u| u.destroy if u} @password = "srp, verify me!" @@ -26,7 +17,7 @@ class AccountFlowTest < ActiveSupport::TestCase @user = User.find_by_login(@login) end - def teardown + teardown do @user.destroy if @user Warden.test_reset! end @@ -75,7 +66,8 @@ class AccountFlowTest < ActiveSupport::TestCase test "signup and wrong password login attempt" do srp = SRP::Client.new @login, :password => "wrong password" server_auth = srp.authenticate(self) - assert_json_error({:login => "Not a valid username/password combination", :password => "Not a valid username/password combination"}) + assert_json_error login: "Not a valid username/password combination", + password: "Not a valid username/password combination" assert !last_response.successful? assert_nil server_auth["M2"] end @@ -86,7 +78,8 @@ class AccountFlowTest < ActiveSupport::TestCase assert_raises RECORD_NOT_FOUND do server_auth = srp.authenticate(self) end - assert_json_error({:login => "Not a valid username/password combination", :password => "Not a valid username/password combination"}) + assert_json_error login: "Not a valid username/password combination", + password: "Not a valid username/password combination" assert !last_response.successful? assert_nil server_auth end diff --git a/users/test/integration/api/login_test.rb b/users/test/integration/api/login_test.rb new file mode 100644 index 0000000..fb761e5 --- /dev/null +++ b/users/test/integration/api/login_test.rb @@ -0,0 +1,16 @@ +require 'test_helper' +require_relative 'rack_test' + +class AccountFlowTest < RackTest + + setup do + @login = "integration_test_user" + end + + test "require json requests" do + put "http://api.lvh.me:3000/1/sessions/" + @login, + :client_auth => "This is not a valid login anyway" + assert_json_error login: I18n.t(:all_strategies_failed) + end + +end diff --git a/users/test/integration/api/rack_test.rb b/users/test/integration/api/rack_test.rb new file mode 100644 index 0000000..da960f2 --- /dev/null +++ b/users/test/integration/api/rack_test.rb @@ -0,0 +1,12 @@ +CONFIG_RU = (Rails.root + 'config.ru').to_s +OUTER_APP = Rack::Builder.parse_file(CONFIG_RU).first + +class RackTest < ActiveSupport::TestCase + include Rack::Test::Methods + include Warden::Test::Helpers + include LeapWebCore::AssertResponses + + def app + OUTER_APP + end +end |