This commit is contained in:
Felix Ableitner 2025-01-09 12:06:43 +01:00
parent 451d388833
commit 47bfde132c
5 changed files with 10 additions and 4 deletions

View file

@ -29,7 +29,7 @@ pub async fn new_instance(
.signed_fetch_actor(&system_user)
.app_data(database)
.url_verifier(Box::new(MyUrlVerifier()))
.debug(false)
.debug(true)
.build()
.await?;
Ok(config)

View file

@ -136,8 +136,8 @@ impl SendActivityTask {
}
}
pub(crate) async fn build_tasks<'a, Activity, Datatype, ActorType>(
activity: &'a Activity,
pub(crate) async fn build_tasks<Activity, Datatype, ActorType>(
activity: &Activity,
actor: &ActorType,
inboxes: Vec<Url>,
data: &Data<Datatype>,

View file

@ -360,6 +360,7 @@ const _IMPL_DIESEL_NEW_TYPE_FOR_OBJECT_ID: () = {
}
};
/// Shared test code
#[cfg(test)]
#[allow(clippy::unwrap_used)]
pub mod tests {

View file

@ -57,9 +57,12 @@ where
.splitn(2, '@')
.collect_tuple()
.ok_or(WebFingerError::WrongFormat.into_crate_error())?;
if !DOMAIN_REGEX.is_match(domain) {
// For production mode make sure that domain doesnt contain any port or path.
if !data.config.debug && !DOMAIN_REGEX.is_match(domain) {
return Err(Error::UrlVerificationError("Invalid characters in domain").into());
}
let protocol = if data.config.debug { "http" } else { "https" };
let fetch_url =
format!("{protocol}://{domain}/.well-known/webfinger?resource=acct:{identifier}");

View file

@ -277,6 +277,7 @@ pub(crate) fn verify_body_hash(
Ok(())
}
/// Shared test code
#[cfg(test)]
#[allow(clippy::unwrap_used)]
pub mod test {
@ -378,6 +379,7 @@ pub mod test {
assert_eq!(invalid, Err(Error::ActivityBodyDigestInvalid));
}
/// Return hardcoded keypair
pub fn test_keypair() -> Keypair {
let rsa = RsaPrivateKey::from_pkcs1_pem(PRIVATE_KEY).unwrap();
let pkey = RsaPublicKey::from(&rsa);