Generalize test.

This commit is contained in:
Justus Winter 2019-03-05 13:36:26 +01:00
parent cadc0d59b0
commit c5f43fb82c
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
1 changed files with 11 additions and 8 deletions

View File

@ -815,7 +815,8 @@ mod tests {
&client, "/pks/lookup?op=get&options=mr&search=foo@invalid.example.com");
// And check that we can get it back, modulo user ids.
fn check_mr_response(client: &Client, uri: &str, tpk: &TPK) {
fn check_mr_response(client: &Client, uri: &str, tpk: &TPK,
nr_uids: usize) {
let mut response = client.get(uri).dispatch();
assert_eq!(response.status(), Status::Ok);
assert_eq!(response.content_type(),
@ -828,27 +829,29 @@ mod tests {
.collect::<Vec<_>>(),
tpk_.subkeys().map(|skb| skb.subkey().fingerprint())
.collect::<Vec<_>>());
assert_eq!(tpk_.userids().count(), 0);
assert_eq!(tpk_.userids().count(), nr_uids);
}
check_mr_response(&client, &format!("/vks/v1/by-keyid/{}", keyid), &tpk);
check_mr_response(&client, &format!("/vks/v1/by-fingerprint/{}", fp), &tpk);
check_mr_response(
&client, &format!("/vks/v1/by-keyid/{}", keyid), &tpk, 0);
check_mr_response(
&client, &format!("/vks/v1/by-fingerprint/{}", fp), &tpk, 0);
check_mr_response(
&client,
&format!("/pks/lookup?op=get&options=mr&search={}", fp),
&tpk);
&tpk, 0);
check_mr_response(
&client,
&format!("/pks/lookup?op=get&options=mr&search=0x{}", fp),
&tpk);
&tpk, 0);
check_mr_response(
&client,
&format!("/pks/lookup?op=get&options=mr&search={}", keyid),
&tpk);
&tpk, 0);
check_mr_response(
&client,
&format!("/pks/lookup?op=get&options=mr&search=0x{}", keyid),
&tpk);
&tpk, 0);
// And check that we can see the human-readable result page.
fn check_hr_response(client: &Client, uri: &str, tpk: &TPK) {