예제 #1
0
 public void unsignedInputCookiesAreIgnored()
 {
     var app = new SessionCookieTestApp();
     app.inboundSession = "before";
     var request = new HttpRequestMessage(HttpMethod.Get, "http://xyz.com/");
     request.Headers.Add("Cookie", "session=random_value");
     var response = testServerGet(app.CaptureInbound, request);
     Assert.IsTrue(response.IsSuccessStatusCode);
     Assert.IsNull(app.inboundSession);
 }
예제 #2
0
 public void responseBodyIsReturnedThroughMiddleware()
 {
     var app = new SessionCookieTestApp();
     app.inboundSession = "before";
     var request = new HttpRequestMessage(HttpMethod.Get, "http://xyz.com/");
     request.Headers.Add("Cookie", "session=random_value");
     var response = testServerGet(app.CaptureInbound, request);
     Assert.IsTrue(response.IsSuccessStatusCode);
     Assert.AreEqual(app.responseBody, response.Content.ReadAsStringAsync().Result);
 }
예제 #3
0
 public void downstreamEnvBecomesOutputCookie()
 {
     var startApp = new SessionCookieTestApp();
     var request = new HttpRequestMessage(HttpMethod.Get, "http://xyz.com/");
     var response = testServerGet(startApp.SetOutbound, request);
     Assert.IsTrue(response.IsSuccessStatusCode);
     Assert.IsTrue(response.Headers.Contains("set-cookie"));
     var cookieName = "session";
     string cookieValue = extractCookie(response, cookieName);
     Assert.IsNotNull(cookieValue, "A cookie was expected but not found");
     Assert.AreEqual(startApp.sessionData, cookieValue);
 }
예제 #4
0
 public void signedInputCookiesAreAvailableDownstream()
 {
     var startApp = new SessionCookieTestApp();
     string inputValue = "some stuff";
     var signed = SignedString.sign(inputValue, startApp.passPhrase);
     var encoded = Uri.EscapeDataString(signed);
     var request = new HttpRequestMessage(HttpMethod.Get, "http://xyz.com/");
     request.Headers.Add("Cookie", string.Format("session={0}", encoded));
     var response = testServerGet(startApp.CaptureInbound, request);
     Assert.IsTrue(response.IsSuccessStatusCode);
     Assert.AreEqual(inputValue, startApp.inboundSession);
 }