11using System ;
22using System . Collections . Generic ;
3+ using System . Net ;
34using System . Text ;
45using System . Threading ;
56using System . Threading . Tasks ;
67using GeneXus . Application ;
78using GeneXus . Encryption ;
89using GeneXus . Http ;
9- using GeneXus . Utils ;
1010using Microsoft . AspNetCore . Http ;
1111using Xunit ;
1212
@@ -22,6 +22,15 @@ public async Task TestSessionRenew()
2222
2323 await authMiddleware . Invoke ( httpContext ) ;
2424 }
25+ [ Fact ]
26+ public async Task TestSessionCookieContainer ( )
27+ {
28+ var httpContext = new DefaultHttpContext ( ) { Session = new MockHttpSession ( ) } ;
29+ var authMiddleware = new MyAuthMiddleware ( next : ( innerHttpContext ) => Task . FromResult ( 0 ) ) ;
30+
31+ await authMiddleware . SessionCookieContainerSerialization ( httpContext ) ;
32+ }
33+
2534 }
2635 public class MyAuthMiddleware
2736 {
@@ -31,6 +40,22 @@ public MyAuthMiddleware(RequestDelegate next)
3140 {
3241 _next = next ;
3342 }
43+ public async Task SessionCookieContainerSerialization ( HttpContext context )
44+ {
45+ GxContext gxcontext = new GxContext ( ) ;
46+ gxcontext . HttpContext = context ;
47+ string url = "https://test.net" ;
48+ CookieContainer container = gxcontext . GetCookieContainer ( url , true ) ;
49+ Cookie cookie = new Cookie ( "ROUTEID" , ".http3" ) ;
50+ cookie . Path = "/" ;
51+ cookie . Expires = DateTime . MinValue ;
52+ cookie . Domain = "test.net" ;
53+ container . Add ( cookie ) ;
54+ gxcontext . UpdateSessionCookieContainer ( ) ;
55+ container = gxcontext . GetCookieContainer ( url , true ) ;
56+ Assert . Equal ( 1 , container . Count ) ;
57+ await _next ( context ) ;
58+ }
3459
3560 public async Task Invoke ( HttpContext context )
3661 {
0 commit comments