Skip to content

Commit 7069e75

Browse files
committed
Additional tests
1 parent 40f6981 commit 7069e75

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/RestSharp.Tests.Integrated/RedirectTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,37 @@ public async Task Can_Perform_POST_Async_With_RedirectionResponse_Cookies() {
5353
response.Content.Should().Be("[\"redirectCookie=value1\"]", "was successfully redirected to get-cookies");
5454
}
5555

56+
[Fact]
57+
public async Task Can_Perform_POST_Async_With_SeeOtherRedirectionResponse_Cookies() {
58+
var request = new RestRequest("/post/set-cookie-seeother") {
59+
Method = Method.Post,
60+
};
61+
62+
var response = await _client.ExecuteAsync(request);
63+
// Verify the cookie exists from the POST:
64+
response.Cookies.Count.Should().BeGreaterThan(0).And.Be(1);
65+
response.Cookies[0].Name.Should().Be("redirectCookie");
66+
response.Cookies[0].Value.Should().Be("seeOtherValue1");
67+
// Make sure the redirected location spits out the correct content:
68+
response.Content.Should().Be("[\"redirectCookie=seeOtherValue1\"]", "was successfully redirected to get-cookies");
69+
}
70+
71+
[Fact]
72+
public async Task Can_Perform_PUT_Async_With_RedirectionResponse_Cookies() {
73+
var request = new RestRequest("/put/set-cookie-redirect") {
74+
Method = Method.Put,
75+
};
76+
77+
var response = await _client.ExecuteAsync(request);
78+
// Verify the cookie exists from the PUT:
79+
response.Cookies.Count.Should().BeGreaterThan(0).And.Be(1);
80+
response.Cookies[0].Name.Should().Be("redirectCookie");
81+
response.Cookies[0].Value.Should().Be("putCookieValue1");
82+
// However, the redirection location should have been a 404:
83+
// Make sure the redirected location spits out the correct content from PUT /get-cookies:
84+
response.StatusCode.Should().Be(HttpStatusCode.MethodNotAllowed);
85+
}
86+
5687
class Response {
5788
public string? Message { get; set; }
5889
}

0 commit comments

Comments
 (0)