[ 
https://issues.apache.org/jira/browse/KNOX-3451?focusedWorklogId=1040789&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1040789
 ]

ASF GitHub Bot logged work on KNOX-3451:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Sep/26 17:56
            Start Date: 10/Sep/26 17:56
    Worklog Time Spent: 10m 
      Work Description: shreyaaryaofficial closed pull request #1390: 
KNOX-3451: Add unit tests for XForwardedHeaderRequestWrapper
URL: https://github.com/apache/knox/pull/1390




Issue Time Tracking
-------------------

    Worklog Id:     (was: 1040789)
    Time Spent: 20m  (was: 10m)

> Add unit tests for XForwardedHeaderRequestWrapper
> -------------------------------------------------
>
>                 Key: KNOX-3451
>                 URL: https://issues.apache.org/jira/browse/KNOX-3451
>             Project: Apache Knox
>          Issue Type: Improvement
>            Reporter: Raghav Maheshwari
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Add dedicated unit tests for `XForwardedHeaderRequestWrapper` to improve 
> unit-test coverage of the forwarded-header handling logic in Apache Knox.
> The `XForwardedHeaderRequestWrapper` class contains logic for generating and 
> handling forwarded request headers such as `X-Forwarded-For`, 
> `X-Forwarded-Proto`, `X-Forwarded-Port`, `X-Forwarded-Host`, 
> `X-Forwarded-Server`, and `X-Forwarded-Context`.
> Currently, the existing test coverage primarily exercises forwarded-header 
> behavior through the filter. Adding a dedicated unit test class for the 
> request wrapper will provide more focused coverage of the wrapper's 
> individual behaviors and edge cases.
> Proposed Change
> Add:
> `gateway-server-xforwarded-filter/src/test/java/org/apache/knox/gateway/filter/XForwardedHeaderRequestWrapperTest.java`
> The test class should cover the following scenarios:
> * Verify default `X-Forwarded-For` behavior when the header is not already 
> present.
> * Verify that an existing `X-Forwarded-For` value is preserved and the remote 
> address is appended appropriately.
> * Verify `X-Forwarded-Proto` generation for HTTP requests.
> * Verify `X-Forwarded-Proto` generation for HTTPS requests.
> * Verify default ports (`80` for HTTP and `443` for HTTPS).
> * Verify that an existing `X-Forwarded-Port` value is preserved.
> * Verify `X-Forwarded-Host` handling.
> * Verify case-insensitive forwarded-header lookup.
> * Verify `X-Forwarded-Context` generation from the request context path.
> * Verify service-context handling.
> * Verify service-name/context handling when enabled.
> * Verify `getHeaders()` returns the expected forwarded-header values.
> * Add regression coverage for host values containing port information.
> * Add edge-case coverage for IPv6-style host values if applicable to the 
> current implementation.
> Testing Approach
> Use the existing JUnit 4 and EasyMock testing conventions used by the 
> `gateway-server-xforwarded-filter` module.
> The tests should mock `HttpServletRequest` and verify the values exposed by 
> `XForwardedHeaderRequestWrapper`.
> No production-code changes are expected as part of this issue.
> Expected Outcome
> The change will provide direct unit-test coverage for 
> `XForwardedHeaderRequestWrapper`, making the forwarded-header behavior easier 
> to validate and reducing the risk of regressions when the request-wrapper 
> implementation is modified in the future.
> Acceptance Criteria
> * A dedicated `XForwardedHeaderRequestWrapperTest` test class is added.
> * Existing forwarded-header behavior is covered by focused unit tests.
> * HTTP and HTTPS scenarios are covered.
> * Existing and generated forwarded-header values are tested.
> * Context/service-name behavior is covered.
> * Header lookup behavior is tested.
> * Relevant edge cases are covered.
> * All existing tests continue to pass.
> * The new tests follow the existing Apache Knox test conventions.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to