Removed authentication rate limit (unnecessary since there is fail2ban)
This commit is contained in:
@@ -68,40 +68,6 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
let range_end = (range_start * LIMIT) + LIMIT;
|
||||
tokio::time::sleep(Duration::from_secs(range_end - now)).await;
|
||||
|
||||
// Invalid authentication requests should be rate limited
|
||||
let mut n_401 = 0;
|
||||
let mut n_429 = 0;
|
||||
for n in 0..110 {
|
||||
if let Err(jmap_client::Error::Problem(problem)) = Client::new()
|
||||
.credentials(Credentials::basic(
|
||||
"not_an_account@example.com",
|
||||
&format!("brute_force{}", n),
|
||||
))
|
||||
.accept_invalid_certs(true)
|
||||
.connect("https://127.0.0.1:8899")
|
||||
.await
|
||||
{
|
||||
if problem.status().unwrap() == 401 {
|
||||
n_401 += 1;
|
||||
if n_401 > 100 {
|
||||
panic!("Rate limiter failed: 429: {n_429}, 401: {n_401}.");
|
||||
}
|
||||
} else if problem.status().unwrap() == 429 {
|
||||
n_429 += 1;
|
||||
if n_429 > 11 {
|
||||
panic!("Rate limiter too restrictive: 429: {n_429}, 401: {n_401}.");
|
||||
}
|
||||
} else {
|
||||
panic!("Unexpected error status {}", problem.status().unwrap());
|
||||
}
|
||||
} else {
|
||||
panic!("Unexpected response.");
|
||||
}
|
||||
}
|
||||
|
||||
// Limit should be restored after 1 second
|
||||
tokio::time::sleep(Duration::from_millis(1500)).await;
|
||||
|
||||
// Test fail2ban
|
||||
assert_eq!(
|
||||
server
|
||||
@@ -113,6 +79,26 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
.unwrap(),
|
||||
None
|
||||
);
|
||||
for n in 0..98 {
|
||||
match Client::new()
|
||||
.credentials(Credentials::basic(
|
||||
"not_an_account@example.com",
|
||||
&format!("brute_force{}", n),
|
||||
))
|
||||
.accept_invalid_certs(true)
|
||||
.connect("https://127.0.0.1:8899")
|
||||
.await
|
||||
{
|
||||
Err(jmap_client::Error::Problem(_)) => {}
|
||||
Err(err) => {
|
||||
panic!("Unexpected response: {:?}", err);
|
||||
}
|
||||
Ok(_) => {
|
||||
panic!("Unexpected success");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut imap = ImapConnection::connect(b"_x ").await;
|
||||
imap.send("AUTHENTICATE PLAIN AGpvaG4AY2hpbWljaGFuZ2Fz")
|
||||
.await;
|
||||
|
||||
@@ -120,7 +120,7 @@ implicit = false
|
||||
certificate = "default"
|
||||
|
||||
[server.fail2ban]
|
||||
authentication = "101/5s"
|
||||
authentication = "100/5s"
|
||||
|
||||
[authentication]
|
||||
rate-limit = "100/2s"
|
||||
@@ -371,7 +371,7 @@ pub async fn jmap_tests() {
|
||||
.await;
|
||||
|
||||
webhooks::test(&mut params).await;
|
||||
/*email_query::test(&mut params, delete).await;
|
||||
email_query::test(&mut params, delete).await;
|
||||
email_get::test(&mut params).await;
|
||||
email_set::test(&mut params).await;
|
||||
email_parse::test(&mut params).await;
|
||||
@@ -381,7 +381,7 @@ pub async fn jmap_tests() {
|
||||
email_copy::test(&mut params).await;
|
||||
thread_get::test(&mut params).await;
|
||||
thread_merge::test(&mut params).await;
|
||||
mailbox::test(&mut params).await;*/
|
||||
mailbox::test(&mut params).await;
|
||||
delivery::test(&mut params).await;
|
||||
auth_acl::test(&mut params).await;
|
||||
auth_limits::test(&mut params).await;
|
||||
|
||||
Reference in New Issue
Block a user