summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2017-11-16 13:18:55 +0100
committerAzul <azul@riseup.net>2017-11-16 13:18:55 +0100
commit1ce9a3355ee59181df0359ebb455efa9ef323bb6 (patch)
treec911f020eb11d0e1342c96ae225cf2a4a6ca57df /test/integration
parentae0aa02d038f16bb0919eebee805624bb891f48f (diff)
fix: respond with error on invalid pgp key
We used to just ignore the key. Also separated the code for handling key updates from other user updates. This should eventually be moved to a different route. Mixing the two makes the implementation really hard.
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/api/pgp_key_test.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/integration/api/pgp_key_test.rb b/test/integration/api/pgp_key_test.rb
index 4c7fb4c..f2744e1 100644
--- a/test/integration/api/pgp_key_test.rb
+++ b/test/integration/api/pgp_key_test.rb
@@ -14,16 +14,16 @@ class PgpKeyTest < SrpTest
assert_equal key, Identity.for(@user).keys[:pgp]
end
- # eventually probably want to remove most of this into a non-integration
- # functional test
test "prevent uploading invalid key" do
update_user public_key: "invalid key"
+ assert_invalid_key_response
assert_nil Identity.for(@user).keys[:pgp]
end
test "prevent emptying public key" do
update_user public_key: key
update_user public_key: ""
+ assert_invalid_key_response
assert_equal key, Identity.for(@user).keys[:pgp]
end
@@ -32,4 +32,9 @@ class PgpKeyTest < SrpTest
def key
@key ||= FactoryGirl.build :pgp_key
end
+
+ def assert_invalid_key_response
+ assert_response :unprocessable_entity
+ assert_json_error "public_key_block"=>["does not look like an armored pgp public key block"]
+ end
end