blob: 46a6bbbbe741dc3889e501389f17139ebecc30c6 (
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
41
42
43
|
require 'test_helper'
require 'file_content'
require 'support/celluloid_test'
require 'support/http_adapter_helper'
require 'nickserver/wkd/source'
require 'nickserver/email_address'
class RemoteWkdSourceTest < CelluloidTest
include HttpAdapterHelper
include FileContent
def test_existing_key
response = source.query email_with_key
assert_equal 200, response.status
assert_pgp_key_in response
end
def test_missing_key
uid = 'thisemaildoesnotexist@test.gnupg.org'
email = Nickserver::EmailAddress.new uid
status, body = source.query email
assert_nil status
assert_nil body
end
protected
def assert_pgp_key_in(response)
json = JSON.parse response.content
assert_equal email_with_key.to_s, json['address']
refute_empty json['openpgp']
assert_equal file_content('dewey.pgp.asc'), json['openpgp']
end
def email_with_key
uid = 'dewey@test.gnupg.org'
Nickserver::EmailAddress.new uid
end
def source
Nickserver::Wkd::Source.new adapter
end
end
|