diff options
Diffstat (limited to 'test/remote')
-rw-r--r-- | test/remote/hkp_source_test.rb | 31 | ||||
-rw-r--r-- | test/remote/nicknym_source_test.rb | 2 | ||||
-rw-r--r-- | test/remote/wkd_source_test.rb | 4 |
3 files changed, 20 insertions, 17 deletions
diff --git a/test/remote/hkp_source_test.rb b/test/remote/hkp_source_test.rb index 8232dce..469941b 100644 --- a/test/remote/hkp_source_test.rb +++ b/test/remote/hkp_source_test.rb @@ -7,32 +7,27 @@ class RemoteHkpSourceTest < CelluloidTest include HttpAdapterHelper def test_key_info - uid = 'elijah@riseup.net' - assert_key_info_for_uid uid do |keys| - assert_equal 1, keys.size - assert keys.first.keyid =~ /00440025$/ - end + assert_key_found 'elijah@riseup.net', /00440025$/ end def test_tls_validation - hkp_url = 'https://keys.mayfirst.org/pks/lookup' - ca_file = file_path('mayfirst-ca.pem') - config.stub(:hkp_url, hkp_url) do - # config.stub(:hkp_ca_file, file_path('autistici-ca.pem')) do config.stub(:hkp_ca_file, ca_file) do assert File.exist?(Nickserver::Config.hkp_ca_file) - uid = 'elijah@riseup.net' - assert_key_info_for_uid uid do |keys| - assert_equal 1, keys.size - assert keys.first.keyid =~ /00440025$/ - end + assert_key_found 'elijah@riseup.net', /00440025$/ end end end protected + def assert_key_found(uid, fingerprint_regexp) + assert_key_info_for_uid uid do |keys| + assert_equal 1, keys.size + assert keys.first.keyid =~ fingerprint_regexp + end + end + def assert_key_info_for_uid(uid) status, keys = source.search uid assert_equal 200, status @@ -44,4 +39,12 @@ class RemoteHkpSourceTest < CelluloidTest def source Nickserver::Hkp::Source.new adapter end + + def hkp_url + 'https://keys.mayfirst.org/pks/lookup' + end + + def ca_file + file_path('mayfirst-ca.pem') + end end diff --git a/test/remote/nicknym_source_test.rb b/test/remote/nicknym_source_test.rb index 6fff1f6..ef74653 100644 --- a/test/remote/nicknym_source_test.rb +++ b/test/remote/nicknym_source_test.rb @@ -63,6 +63,6 @@ class RemoteNicknymSourceTest < CelluloidTest end def email_without_key - Nickserver::EmailAddress.new('pleaseneverusethisemailweuseittotest@mail.bitmask.net') + Nickserver::EmailAddress.new('neverusethisweuseittotest@mail.bitmask.net') end end diff --git a/test/remote/wkd_source_test.rb b/test/remote/wkd_source_test.rb index 1ed7ea5..46a6bbb 100644 --- a/test/remote/wkd_source_test.rb +++ b/test/remote/wkd_source_test.rb @@ -27,8 +27,8 @@ class RemoteWkdSourceTest < CelluloidTest 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 email_with_key.to_s, json['address'] + refute_empty json['openpgp'] assert_equal file_content('dewey.pgp.asc'), json['openpgp'] end |