Skip to content

Commit 778a076

Browse files
committed
Release KnownUser v.3.7.0
1 parent 2088c64 commit 778a076

14 files changed

+2354
-2018
lines changed

QueueIT.KnownUserV3.SDK.Tests/IntegrationConfig/IntegrationConfigHelpersTest.cs

Lines changed: 422 additions & 353 deletions
Large diffs are not rendered by default.

QueueIT.KnownUserV3.SDK.Tests/KnownUserTest.cs

Lines changed: 165 additions & 111 deletions
Large diffs are not rendered by default.

QueueIT.KnownUserV3.SDK.Tests/UserInQueueServiceTest.cs

Lines changed: 77 additions & 69 deletions
Large diffs are not rendered by default.

QueueIT.KnownUserV3.SDK.Tests/UserInQueueStateCookieRepositoryTest.cs

Lines changed: 98 additions & 73 deletions
Large diffs are not rendered by default.

QueueIT.KnownUserV3.SDK/HttpContextProvider.cs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@
55

66
namespace QueueIT.KnownUserV3.SDK
77
{
8+
public class SDKInitializer
9+
{
10+
public static void SetHttpRequest(IHttpRequest httpRequest)
11+
{
12+
HttpContextProvider.SetHttpRequest(httpRequest);
13+
}
14+
}
15+
816
class HttpContextProvider : IHttpContextProvider
917
{
10-
public IHttpRequest HttpRequest { get; } = new HttpRequest();
18+
IHttpRequest _httpRequest;
19+
public IHttpRequest HttpRequest => _httpRequest ?? (_httpRequest = new HttpRequest());
20+
21+
IHttpResponse _httpResponse;
22+
public IHttpResponse HttpResponse => _httpResponse ?? (_httpResponse = new HttpResponse());
1123

12-
public IHttpResponse HttpResponse { get; } = new HttpResponse();
24+
public static IHttpContextProvider Instance { get; } = new HttpContextProvider();
1325

14-
public static IHttpContextProvider Instance { get; private set; } = new HttpContextProvider();
26+
public static void SetHttpRequest(IHttpRequest httpRequest)
27+
{
28+
((HttpContextProvider)Instance)._httpRequest = httpRequest;
29+
}
1530
}
1631

17-
class HttpRequest : IHttpRequest
32+
public class HttpRequest : IHttpRequest
1833
{
1934
public string UserAgent => HttpContext.Current.Request.UserAgent;
2035

@@ -31,24 +46,33 @@ public string GetCookieValue(string cookieKey)
3146
return null;
3247
return HttpUtility.UrlDecode(cookieValue);
3348
}
49+
50+
public virtual string GetRequestBodyAsString()
51+
{
52+
return string.Empty;
53+
}
3454
}
3555

36-
class HttpResponse : IHttpResponse
56+
internal class HttpResponse : IHttpResponse
3757
{
38-
public void SetCookie(string cookieName, string cookieValue, string domain, DateTime expiration)
58+
public void SetCookie(string cookieName, string cookieValue, string domain, DateTime expiration, bool isHttpOnly, bool isSecure)
3959
{
4060
if (HttpContext.Current.Response.
4161
Cookies.AllKeys.Any(key => key == KnownUser.QueueITDebugKey))
4262
{
4363
HttpContext.Current.Response.Cookies.Remove(KnownUser.QueueITDebugKey);
4464
}
65+
4566
var cookie = new HttpCookie(cookieName, Uri.EscapeDataString(cookieValue));
67+
4668
if (!string.IsNullOrEmpty(domain))
4769
{
4870
cookie.Domain = domain;
4971
}
50-
cookie.HttpOnly = false;
72+
cookie.HttpOnly = isHttpOnly;
73+
cookie.Secure = isSecure;
5174
cookie.Expires = expiration;
75+
5276
HttpContext.Current.Response.Cookies.Add(cookie);
5377
}
5478
}

0 commit comments

Comments
 (0)