summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/integration/api/update_account_test.rb6
-rw-r--r--test/unit/account_test.rb36
2 files changed, 42 insertions, 0 deletions
diff --git a/test/integration/api/update_account_test.rb b/test/integration/api/update_account_test.rb
index 1492006..108f05d 100644
--- a/test/integration/api/update_account_test.rb
+++ b/test/integration/api/update_account_test.rb
@@ -28,6 +28,12 @@ class UpdateAccountTest < SrpTest
assert server_auth["M2"]
end
+ test "update recovery code via api" do
+ authenticate
+ update_user recovery_code_verifier: "123", recovery_code_salt: "456"
+ assert last_response.successful?
+ end
+
test "change login with password_verifier" do
authenticate
new_login = 'zaph'
diff --git a/test/unit/account_test.rb b/test/unit/account_test.rb
index e00e589..058e196 100644
--- a/test/unit/account_test.rb
+++ b/test/unit/account_test.rb
@@ -96,6 +96,42 @@ class AccountTest < ActiveSupport::TestCase
user.account.destroy
end
+ test "create recovery code if it does not exist" do
+ user = Account.create(FactoryGirl.attributes_for(:user, :invite_code => @testcode.invite_code))
+ user.account.update(:recovery_code_verifier => "abc", :recovery_code_salt => "123")
+ user.reload
+
+ assert_equal "abc", user.recovery_code_verifier
+ assert_equal "123", user.recovery_code_salt
+
+ user.account.destroy
+ end
+
+ test "update recovery code that already exists" do
+ user = Account.create(FactoryGirl.attributes_for(:user,
+ :invite_code => @testcode.invite_code,
+ :recovery_code_verifier => "000",
+ :recovery_code_salt => "111"))
+
+ user.account.update(:recovery_code_verifier => "abc", :recovery_code_salt => "123")
+ user.reload
+
+ assert_equal "abc", user.recovery_code_verifier
+ assert_equal "123", user.recovery_code_salt
+
+ user.account.destroy
+ end
+
+ test "update password" do
+ user = Account.create(FactoryGirl.attributes_for(:user, :invite_code => @testcode.invite_code))
+ user.account.update(:password_verifier => "551A8B", :password_salt => "551A8B")
+
+ assert_equal "551A8B", user.password_verifier
+ assert_equal "551A8B", user.password_salt
+
+ user.account.destroy
+ end
+
test "Invite code count goes up by 1 when the invite code is entered" do
with_config invite_required: true do
user = Account.create(FactoryGirl.attributes_for(:user, :invite_code => @testcode.invite_code))