summaryrefslogtreecommitdiff
path: root/test/unit/couch_db
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/couch_db')
-rw-r--r--test/unit/couch_db/response_test.rb46
1 files changed, 42 insertions, 4 deletions
diff --git a/test/unit/couch_db/response_test.rb b/test/unit/couch_db/response_test.rb
index 3003307..7eb5872 100644
--- a/test/unit/couch_db/response_test.rb
+++ b/test/unit/couch_db/response_test.rb
@@ -11,20 +11,58 @@ class Nickserver::CouchDB::ResponseTest < Minitest::Test
assert_equal 404, response.status
end
- def test_200_with_empty_response
+ def test_404_because_of_empty_response
response = response_for 'stompy@example.org',
- status: 200, body: file_content(:empty_couchdb_result)
+ status: 200,
+ body: file_content(:empty_couchdb_result)
assert_equal 404, response.status
end
def test_200_with_success
response = response_for 'blue@example.org',
- status: 200, body: file_content(:blue_couchdb_result)
+ status: 200, body:
+ file_content(:blue_couchdb_result)
assert_equal 200, response.status
- assert_equal file_content(:blue_nickserver_result), response.content
+ assert_equal JSON.parse(file_content(:blue_nickserver_result)),
+ JSON.parse(response.content)
+ end
+
+ def test_200_with_other_keys
+ body_with_other_type = change_type(file_content(:blue_couchdb_result))
+ response = response_for 'blue@example.org',
+ status: 200,
+ body: body_with_other_type
+ assert_equal 200, response.status
+ expected = JSON.parse change_type(file_content(:blue_nickserver_result))
+ assert_equal expected, JSON.parse(response.content)
+ end
+
+ def test_openpgp_key_from_old_data_format
+ response = response_for 'red@example.org',
+ status: 200,
+ body: file_content(:red_couchdb_result_with_old_format)
+ assert_equal 200, response.status
+ data = JSON.parse response.content
+ assert_includes data.keys, 'address'
+ assert_includes data.keys, 'openpgp'
+ end
+
+ def test_katzenpost_key
+ response = response_for 'red@example.org',
+ status: 200,
+ body: file_content(:red_couchdb_result_with_katzenpost)
+ assert_equal 200, response.status
+ data = JSON.parse response.content
+ assert_includes data.keys, 'address'
+ assert_includes data.keys, 'katzenpost_link'
end
def response_for(uid, couch_response = {})
Nickserver::CouchDB::Response.new uid, couch_response
end
+
+ def change_type(string)
+ string.gsub('openpgp', 'other')
+ end
+
end