@@ -315,11 +315,8 @@ public async Task Invoke_WithEndpoint_DoesNotThrowIfUnhandledCorsAttributesWereF
315315 Assert . True ( calledEndpoint ) ;
316316 }
317317
318- [ Theory ]
319- [ InlineData ( "POST" ) ]
320- [ InlineData ( "PUT" ) ]
321- [ InlineData ( "PATCH" ) ]
322- public async Task Invoke_WithEndpoint_ThrowsIfAntiforgeryMetadataWasFound_ButAntiforgeryMiddlewareNotInvoked_ForValidHttpMethods ( string method )
318+ [ Fact ]
319+ public async Task Invoke_WithEndpoint_ThrowsIfAntiforgeryMetadataWasFound_ButAntiforgeryMiddlewareNotInvoked ( )
323320 {
324321 // Arrange
325322 var expected = "Endpoint Test contains anti-forgery metadata, but a middleware was not found that supports anti-forgery." +
@@ -338,7 +335,6 @@ public async Task Invoke_WithEndpoint_ThrowsIfAntiforgeryMetadataWasFound_ButAnt
338335 } ;
339336
340337 httpContext . SetEndpoint ( new Endpoint ( throwIfCalled , new EndpointMetadataCollection ( AntiforgeryMetadata . ValidationRequired ) , "Test" ) ) ;
341- httpContext . Request . Method = method ;
342338
343339 var middleware = new EndpointMiddleware ( NullLogger < EndpointMiddleware > . Instance , throwIfCalled , RouteOptions ) ;
344340
@@ -349,39 +345,6 @@ public async Task Invoke_WithEndpoint_ThrowsIfAntiforgeryMetadataWasFound_ButAnt
349345 Assert . Equal ( expected , ex . Message ) ;
350346 }
351347
352- [ Theory ]
353- [ InlineData ( "GET" ) ]
354- [ InlineData ( "TRACE" ) ]
355- [ InlineData ( "HEAD" ) ]
356- [ InlineData ( "OPTIONS" ) ]
357- [ InlineData ( "DELETE" ) ]
358- [ InlineData ( "CONNECT" ) ]
359- public async Task Invoke_WithEndpoint_WorksIfAntiforgeryMetadataWasFound_ButAntiforgeryMiddlewareNotInvoked_ForInvalidHttpMethods ( string method )
360- {
361- // Arrange
362- var message = "Should be called" ;
363- var httpContext = new DefaultHttpContext
364- {
365- RequestServices = new ServiceProvider ( )
366- } ;
367-
368- RequestDelegate throwIfCalled = ( c ) =>
369- {
370- throw new InvalidTimeZoneException ( message ) ;
371- } ;
372-
373- httpContext . SetEndpoint ( new Endpoint ( throwIfCalled , new EndpointMetadataCollection ( AntiforgeryMetadata . ValidationRequired ) , "Test" ) ) ;
374- httpContext . Request . Method = method ;
375-
376- var middleware = new EndpointMiddleware ( NullLogger < EndpointMiddleware > . Instance , throwIfCalled , RouteOptions ) ;
377-
378- // Act & Assert
379- var ex = await Assert . ThrowsAsync < InvalidTimeZoneException > ( ( ) => middleware . Invoke ( httpContext ) ) ;
380-
381- // Assert
382- Assert . Equal ( message , ex . Message ) ;
383- }
384-
385348 [ Fact ]
386349 public async Task Invoke_WithEndpoint_WorksIfAntiforgeryMetadataWasFound_AndAntiforgeryMiddlewareInvoked ( )
387350 {
0 commit comments