Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie Path Attribute Missing in HttpRequest When Using TestRequest #3493

Open
3schwartz opened this issue Nov 1, 2024 · 0 comments
Open

Comments

@3schwartz
Copy link

3schwartz commented Nov 1, 2024

When using TestRequest to set a cookie with a specified path, the path information is not retained when building the `HttpRequest. This results in the path attribute missing in the generated cookie, causing inconsistencies in test environments compared to actual application logic.

Expected Behavior

The HttpRequest should retain all cookie attributes, including the path, as defined when setting the cookie in TestRequest`.

Current Behavior

The cookie path is missing in the generated HttpRequest cookie, even when explicitly set in TestRequest`.

Steps to Reproduce (for bugs)

Here is a minimal example demonstrating the issue (currently the test fails):

    #[test]
    fn test_missing_cookie_path() {
        // Arrange
        let cookie = Cookie::build("name", "value").path("/somepath").finish();

        // Act
        let req = TestRequest::default().cookie(cookie).to_http_request();

        // Assert
        let cookies = req.cookies().unwrap();
        assert_eq!(cookies.len(), 1);
        let cookie = &cookies[0];
        assert!(cookie.path().is_some());
    }

Your Environment

  • Rust Version (I.e, output of rustc -V): rustc 1.82.0
  • Actix Web Version: 4.9.0
@3schwartz 3schwartz changed the title Cookie path missing in HttpRequest when using TestRequest Cookie Path Attribute Missing in HttpRequest When Using TestRequest Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant