summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--users/app/models/user.rb20
-rw-r--r--users/test/unit/user_test.rb8
2 files changed, 25 insertions, 3 deletions
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index f78f290..0a89f7c 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -87,6 +87,26 @@ class User < CouchRest::Model::Base
Ticket.for_user(self).limit(count).all #defaults to having most recent updated first
end
+ # DEPRECATED
+ #
+ # Please set the key on the identity directly
+ # WARNING: This will not be serialized with the user record!
+ # It is only a workaround for the key form.
+ def public_key=(value)
+ identity.set_key(:pgp, value)
+ end
+
+ # DEPRECATED
+ #
+ # Please access identity.keys[:pgp] directly
+ def public_key
+ identity.keys[:pgp]
+ end
+
+ def identity
+ @identity ||= Identity.for(self)
+ end
+
protected
##
diff --git a/users/test/unit/user_test.rb b/users/test/unit/user_test.rb
index 477c727..89ee749 100644
--- a/users/test/unit/user_test.rb
+++ b/users/test/unit/user_test.rb
@@ -70,14 +70,16 @@ class UserTest < ActiveSupport::TestCase
end
test "pgp key view" do
- @user.public_key = SecureRandom.base64(4096)
- @user.save
+ key = SecureRandom.base64(4096)
+ identity = Identity.create_for @user
+ identity.set_key('pgp', key)
+ identity.save
view = Identity.pgp_key_by_email.key(@user.email_address)
assert_equal 1, view.rows.count
assert result = view.rows.first
assert_equal @user.email_address, result["key"]
- assert_equal @user.public_key, result["value"]
+ assert_equal key, result["value"]
end
end