@@ -11,33 +11,13 @@ namespace NuGetGallery.Cookies
1111{
1212 public class CookieExpirationServiceFacts
1313 {
14- [ Fact ]
15- public void CreateCookieExpirationService_ThrowsIfDomainNull ( )
16- {
17- // Arrange, Act & Assert
18- var exception = Assert . Throws < ArgumentException > ( ( ) => new CookieExpirationService ( domain : null ) ) ;
19-
20- Assert . Equal ( "domain" , exception . ParamName ) ;
21- Assert . Contains ( "The argument cannot be null or empty" , exception . Message ) ;
22- }
23-
24- [ Fact ]
25- public void CreateCookieExpirationService_ThrowsIfDomainEmpty ( )
26- {
27- // Arrange, Act & Assert
28- var exception = Assert . Throws < ArgumentException > ( ( ) => new CookieExpirationService ( domain : "" ) ) ;
29-
30- Assert . Equal ( "domain" , exception . ParamName ) ;
31- Assert . Contains ( "The argument cannot be null or empty" , exception . Message ) ;
32- }
33-
3414 public class TheExpireAnalyticsCookiesMethod
3515 {
3616 [ Fact ]
3717 public void ExpireAnalyticsCookies_ThrowsIfHttpContextNull ( )
3818 {
3919 // Arrange
40- var cookieExpirationService = new CookieExpirationService ( "AnyDomain" ) ;
20+ var cookieExpirationService = new CookieExpirationService ( ) ;
4121
4222 // Act & Assert
4323 var exception = Assert . Throws < ArgumentNullException > ( ( ) => cookieExpirationService . ExpireAnalyticsCookies ( httpContext : null ) ) ;
@@ -58,9 +38,8 @@ public void ExpireAnalyticsCookies()
5838 } ;
5939
6040 var httpContext = GetHttpContext ( cookies ) ;
61- var domain = "subdomain.domain.test" ;
62- var rootDomain = "domain.test" ;
63- var cookieExpirationService = new CookieExpirationService ( domain ) ;
41+
42+ var cookieExpirationService = new CookieExpirationService ( ) ;
6443
6544 // Act
6645 cookieExpirationService . ExpireAnalyticsCookies ( httpContext ) ;
@@ -72,16 +51,8 @@ public void ExpireAnalyticsCookies()
7251 Assert . NotNull ( responseCookie ) ;
7352 Assert . True ( DateTime . Equals ( new DateTime ( 2010 , 1 , 1 ) , responseCookie . Expires ) ) ;
7453 Assert . Equal ( cookies [ key ] , responseCookie . Value ) ;
54+ Assert . Null ( responseCookie . Domain ) ;
7555 }
76-
77- var _gaCookie = httpContext . Response . Cookies [ "_ga" ] ;
78- Assert . Equal ( rootDomain , _gaCookie . Domain ) ;
79- var _gidCookie = httpContext . Response . Cookies [ "_gid" ] ;
80- Assert . Equal ( rootDomain , _gidCookie . Domain ) ;
81- var _gatCookie = httpContext . Response . Cookies [ "_gat" ] ;
82- Assert . Equal ( rootDomain , _gatCookie . Domain ) ;
83- Assert . Null ( httpContext . Response . Cookies [ "ai_user" ] . Domain ) ;
84- Assert . Null ( httpContext . Response . Cookies [ "ai_session" ] . Domain ) ;
8556 }
8657 }
8758
@@ -91,7 +62,7 @@ public class TheExpireCookieByNameMethod
9162 public void ExpireCookieByName_ThrowsIfHttpContextNull ( )
9263 {
9364 // Arrange
94- var cookieExpirationService = new CookieExpirationService ( "AnyDomain" ) ;
65+ var cookieExpirationService = new CookieExpirationService ( ) ;
9566
9667 // Act & Assert
9768 var exception = Assert . Throws < ArgumentNullException > ( ( ) => cookieExpirationService . ExpireCookieByName ( httpContext : null , cookieName : It . IsAny < string > ( ) ) ) ;
@@ -102,7 +73,7 @@ public void ExpireCookieByName_ThrowsIfHttpContextNull()
10273 public void ExpireCookieByName_ThrowsIfCookieNameNull ( )
10374 {
10475 // Arrange
105- var cookieExpirationService = new CookieExpirationService ( "AnyDomain" ) ;
76+ var cookieExpirationService = new CookieExpirationService ( ) ;
10677
10778 // Act & Assert
10879 var exception = Assert . Throws < ArgumentException > ( ( ) => cookieExpirationService . ExpireCookieByName ( httpContext : Mock . Of < HttpContextBase > ( ) , cookieName : null ) ) ;
@@ -114,7 +85,7 @@ public void ExpireCookieByName_ThrowsIfCookieNameNull()
11485 public void ExpireCookieByName_ThrowsIfCookieNameEmpty ( )
11586 {
11687 // Arrange
117- var cookieExpirationService = new CookieExpirationService ( "AnyDomain" ) ;
88+ var cookieExpirationService = new CookieExpirationService ( ) ;
11889
11990 // Act & Assert
12091 var exception = Assert . Throws < ArgumentException > ( ( ) => cookieExpirationService . ExpireCookieByName ( httpContext : Mock . Of < HttpContextBase > ( ) , cookieName : "" ) ) ;
@@ -127,7 +98,7 @@ public void ExpireCookieByName_ReturnsIfRequestNull()
12798 {
12899 // Arrange
129100 var httpContext = new Mock < HttpContextBase > ( ) ;
130- var cookieExpirationService = new CookieExpirationService ( "AnyDomain" ) ;
101+ var cookieExpirationService = new CookieExpirationService ( ) ;
131102
132103 // Act & Assert
133104 cookieExpirationService . ExpireCookieByName ( httpContext . Object , "AnyCookieName" ) ;
@@ -139,7 +110,7 @@ public void ExpireCookieByName_ReturnsIfResponseNull()
139110 // Arrange
140111 var httpContext = new Mock < HttpContextBase > ( ) ;
141112 httpContext . Setup ( c => c . Request ) . Returns ( Mock . Of < HttpRequestBase > ( ) ) ;
142- var cookieExpirationService = new CookieExpirationService ( "AnyDomain" ) ;
113+ var cookieExpirationService = new CookieExpirationService ( ) ;
143114
144115 // Act & Assert
145116 cookieExpirationService . ExpireCookieByName ( httpContext . Object , "AnyCookieName" ) ;
@@ -152,7 +123,7 @@ public void ExpireCookieByName_ReturnsIfRequestCookiesNull()
152123 var httpContext = new Mock < HttpContextBase > ( ) ;
153124 httpContext . Setup ( c => c . Request ) . Returns ( Mock . Of < HttpRequestBase > ( ) ) ;
154125 httpContext . Setup ( c => c . Response ) . Returns ( Mock . Of < HttpResponseBase > ( ) ) ;
155- var cookieExpirationService = new CookieExpirationService ( "AnyDomain" ) ;
126+ var cookieExpirationService = new CookieExpirationService ( ) ;
156127
157128 // Act & Assert
158129 cookieExpirationService . ExpireCookieByName ( httpContext . Object , "AnyCookieName" ) ;
@@ -171,15 +142,15 @@ public void ExpireCookieByName_ReturnsIfResponseCookiesNull()
171142 httpContext . Setup ( c => c . Request ) . Returns ( httpRequest . Object ) ;
172143 httpContext . Setup ( c => c . Response ) . Returns ( Mock . Of < HttpResponseBase > ( ) ) ;
173144
174- var cookieExpirationService = new CookieExpirationService ( "AnyDomain" ) ;
145+ var cookieExpirationService = new CookieExpirationService ( ) ;
175146
176147 // Act & Assert
177148 cookieExpirationService . ExpireCookieByName ( httpContext . Object , "AnyCookieName" ) ;
178149 }
179150
180151 [ Theory ]
181152 [ InlineData ( null ) ]
182- [ InlineData ( "AnyDomain " ) ]
153+ [ InlineData ( "anyspecificdomain " ) ]
183154 public void ExpireCookieByName ( string domain )
184155 {
185156 // Arrange
@@ -190,7 +161,7 @@ public void ExpireCookieByName(string domain)
190161 { cookieName , cookieValue }
191162 } ;
192163 var httpContext = GetHttpContext ( cookies ) ;
193- var cookieExpirationService = new CookieExpirationService ( "AnyDomain" ) ;
164+ var cookieExpirationService = new CookieExpirationService ( ) ;
194165
195166 // Act
196167 cookieExpirationService . ExpireCookieByName ( httpContext , cookieName , domain ) ;
0 commit comments