Verified Commit d15f0926 authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

hkp: return correct creation time

The creation time reported in the hkp "index" response should be the
primary key's creation timestamp. We returned the creation time of the
"primary key signature" (i.e.  newest user id binding signature) before.

parent 230f69bc
Pipeline #102229273 passed with stage
in 14 minutes and 34 seconds
......@@ -223,11 +223,7 @@ fn key_to_hkp_index(db: rocket::State<KeyDatabase>, query: Query)
let mut out = String::default();
let p = tpk.primary();
let ctime = tpk
.and_then(|x| x.signature_creation_time())
.map(|x| format!("{}", x.to_timespec().sec))
let ctime = format!("{}", p.creation_time().to_timespec().sec);
let extime = tpk
.and_then(|x| x.signature_expiration_time())
......@@ -1059,6 +1059,25 @@ pub mod tests {
assert_eq!(tpk_.userids().count(), nr_uids);
// it's a rather "reverse implementation" style test.. can we do better?
/// Asserts that the given URI returns a correct hkp "index"
/// response for the given TPK.
pub fn check_index_response(client: &Client, uri: &str, tpk: &TPK) {
let mut response = client.get(uri).dispatch();
assert_eq!(response.status(), Status::Ok);
Some(ContentType::new("text", "plain")));
let body = response.body_string().unwrap();
let primary_fpr = tpk.fingerprint().to_hex();
let algo: u8 = tpk.primary().pk_algo().into();
assert!(body.contains(&format!("pub:{}:{}:", primary_fpr, algo)));
let creation_time = tpk.primary().creation_time().to_timespec().sec;
assert!(body.contains(&format!(":{}:", creation_time)));
/// Asserts that we can get the given TPK back using the various
/// by-fingerprint or by-keyid lookup mechanisms.
pub fn check_mr_responses_by_fingerprint(client: &Client, tpk: &TPK,
......@@ -1090,6 +1109,11 @@ pub mod tests {
&format!("/pks/lookup?op=get&search=0x{}", keyid),
&tpk, nr_uids);
&format!("/pks/lookup?op=index&search={}", fp),
/// Asserts that the given URI contains the search string.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment