Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure request body is correctly propagated in Nighthawk Request Sour…
…ce. (#1289) * Ensure request body is correctly propagated in Nighthawk Request Source. Previously, requests generated by `OptionsListRequestSource` did not correctly set the request body, leading to empty payloads when using `json_body`. This CL ensures that `json_body` is correctly propagated from `RequestOptionsList` to `RequestImpl`, aligning request behavior with expectations. ### Changes: - **Updated Request interface (`request.h`)**: Added `body()` as a pure virtual method. - **Modified `RequestImpl` (`request_impl.h` & `request_impl.cc`)**: - Updated the constructor to accept `json_body_` as an argument. - Implemented `body()` to return `json_body_` instead of an empty string. - **Fixed `OptionsListRequestSource::get()`**: - Now correctly assigns `json_body` when creating `RequestImpl`. - Ensures request bodies are set properly instead of being empty. - **Fixed `RemoteRequestSourceImpl::get()`**: - Ensures that request bodies from gRPC sources are also correctly populated. - **Updated `request_source_plugin_test.cc`**: - Modified tests to verify that `request3->body()` is correctly set. - Ensured `request3` is not `nullptr` and contains the expected `json_body`. ### **Why This Change?** Without this fix, request bodies remain empty despite being set in the configuration (`RequestOptionsList`). This caused inconsistencies in request generation. This CL ensures that the body is always populated correctly, improving reliability. ### **Testing:** - Verified that `json_body` is correctly loaded from the YAML file. - Confirmed `request3->body()` now returns the expected JSON payload. - Ran tests on Cider-V, all passed successfully. This change ensures that request generation works as expected and aligns with the intended behavior. Signed-off-by: pelinthecoder <[email protected]> * Update request_source_impl.cc Signed-off-by: Pelinthecoder <[email protected]> * Update request_source_plugin_test.cc Signed-off-by: Pelinthecoder <[email protected]> * Add json body for OptionsListRequestSource::get Signed-off-by: pelinthecoder <[email protected]> * Remove move for string value Signed-off-by: pelinthecoder <[email protected]> * Add json body under options.proto Signed-off-by: pelinthecoder <[email protected]> * Fixes the include statements under the test file Signed-off-by: pelinthecoder <[email protected]> * Fixes external envoy includes in the test Signed-off-by: pelinthecoder <[email protected]> * add semicolon Signed-off-by: pelinthecoder <[email protected]> * modify request body size to account for json body Signed-off-by: pelinthecoder <[email protected]> * modifying the request body size again Signed-off-by: pelinthecoder <[email protected]> * Fix test for json body Signed-off-by: pelinthecoder <[email protected]> * test option request body size to reflect json length Signed-off-by: pelinthecoder <[email protected]> * fixing the format Signed-off-by: pelinthecoder <[email protected]> * Added tests for json bodies Signed-off-by: pelinthecoder <[email protected]> * fix header import order to satisfy lint Signed-off-by: pelinthecoder <[email protected]> * Recovered the working request_source_impl, added tests Signed-off-by: pelinthecoder <[email protected]> * Fixes format Signed-off-by: pelinthecoder <[email protected]> --------- Signed-off-by: pelinthecoder <[email protected]> Signed-off-by: Pelinthecoder <[email protected]>
- Loading branch information