storkit: merge 449_bug_oauth_callback_url_ignores_port_cli_flag
This commit is contained in:
+12
-2
@@ -64,12 +64,13 @@ pub fn build_routes(
|
||||
ctx: AppContext,
|
||||
whatsapp_ctx: Option<Arc<WhatsAppWebhookContext>>,
|
||||
slack_ctx: Option<Arc<SlackWebhookContext>>,
|
||||
port: u16,
|
||||
) -> impl poem::Endpoint {
|
||||
let ctx_arc = std::sync::Arc::new(ctx);
|
||||
|
||||
let (api_service, docs_service) = build_openapi_service(ctx_arc.clone());
|
||||
|
||||
let oauth_state = Arc::new(oauth::OAuthState::new(resolve_port()));
|
||||
let oauth_state = Arc::new(oauth::OAuthState::new(port));
|
||||
|
||||
let mut route = Route::new()
|
||||
.nest("/api", api_service)
|
||||
@@ -236,6 +237,15 @@ mod tests {
|
||||
fn build_routes_constructs_without_panic() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = context::AppContext::new_test(tmp.path().to_path_buf());
|
||||
let _endpoint = build_routes(ctx, None, None);
|
||||
let _endpoint = build_routes(ctx, None, None, 3001);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_routes_accepts_custom_port() {
|
||||
// Verify build_routes compiles and runs with a non-default port,
|
||||
// ensuring the port parameter flows through to OAuthState.
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = context::AppContext::new_test(tmp.path().to_path_buf());
|
||||
let _endpoint = build_routes(ctx, None, None, 9999);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,6 +423,13 @@ mod tests {
|
||||
assert_eq!(state.callback_url(), "http://localhost:3001/callback");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oauth_state_callback_url_uses_given_port() {
|
||||
// Ensure OAuthState::new uses the port passed to it, not a hardcoded value.
|
||||
let state = OAuthState::new(9876);
|
||||
assert_eq!(state.callback_url(), "http://localhost:9876/callback");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn html_response_contains_title_and_message() {
|
||||
let resp = html_response(StatusCode::OK, "Test Title", "Test message");
|
||||
|
||||
+1
-1
@@ -495,7 +495,7 @@ async fn main() -> Result<(), std::io::Error> {
|
||||
matrix_shutdown_tx: Some(Arc::clone(&matrix_shutdown_tx)),
|
||||
};
|
||||
|
||||
let app = build_routes(ctx, whatsapp_ctx.clone(), slack_ctx.clone());
|
||||
let app = build_routes(ctx, whatsapp_ctx.clone(), slack_ctx.clone(), port);
|
||||
|
||||
// Optional Matrix bot: connect to the homeserver and start listening for
|
||||
// messages if `.storkit/bot.toml` is present and enabled.
|
||||
|
||||
Reference in New Issue
Block a user