โ† Back to Pull requests

๐Ÿ› bug: serve a request with a TLS state over TLS in app.Test #4839

Closed
unknown closed this pull request without merging on Nov 03, 2026 10:36 UTC
View on GitHub
unknown unknown commented on Nov 02, 2026 18:50 UTC
Author

Description

httptest.NewRequest gives an https:// target a non-nil req.TLS, but app.Test serves the dumped request on a plain in-memory connection. In the handler c.Scheme() is then http, c.Secure() is false, c.BaseURL() is http://example.com and c.RequestCtx().TLSConnectionState() is nil, so testing HTTPS-dependent behaviour with app.Test fails, or passes for the wrong reason:

  • With csrf.New(), a same-origin POST https://example.com/ with Origin: https://example.com and a valid token gets 403 Forbidden, because the origin is compared with http://example.com. The same flow over http:// gets 200.

  • With helmet.New(helmet.Config{HSTSMaxAge: 3600}), GET https://example.com/ has no Strict-Transport-Security header.
  • app.Test now serves a request with a TLS state on a testTLSConn, which has the ConnectionState and Handshake methods fasthttp detects TLS by and returns *req.TLS. This is what adaptor.FiberApp already does with r.TLS. A request without a TLS state is served as before; one built with http.NewRequest or a path-only target can set req.TLS to be served over TLS. Existing tests that send https:// targets now see https. With the change both cases above answer 200 saved and max-age=3600; includeSubDomains.

    Test_App_Test_TLS covers an https:// target and a request with a TLS state set by hand (both fail on main), and keeps http:// and path-only targets on http. docs/api/app.md (Test) and docs/whats_new.md get one sentence each.

    Ran: go test ./... -count=1 -shuffle=on, golangci-lint run ./... (v2.14.0), gofumpt -extra=group_params -l ., go vet ./..., betteralign -test_files -generated_files ./... (v0.8.0), markdownlint-cli2 on the two docs files.

    Changes introduced

  • Benchmarks: Describe any performance benchmarks and improvements related to the changes.

  • Documentation Update: Detail the updates made to the documentation and links to the changed files.

  • Changelog/What's New: Include a summary of the additions for the upcoming release notes.

  • Migration Guide: If necessary, provide a guide or steps for users to migrate their existing code to accommodate these changes.

  • API Alignment with Express: Explain how the changes align with the Express API.

  • API Longevity: Discuss the steps taken to ensure that the new or updated APIs are consistent and not prone to breaking changes.

  • Examples: Provide examples demonstrating the new features or changes in action.
  • Type of change

  • Code consistency (non-breaking change which improves code reliability and robustness)
  • Checklist

  • Conducted a self-review of the code and provided comments for complex or critical parts.

  • Updated the documentation in the /docs/ directory for Fiber's documentation.

  • Added or updated unit tests to validate the effectiveness of the changes or new features.

  • Ensured that new and existing unit tests pass locally with the changes.

  • Aimed for optimal performance with minimal allocations in the new code.
  • <!-- pr-command-hint -->
    <sub>๐Ÿค– Maintainers: /generate re-runs the code generators on this branch</sub>

    Diff: 403 lines (+302 / -101) across 5 files Reviewer: nk-batman21 Review duration: 945m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.68) ร— (1 โˆ’ Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 ยท Change Risk (XGBoost)
    Score: 0.68 ยท 403 lines diff across 5 files
    0.68
    Model 2 ยท Review Depth (DistilBERT)
    Depth Score: 0.17 ยท 1 substantive comment(s)
    0.17
    Model 3 ยท Review Timing & Attention
    Session adequacy: 100% ยท Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 ยท Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 ยท Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.068
    Real PR Conversation Timeline
    1 comments
    "Review active on #4839"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk ยท Model 1 (XGBoost)
    Predicted defect probability (0.00โ€“1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 67.9% (HIGH) ยท Higher = larger blast radius
    67.9%
    Review Confidence
    Review Confidence ยท Models 2 & 3
    Scrutiny score (0.00โ€“1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% ยท Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk ยท Core Equation
    Residual = Change ร— (1 โˆ’ Confidence)
    Unmitigated risk surviving review. โ‰ฅ 0.65 triggers an automated re-queue to protect production.
    Score: 26.8% ยท Safe to merge
    26.8%
    Repository