mirror of
https://gitlab.com/keys.openpgp.org/hagrid.git
synced 2025-10-05 16:12:44 +02:00
Use "base_uri" fixture instead of BASE_URI const. Eliminate usage of BASE_URI const.
This commit is contained in:
committed by
Vincent Breitmoser
parent
d9741fad8f
commit
b6ad3f3705
@@ -447,7 +447,6 @@ pub mod tests {
|
||||
|
||||
pub mod assert {
|
||||
use crate::mail::pop_mail;
|
||||
use crate::web::tests::BASE_URI;
|
||||
use crate::web::vks_api;
|
||||
use hagrid_database::{Database, Sqlite};
|
||||
use rocket::http::{ContentType, Header, Status};
|
||||
@@ -799,8 +798,12 @@ pub mod tests {
|
||||
assert!(response.into_string().unwrap().contains("pending"));
|
||||
}
|
||||
|
||||
pub fn check_mails_and_verify_email(client: &Client, filemail_path: &Path) {
|
||||
let pattern = format!("{}(/verify/[^ \t\n]*)", BASE_URI);
|
||||
pub fn check_mails_and_verify_email(
|
||||
client: &Client,
|
||||
filemail_path: &Path,
|
||||
base_uri: &str,
|
||||
) {
|
||||
let pattern = format!("{}(/verify/[^ \t\n]*)", base_uri);
|
||||
let confirm_uri = pop_mail_capture_pattern(filemail_path, &pattern);
|
||||
|
||||
let response = client.post(&confirm_uri).dispatch();
|
||||
@@ -820,8 +823,9 @@ pub mod tests {
|
||||
client: &Client,
|
||||
filemail_path: &Path,
|
||||
address: &str,
|
||||
base_uri: &str,
|
||||
) {
|
||||
let pattern = format!("{}/manage/([^ \t\n]*)", BASE_URI);
|
||||
let pattern = format!("{}/manage/([^ \t\n]*)", base_uri);
|
||||
let token = pop_mail_capture_pattern(filemail_path, &pattern);
|
||||
vks_manage_delete(client, &token, address);
|
||||
}
|
||||
@@ -897,13 +901,17 @@ pub mod tests {
|
||||
.dispatch()
|
||||
}
|
||||
|
||||
pub fn vks_publish_shortcut_get_token(client: &Client, data: &[u8]) -> String {
|
||||
pub fn vks_publish_shortcut_get_token(
|
||||
client: &Client,
|
||||
data: &[u8],
|
||||
base_uri: &str,
|
||||
) -> String {
|
||||
let response = client.put("/").body(data).dispatch();
|
||||
assert_eq!(response.status(), Status::Ok);
|
||||
let response_body = response.into_string().unwrap();
|
||||
assert!(response_body.contains("Key successfully uploaded"));
|
||||
|
||||
let pattern = format!("{}/upload/([^ \t\n]*)", BASE_URI);
|
||||
let pattern = format!("{}/upload/([^ \t\n]*)", base_uri);
|
||||
let capture_re = regex::bytes::Regex::new(&pattern).unwrap();
|
||||
let capture_content = capture_re
|
||||
.captures(response_body.as_bytes())
|
||||
@@ -956,8 +964,6 @@ pub mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
const BASE_URI: &str = "http://local.connection";
|
||||
|
||||
#[rstest]
|
||||
fn about_translation(#[from(client)] (_tmpdir, client): (TempDir, Client)) {
|
||||
// Check that we see the landing page.
|
||||
@@ -1089,7 +1095,7 @@ pub mod tests {
|
||||
assert::check_verify_link(&client, &token, cert_name, "");
|
||||
|
||||
// Now check for the verification mail.
|
||||
assert::check_mails_and_verify_email(&client, filemail_into.as_path());
|
||||
assert::check_mails_and_verify_email(&client, filemail_into.as_path(), base_uri);
|
||||
|
||||
// Now lookups using the mail address should work.
|
||||
assert::check_responses_by_email(&client, cert_name, &tpk, 1, base_uri, base_uri_onion);
|
||||
@@ -1101,7 +1107,12 @@ pub mod tests {
|
||||
assert::vks_manage(&client, cert_name);
|
||||
|
||||
// Confirm deletion.
|
||||
assert::check_mails_and_confirm_deletion(&client, filemail_into.as_path(), cert_name);
|
||||
assert::check_mails_and_confirm_deletion(
|
||||
&client,
|
||||
filemail_into.as_path(),
|
||||
cert_name,
|
||||
base_uri,
|
||||
);
|
||||
|
||||
// Now, we should no longer be able to look it up by email
|
||||
// address.
|
||||
@@ -1204,8 +1215,8 @@ pub mod tests {
|
||||
assert::check_verify_link_json(&client, &token_2, cert_name_2);
|
||||
|
||||
// Now check for the verification mails.
|
||||
assert::check_mails_and_verify_email(&client, &filemail_into);
|
||||
assert::check_mails_and_verify_email(&client, &filemail_into);
|
||||
assert::check_mails_and_verify_email(&client, &filemail_into, base_uri);
|
||||
assert::check_mails_and_verify_email(&client, &filemail_into, base_uri);
|
||||
|
||||
// Now lookups using the mail address should work.
|
||||
assert::check_responses_by_email(&client, cert_name_1, &tpk_1, 1, base_uri, base_uri_onion);
|
||||
@@ -1213,9 +1224,9 @@ pub mod tests {
|
||||
|
||||
// Request deletion of the bindings.
|
||||
assert::vks_manage(&client, cert_name_1);
|
||||
assert::check_mails_and_confirm_deletion(&client, &filemail_into, cert_name_1);
|
||||
assert::check_mails_and_confirm_deletion(&client, &filemail_into, cert_name_1, base_uri);
|
||||
assert::vks_manage(&client, cert_name_2);
|
||||
assert::check_mails_and_confirm_deletion(&client, &filemail_into, cert_name_2);
|
||||
assert::check_mails_and_confirm_deletion(&client, &filemail_into, cert_name_2, base_uri);
|
||||
|
||||
// Now, we should no longer be able to look it up by email
|
||||
// address.
|
||||
@@ -1279,13 +1290,14 @@ pub mod tests {
|
||||
|
||||
#[rstest]
|
||||
fn upload_curl_shortcut(
|
||||
base_uri: &str,
|
||||
#[from(cert)] (cert_name, tpk): (&str, Cert),
|
||||
#[from(client)] (_tmpdir, client): (TempDir, Client),
|
||||
) {
|
||||
let mut tpk_serialized = Vec::new();
|
||||
tpk.serialize(&mut tpk_serialized).unwrap();
|
||||
|
||||
let _token = assert::vks_publish_shortcut_get_token(&client, &tpk_serialized);
|
||||
let _token = assert::vks_publish_shortcut_get_token(&client, &tpk_serialized, base_uri);
|
||||
|
||||
assert::check_mr_responses_by_fingerprint(&client, &tpk, 0);
|
||||
assert::check_null_responses_by_email(&client, cert_name);
|
||||
|
Reference in New Issue
Block a user