1212
1313namespace xUnitTesting
1414{
15+
1516 public class RestServiceTest : MiddlewareTest
1617 {
1718 public RestServiceTest ( ) : base ( )
1819 {
1920 ClassLoader . FindType ( "apps.append" , "GeneXus.Programs.apps" , "append" , Assembly . GetExecutingAssembly ( ) , true ) ; //Force loading assembly for append procedure
2021 ClassLoader . FindType ( "apps.saveimage" , "GeneXus.Programs.apps" , "saveimage" , Assembly . GetExecutingAssembly ( ) , true ) ; //Force loading assembly for saveimage procedure
2122 server . AllowSynchronousIO = true ;
23+ ClassLoader . FindType ( "webhook" , "GeneXus.Programs" , "webhook" , Assembly . GetExecutingAssembly ( ) , true ) ; //Force loading assembly for webhook procedure
24+ server . AllowSynchronousIO = true ;
25+
2226 }
2327
2428 [ Fact ]
@@ -31,7 +35,7 @@ public async Task TestSimpleRestPost()
3135 Assert . Equal ( System . Net . HttpStatusCode . BadRequest , response . StatusCode ) ;
3236 }
3337
34- [ Fact ]
38+ [ Fact ( Skip = "Disable until solve concurrency issue" ) ]
3539 public async Task RunController ( )
3640 {
3741
@@ -60,7 +64,34 @@ public async Task RunController()
6064 client . DefaultRequestHeaders . Add ( "Cookie" , values ) ; // //cookies.GetCookieHeader(requestUriObj));
6165
6266 response = await client . PostAsync ( "rest/apps/saveimage" , body ) ;
63- //Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode);
67+ Assert . Equal ( System . Net . HttpStatusCode . OK , response . StatusCode ) ;
68+ }
69+ [ Fact ]
70+ public async Task HttpFirstPost ( )
71+ {
72+ HttpClient client = server . CreateClient ( ) ;
73+ HttpResponseMessage response = await client . PostAsync ( "webhook.aspx" , null ) ;
74+ IEnumerable < string > cookies = response . Headers . SingleOrDefault ( header => header . Key == "Set-Cookie" ) . Value ;
75+ foreach ( string cookie in cookies )
76+ {
77+ Assert . False ( cookie . StartsWith ( HttpHeader . X_GXCSRF_TOKEN ) ) ;
78+ }
79+ response . EnsureSuccessStatusCode ( ) ;
80+ Assert . Equal ( System . Net . HttpStatusCode . OK , response . StatusCode ) ;
81+ }
82+ [ Fact ]
83+ public async Task HttpFirstGet ( )
84+ {
85+ HttpClient client = server . CreateClient ( ) ;
86+ HttpResponseMessage response = await client . GetAsync ( "webhook.aspx" ) ;
87+ IEnumerable < string > cookies = response . Headers . SingleOrDefault ( header => header . Key == "Set-Cookie" ) . Value ;
88+ foreach ( string cookie in cookies )
89+ {
90+ Assert . False ( cookie . StartsWith ( HttpHeader . X_GXCSRF_TOKEN ) ) ;
91+ }
92+
93+ response . EnsureSuccessStatusCode ( ) ;
94+ Assert . Equal ( System . Net . HttpStatusCode . OK , response . StatusCode ) ;
6495 }
6596 }
6697}
0 commit comments