@@ -21,6 +21,29 @@ public void AppendLargeCookie_Appended()
21
21
Assert . Equal ( "TestCookie=" + testString + "; path=/; samesite=lax" , values [ 0 ] ) ;
22
22
}
23
23
24
+ [ Fact ]
25
+ public void AppendLargeCookie_WithOptions_Appended ( )
26
+ {
27
+ HttpContext context = new DefaultHttpContext ( ) ;
28
+ var now = DateTimeOffset . UtcNow ;
29
+ var options = new CookieOptions
30
+ {
31
+ Domain = "foo.com" ,
32
+ HttpOnly = true ,
33
+ SameSite = SameSiteMode . Strict ,
34
+ Path = "/bar" ,
35
+ Secure = true ,
36
+ Expires = now . AddMinutes ( 5 ) ,
37
+ MaxAge = TimeSpan . FromMinutes ( 5 )
38
+ } ;
39
+ var testString = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
40
+ new ChunkingCookieManager ( ) { ChunkSize = null } . AppendResponseCookie ( context , "TestCookie" , testString , options ) ;
41
+
42
+ var values = context . Response . Headers [ "Set-Cookie" ] ;
43
+ Assert . Single ( values ) ;
44
+ Assert . Equal ( $ "TestCookie={ testString } ; expires={ now . AddMinutes ( 5 ) . ToString ( "R" ) } ; max-age=300; domain=foo.com; path=/bar; secure; samesite=strict; httponly", values [ 0 ] ) ;
45
+ }
46
+
24
47
[ Fact ]
25
48
public void AppendLargeCookieWithLimit_Chunked ( )
26
49
{
@@ -112,19 +135,19 @@ public void DeleteChunkedCookieWithOptions_AllDeleted()
112
135
HttpContext context = new DefaultHttpContext ( ) ;
113
136
context . Request . Headers . Append ( "Cookie" , "TestCookie=chunks-7" ) ;
114
137
115
- new ChunkingCookieManager ( ) . DeleteCookie ( context , "TestCookie" , new CookieOptions ( ) { Domain = "foo.com" } ) ;
138
+ new ChunkingCookieManager ( ) . DeleteCookie ( context , "TestCookie" , new CookieOptions ( ) { Domain = "foo.com" , Secure = true } ) ;
116
139
var cookies = context . Response . Headers [ "Set-Cookie" ] ;
117
140
Assert . Equal ( 8 , cookies . Count ) ;
118
141
Assert . Equal ( new [ ]
119
142
{
120
- "TestCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax" ,
121
- "TestCookieC1=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax" ,
122
- "TestCookieC2=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax" ,
123
- "TestCookieC3=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax" ,
124
- "TestCookieC4=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax" ,
125
- "TestCookieC5=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax" ,
126
- "TestCookieC6=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax" ,
127
- "TestCookieC7=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax" ,
143
+ "TestCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure; samesite=lax" ,
144
+ "TestCookieC1=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure; samesite=lax" ,
145
+ "TestCookieC2=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure; samesite=lax" ,
146
+ "TestCookieC3=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure; samesite=lax" ,
147
+ "TestCookieC4=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure; samesite=lax" ,
148
+ "TestCookieC5=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure; samesite=lax" ,
149
+ "TestCookieC6=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure; samesite=lax" ,
150
+ "TestCookieC7=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure; samesite=lax" ,
128
151
} , cookies ) ;
129
152
}
130
153
}
0 commit comments