11// Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
4+ using System ;
45using System . Text ;
56using Microsoft . AspNetCore . Http . Internal ;
67using Microsoft . Extensions . ObjectPool ;
@@ -27,6 +28,35 @@ public void DeleteCookieShouldSetDefaultPath()
2728 Assert . Contains ( "expires=Thu, 01 Jan 1970 00:00:00 GMT" , cookieHeaderValues [ 0 ] ) ;
2829 }
2930
31+ [ Fact ]
32+ public void DeleteCookieWithCookieOptionsShouldKeepPropertiesOfCookieOptions ( )
33+ {
34+ var headers = new HeaderDictionary ( ) ;
35+ var cookies = new ResponseCookies ( headers , null ) ;
36+ var testcookie = "TestCookie" ;
37+ var time = new DateTimeOffset ( 2000 , 1 , 1 , 1 , 1 , 1 , 1 , TimeSpan . Zero ) ;
38+ var options = new CookieOptions
39+ {
40+ Secure = true ,
41+ HttpOnly = true ,
42+ Path = "/" ,
43+ Expires = time ,
44+ Domain = "example.com" ,
45+ SameSite = SameSiteMode . Lax
46+ } ;
47+
48+ cookies . Delete ( testcookie , options ) ;
49+
50+ var cookieHeaderValues = headers [ HeaderNames . SetCookie ] ;
51+ Assert . Equal ( 1 , cookieHeaderValues . Count ) ;
52+ Assert . StartsWith ( testcookie , cookieHeaderValues [ 0 ] ) ;
53+ Assert . Contains ( "path=/" , cookieHeaderValues [ 0 ] ) ;
54+ Assert . Contains ( "expires=Thu, 01 Jan 1970 00:00:00 GMT" , cookieHeaderValues [ 0 ] ) ;
55+ Assert . Contains ( "secure" , cookieHeaderValues [ 0 ] ) ;
56+ Assert . Contains ( "httponly" , cookieHeaderValues [ 0 ] ) ;
57+ Assert . Contains ( "samesite" , cookieHeaderValues [ 0 ] ) ;
58+ }
59+
3060 [ Fact ]
3161 public void NoParamsDeleteRemovesCookieCreatedByAdd ( )
3262 {
0 commit comments