summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-01-31 14:43:19 -0800
committerelijah <elijah@riseup.net>2016-01-31 15:10:10 -0800
commite7e16318d056dbd9ec272085487cce6039627b09 (patch)
tree6ff86c1ae638da1ad620924037ccd41f9418b4b8 /test/unit
parent16fb1c2bf33ca418a6db06217e286964077a730f (diff)
remove cert fingerprints for disabled users, so that they cannot send email anymore. closes #7690
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/account_test.rb20
-rw-r--r--test/unit/identity_test.rb10
2 files changed, 20 insertions, 10 deletions
diff --git a/test/unit/account_test.rb b/test/unit/account_test.rb
index 6b814b6..7c26d5c 100644
--- a/test/unit/account_test.rb
+++ b/test/unit/account_test.rb
@@ -1,4 +1,4 @@
-require 'test_helper'
+require_relative '../test_helper'
class AccountTest < ActiveSupport::TestCase
@@ -23,10 +23,10 @@ class AccountTest < ActiveSupport::TestCase
test "create a new account" do
with_config invite_required: false do
- user = Account.create(FactoryGirl.attributes_for(:user))
- assert user.valid?, "unexpected errors: #{user.errors.inspect}"
- assert user.persisted?
- user.account.destroy
+ user = Account.create(FactoryGirl.attributes_for(:user))
+ assert user.valid?, "unexpected errors: #{user.errors.inspect}"
+ assert user.persisted?
+ user.account.destroy
end
end
@@ -80,4 +80,14 @@ class AccountTest < ActiveSupport::TestCase
assert_equal 0, user_code.invite_count
end
+
+ test "disabled accounts have no cert fingerprints" do
+ user = Account.create(FactoryGirl.attributes_for(:user))
+ cert = stub(expiry: 1.month.from_now, fingerprint: SecureRandom.hex)
+ user.identity.register_cert cert
+ user.identity.save
+ assert_equal cert.fingerprint, Identity.for(user).cert_fingerprints.keys.first
+ user.account.disable
+ assert_equal({}, Identity.for(user).cert_fingerprints)
+ end
end
diff --git a/test/unit/identity_test.rb b/test/unit/identity_test.rb
index f5c95f8..1f93109 100644
--- a/test/unit/identity_test.rb
+++ b/test/unit/identity_test.rb
@@ -1,4 +1,4 @@
-require 'test_helper'
+require_relative '../test_helper'
class IdentityTest < ActiveSupport::TestCase
include StubRecordHelper
@@ -177,9 +177,9 @@ class IdentityTest < ActiveSupport::TestCase
end
def cert_stub
- # make this expire later than the others so it's on top
- # when sorting by expiry descending.
- @cert_stub ||= stub expiry: 2.month.from_now,
- fingerprint: SecureRandom.hex
+ # make this expire later than the other test identities
+ # so that the query that returns certs sorted by expiry will
+ # return cert_stub first.
+ @cert_stub ||= stub(expiry: 2.month.from_now, fingerprint: SecureRandom.hex)
end
end