blob: f2744e118448357702e061bee3074b18240fd580 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
require 'test_helper'
require_relative 'srp_test'
class PgpKeyTest < SrpTest
setup do
# todo: prepare user and login without doing the srp dance
register_user
authenticate
end
test "upload pgp key" do
update_user public_key: key
assert_equal key, Identity.for(@user).keys[:pgp]
end
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
protected
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
|