summaryrefslogtreecommitdiff
path: root/users/test
diff options
context:
space:
mode:
Diffstat (limited to 'users/test')
-rw-r--r--users/test/functional/sessions_controller_test.rb21
-rw-r--r--users/test/integration/browser/account_test.rb25
2 files changed, 18 insertions, 28 deletions
diff --git a/users/test/functional/sessions_controller_test.rb b/users/test/functional/sessions_controller_test.rb
index b22c3a3..a630e6e 100644
--- a/users/test/functional/sessions_controller_test.rb
+++ b/users/test/functional/sessions_controller_test.rb
@@ -41,27 +41,6 @@ class SessionsControllerTest < ActionController::TestCase
assert_json_error :login => I18n.t(:all_strategies_failed)
end
- # Warden takes care of parsing the params and
- # rendering the response. So not much to test here.
- test "should perform handshake" do
- request.env['warden'].expects(:authenticate!)
- # make sure we don't get a template missing error:
- @controller.stubs(:render)
- post :create, :login => @user.login, 'A' => @client_hex
- end
-
- test "should authorize" do
- request.env['warden'].expects(:authenticate!)
- handshake = stub(:to_json => "JSON")
- session[:handshake] = handshake
-
- post :update, :id => @user.login, :client_auth => @client_hex
-
- assert_nil session[:handshake]
- assert_response :success
- assert_json_response handshake
- end
-
test "logout should reset warden user" do
expect_warden_logout
delete :destroy
diff --git a/users/test/integration/browser/account_test.rb b/users/test/integration/browser/account_test.rb
index b412980..f3a78ed 100644
--- a/users/test/integration/browser/account_test.rb
+++ b/users/test/integration/browser/account_test.rb
@@ -7,13 +7,7 @@ class AccountTest < BrowserIntegrationTest
end
test "normal account workflow" do
- username = "test_#{SecureRandom.urlsafe_base64}".downcase
- password = SecureRandom.base64
- visit '/users/new'
- fill_in 'Username', with: username
- fill_in 'Password', with: password
- fill_in 'Password confirmation', with: password
- click_on 'Sign Up'
+ username, password = submit_signup
assert page.has_content?("Welcome #{username}")
click_on 'Logout'
assert page.has_content?("Sign Up")
@@ -32,6 +26,23 @@ class AccountTest < BrowserIntegrationTest
assert page.has_no_content?("Welcome")
end
+ test "reports internal server errors" do
+ V1::UsersController.any_instance.stubs(:create).raises
+ submit_signup
+ assert page.has_content?("server failed")
+ end
+
+ def submit_signup
+ username = "test_#{SecureRandom.urlsafe_base64}".downcase
+ password = SecureRandom.base64
+ visit '/users/new'
+ fill_in 'Username', with: username
+ fill_in 'Password', with: password
+ fill_in 'Password confirmation', with: password
+ click_on 'Sign Up'
+ return username, password
+ end
+
def inject_malicious_js
page.execute_script <<-EOJS
var calc = new srp.Calculate();