Skip to content

Commit a459530

Browse files
committed
Additional tests
1 parent 6ef3981 commit a459530

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
@@ -68,6 +68,37 @@ public async Task Can_Perform_POST_Async_With_RedirectionResponse_Cookies() {
6868
response.Content.Should().Be("[\"redirectCookie=value1\"]", "was successfully redirected to get-cookies");
6969
}
7070

71+
[Fact]
72+
public async Task Can_Perform_POST_Async_With_SeeOtherRedirectionResponse_Cookies() {
73+
var request = new RestRequest("/post/set-cookie-seeother") {
74+
Method = Method.Post,
75+
};
76+
77+
var response = await _client.ExecuteAsync(request);
78+
// Verify the cookie exists from the POST:
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("seeOtherValue1");
82+
// Make sure the redirected location spits out the correct content:
83+
response.Content.Should().Be("[\"redirectCookie=seeOtherValue1\"]", "was successfully redirected to get-cookies");
84+
}
85+
86+
[Fact]
87+
public async Task Can_Perform_PUT_Async_With_RedirectionResponse_Cookies() {
88+
var request = new RestRequest("/put/set-cookie-redirect") {
89+
Method = Method.Put,
90+
};
91+
92+
var response = await _client.ExecuteAsync(request);
93+
// Verify the cookie exists from the PUT:
94+
response.Cookies.Count.Should().BeGreaterThan(0).And.Be(1);
95+
response.Cookies[0].Name.Should().Be("redirectCookie");
96+
response.Cookies[0].Value.Should().Be("putCookieValue1");
97+
// However, the redirection location should have been a 404:
98+
// Make sure the redirected location spits out the correct content from PUT /get-cookies:
99+
response.StatusCode.Should().Be(HttpStatusCode.MethodNotAllowed);
100+
}
101+
71102
class Response {
72103
public string? Message { get; set; }
73104
}

0 commit comments

Comments
 (0)