public string GetUserUniqueIdFromCookie(HttpContextBase httpContext) { HttpCookie cookie = httpContext.Request.Cookies[COOKIE_NAME]; string result = null; if (cookie != null) { result = cookie.Value != null?cookie.Value.ToLower() : null; if (!_userUniqueId.IsValid(result)) { result = null; } if (result != null && !string.Equals(WebSettingsConfig.Instance.CookieWideDomain, cookie.Domain, StringComparison.InvariantCultureIgnoreCase)) { //кука весит не на том домене - перевесить куку AddCookie(httpContext, result); } } return(result); }
public void IsValid(string hash, bool expectedResult) { var userUniqueId = new UserUniqueId(); bool result = userUniqueId.IsValid(hash); Assert.That(result, Is.EqualTo(expectedResult)); }