From 59adb0892f443e1fe1bdd4201c4e0db1b036e0af Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 5 Sep 2013 13:12:23 -0700 Subject: Test of failing to add non-local email address as an identity's address. --- users/test/unit/identity_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'users/test') diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb index fa88315..a77613a 100644 --- a/users/test/unit/identity_test.rb +++ b/users/test/unit/identity_test.rb @@ -70,6 +70,13 @@ class IdentityTest < ActiveSupport::TestCase id.destroy end + test "fail to end non-local email address as identity address" do + id = Identity.for @user, address: 'blah@sdlfksjdfljk.com' + assert !id.valid? + assert_match /needs to end in/, id.errors[:address].first + end + + def alias_name @alias_name ||= Faker::Internet.user_name end -- cgit v1.2.3 From 3ef22b5a856e1f576fb0a6a589b6b7ab41e1dd18 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 5 Sep 2013 14:00:50 -0700 Subject: For moment, have identity's address handle aliased from login so we can use LoginFormatValidation. However, this is not how we will want it eventually. One issue is that the errors messages are set on login, rather than the appropriate field. --- users/test/unit/identity_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'users/test') diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb index a77613a..b3918f1 100644 --- a/users/test/unit/identity_test.rb +++ b/users/test/unit/identity_test.rb @@ -76,6 +76,14 @@ class IdentityTest < ActiveSupport::TestCase assert_match /needs to end in/, id.errors[:address].first end + test "only lowercase alias" do + id = Identity.create_for @user, address: alias_name.capitalize + assert !id.valid? + #hacky way to do this, but okay for now: + assert id.errors.messages.flatten(2).include? "Must begin with a lowercase letter" + assert id.errors.messages.flatten(2).include? "Only lowercase letters, digits, . - and _ allowed." + end + def alias_name @alias_name ||= Faker::Internet.user_name -- cgit v1.2.3 From a9c68ba0bbba7a95e9b4a3ff24554d1b0af6cbc5 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 23 Sep 2013 12:23:08 -0700 Subject: This ensures that email addresses contain only lowercase letters, and that an identity's destination is a valid Email. --- users/test/unit/identity_test.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'users/test') diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb index b3918f1..02f14c0 100644 --- a/users/test/unit/identity_test.rb +++ b/users/test/unit/identity_test.rb @@ -70,13 +70,13 @@ class IdentityTest < ActiveSupport::TestCase id.destroy end - test "fail to end non-local email address as identity address" do - id = Identity.for @user, address: 'blah@sdlfksjdfljk.com' + test "fail to add non-local email address as identity address" do + id = Identity.for @user, address: forward_address assert !id.valid? assert_match /needs to end in/, id.errors[:address].first end - test "only lowercase alias" do + test "alias must meet some conditions as login" do id = Identity.create_for @user, address: alias_name.capitalize assert !id.valid? #hacky way to do this, but okay for now: @@ -84,6 +84,17 @@ class IdentityTest < ActiveSupport::TestCase assert id.errors.messages.flatten(2).include? "Only lowercase letters, digits, . - and _ allowed." end + test "destination must be valid email address" do + id = Identity.create_for @user, address: @user.email_address, destination: 'ASKJDLFJD' + assert !id.valid? + assert id.errors.messages[:destination].include? "needs to be a valid email address" + end + + test "only lowercase destination" do + id = Identity.create_for @user, address: @user.email_address, destination: forward_address.capitalize + assert !id.valid? + assert id.errors.messages[:destination].include? "letters must be lowercase" + end def alias_name @alias_name ||= Faker::Internet.user_name -- cgit v1.2.3 From 193bf6446b384dce1699e8fb82be6f16cb8cb5f6 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 23 Sep 2013 19:55:22 +0200 Subject: use token auth when accessing the api from webapp One failing integration test still needs to be fixed --- users/test/integration/browser/account_test.rb | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'users/test') diff --git a/users/test/integration/browser/account_test.rb b/users/test/integration/browser/account_test.rb index 8c2c997..3434557 100644 --- a/users/test/integration/browser/account_test.rb +++ b/users/test/integration/browser/account_test.rb @@ -24,8 +24,41 @@ class AccountTest < BrowserIntegrationTest fill_in 'Password', with: password click_on 'Log In' assert page.has_content?("Welcome #{username}") + User.find_by_login(username).account.destroy end + test "change password" do + username, password = submit_signup + click_on "Account Settings" + within('#update_login_and_password') do + fill_in 'Password', with: "other password" + fill_in 'Password confirmation', with: "other password" + click_on 'Save' + end + click_on 'Logout' + click_on 'Log In' + fill_in 'Username', with: username + fill_in 'Password', with: "other password" + click_on 'Log In' + assert page.has_content?("Welcome #{username}") + User.find_by_login(username).account.destroy + end + + test "change pgp key" do + pgp_key = "My PGP Key Stub" + username, password = submit_signup + click_on "Account Settings" + within('#update_pgp_key') do + fill_in 'Public key', with: pgp_key + click_on 'Save' + end + debugger + assert user = User.find_by_login(username) + assert_equal pgp_key, user.public_key + user.account.destroy + end + + # trying to seed an invalid A for srp login test "detects attempt to circumvent SRP" do user = FactoryGirl.create :user -- cgit v1.2.3 From 4f8414298750193b6de3daff08364ec745a6a761 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 25 Sep 2013 10:12:08 +0200 Subject: visual feedback when submitting forms (#3164) This also helps with the failing integration test. We needed a way to tell the ajax request was back. Observing the button state now works for that. --- users/test/integration/browser/account_test.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'users/test') diff --git a/users/test/integration/browser/account_test.rb b/users/test/integration/browser/account_test.rb index 3434557..1deda45 100644 --- a/users/test/integration/browser/account_test.rb +++ b/users/test/integration/browser/account_test.rb @@ -52,8 +52,11 @@ class AccountTest < BrowserIntegrationTest fill_in 'Public key', with: pgp_key click_on 'Save' end - debugger - assert user = User.find_by_login(username) + page.assert_selector 'input[value="Saving..."]' + # at some point we're done: + page.assert_no_selector 'input[value="Saving..."]' + assert page.has_field? 'Public key', with: pgp_key + user = User.find_by_login(username) assert_equal pgp_key, user.public_key user.account.destroy end -- cgit v1.2.3 From af9d843d646cf500306de0ad20896c05ecaccd78 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 26 Sep 2013 12:06:25 -0700 Subject: Since local part of email is case sensitive, want to allow remote email addresses with uppercase letters in local part. --- users/test/unit/identity_test.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'users/test') diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb index 02f14c0..0842a77 100644 --- a/users/test/unit/identity_test.rb +++ b/users/test/unit/identity_test.rb @@ -76,7 +76,7 @@ class IdentityTest < ActiveSupport::TestCase assert_match /needs to end in/, id.errors[:address].first end - test "alias must meet some conditions as login" do + test "alias must meet same conditions as login" do id = Identity.create_for @user, address: alias_name.capitalize assert !id.valid? #hacky way to do this, but okay for now: @@ -90,12 +90,6 @@ class IdentityTest < ActiveSupport::TestCase assert id.errors.messages[:destination].include? "needs to be a valid email address" end - test "only lowercase destination" do - id = Identity.create_for @user, address: @user.email_address, destination: forward_address.capitalize - assert !id.valid? - assert id.errors.messages[:destination].include? "letters must be lowercase" - end - def alias_name @alias_name ||= Faker::Internet.user_name end -- cgit v1.2.3