Skip to content

Commit

Permalink
fix: validate step
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed May 20, 2024
1 parent 58b438b commit 55066d9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions integration/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('Echo Server', () => {

// Simulate flood of requests and check for rate-limited responses
it('Rate limiting', async () => {
const url = `${BASE_URL}/health`
const url = `${BASE_URL}/rate_limit_test`
const requests_to_send = 100;
const promises = [];
for (let i = 0; i < requests_to_send; i++) {
Expand All @@ -85,7 +85,7 @@ describe('Echo Server', () => {
);
}
const results = await Promise.allSettled(promises);

let ok_statuses_counter = 0;
let rate_limited_statuses_counter = 0;
results.forEach((result) => {
Expand Down
1 change: 1 addition & 0 deletions src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub mod delete_tenant;
#[cfg(feature = "multitenant")]
pub mod get_tenant;
pub mod health;
pub mod rate_limit_test;
#[cfg(feature = "multitenant")]
pub mod update_apns;
#[cfg(feature = "multitenant")]
Expand Down
5 changes: 5 additions & 0 deletions src/handlers/rate_limit_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use axum::{http::StatusCode, response::IntoResponse};

pub async fn handler() -> impl IntoResponse {
StatusCode::OK.into_response()
}
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) ->

Router::new()
.route("/health", get(handlers::health::handler))
.route("/rate_limit_test", get(handlers::rate_limit_test::handler).layer(
axum::middleware::from_fn_with_state(state_arc.clone(), rate_limit_middleware),
))
.nest("/tenants", tenancy_routes.layer(
axum::middleware::from_fn_with_state(state_arc.clone(), rate_limit_middleware),
))
Expand All @@ -260,6 +263,9 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) ->
#[cfg(not(feature = "multitenant"))]
let app = Router::new()
.route("/health", get(handlers::health::handler))
.route("/rate_limit_test", get(handlers::rate_limit_test::handler).layer(
axum::middleware::from_fn_with_state(state_arc.clone(), rate_limit_middleware),
))
.route(
"/clients",
post(handlers::single_tenant_wrappers::register_handler).layer(
Expand Down

0 comments on commit 55066d9

Please sign in to comment.