summaryrefslogtreecommitdiff
path: root/users/test/integration/api
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-12 19:42:00 +0100
committerAzul <azul@leap.se>2012-11-12 19:42:00 +0100
commita0ba5ec9c705a74b86fdb558436fb05103bf88e3 (patch)
tree22e0562166e38eb84dc20c8e7addf3089b3af13c /users/test/integration/api
parent05ea71016fd54a14159c72299c25efbdc2f177bc (diff)
parentfe8b49232d31681667badaaeff7aa4d0a40445ea (diff)
Merge branch 'develop' into feature-client-side-validations
Conflicts: Gemfile.lock
Diffstat (limited to 'users/test/integration/api')
-rw-r--r--users/test/integration/api/account_flow_test.rb32
1 files changed, 23 insertions, 9 deletions
diff --git a/users/test/integration/api/account_flow_test.rb b/users/test/integration/api/account_flow_test.rb
index 5800d46..c9a7109 100644
--- a/users/test/integration/api/account_flow_test.rb
+++ b/users/test/integration/api/account_flow_test.rb
@@ -1,12 +1,26 @@
require 'test_helper'
-class AccountFlowTest < ActionDispatch::IntegrationTest
+CONFIG_RU = (Rails.root + 'config.ru').to_s
+OUTER_APP = Rack::Builder.parse_file(CONFIG_RU).first
+
+class AccountFlowTest < ActiveSupport::TestCase
+ include Rack::Test::Methods
+ include Warden::Test::Helpers
+ include LeapWebCore::AssertResponses
+
+ def app
+ OUTER_APP
+ end
+
+ def teardown
+ Warden.test_reset!
+ end
# this test wraps the api and implements the interface the ruby-srp client.
def handshake(login, aa)
- post "sessions", :login => login, 'A' => aa.to_s(16)
- assert_response :success
- response = JSON.parse(@response.body)
+ post "/sessions.json", :login => login, 'A' => aa.to_s(16), :format => :json
+ assert last_response.successful?
+ response = JSON.parse(last_response.body)
if response['errors']
raise RECORD_NOT_FOUND.new(response['errors'])
else
@@ -15,9 +29,9 @@ class AccountFlowTest < ActionDispatch::IntegrationTest
end
def validate(m)
- put "sessions/" + @login, :client_auth => m.to_s(16)
- assert_response :success
- return JSON.parse(@response.body)
+ put "/sessions/" + @login + '.json', :client_auth => m.to_s(16), :format => :json
+ assert last_response.successful?
+ return JSON.parse(last_response.body)
end
def setup
@@ -40,7 +54,7 @@ class AccountFlowTest < ActionDispatch::IntegrationTest
test "signup response" do
assert_json_response :login => @login, :ok => true
- assert_response :success
+ assert last_response.successful?
end
test "signup and login with srp via api" do
@@ -52,7 +66,7 @@ class AccountFlowTest < ActionDispatch::IntegrationTest
test "signup and wrong password login attempt" do
srp = SRP::Client.new(@login, "wrong password")
server_auth = srp.authenticate(self)
- assert_equal ["wrong password"], server_auth["errors"]['password']
+ assert_equal "Could not log in", server_auth["errors"]['password']
assert_nil server_auth["M2"]
end