mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-03-14 13:08:27 +03:00
feat: fallabck to localhost when running tests
This commit is contained in:
parent
f8e6bdf229
commit
21825582e5
1 changed files with 8 additions and 0 deletions
|
@ -42,7 +42,15 @@ pub async fn verify_pow(
|
|||
payload: web::Json<Work>,
|
||||
data: AppData,
|
||||
) -> ServiceResult<impl Responder> {
|
||||
#[cfg(not(test))]
|
||||
let ip = req.connection_info().peer_addr().unwrap().to_string();
|
||||
// From actix-web docs:
|
||||
// Will only return None when called in unit tests unless TestRequest::peer_addr is used.
|
||||
//
|
||||
// ref: https://docs.rs/actix-web/latest/actix_web/struct.HttpRequest.html#method.peer_addr
|
||||
#[cfg(test)]
|
||||
let ip = "127.0.1.1".into();
|
||||
|
||||
let key = payload.key.clone();
|
||||
let res = data.captcha.verify_pow(payload.into_inner(), ip).await?;
|
||||
data.stats.record_solve(&data, &key).await?;
|
||||
|
|
Loading…
Add table
Reference in a new issue