forked from FubuMvcArchive/FubuMVC.AntiForgery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto adding the AntiForgeryPolicy. Closes FubuMvcArchiveGH-4
- Loading branch information
1 parent
9f1213d
commit 0b78275
Showing
5 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
61 changes: 61 additions & 0 deletions
61
src/FubuMVC.AntiForgery.Testing/Default_policy_applies_anti_forgery_to_post_routes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Linq; | ||
using FubuMVC.Core; | ||
using FubuMVC.Core.Registration; | ||
using FubuMVC.StructureMap; | ||
using FubuTestingSupport; | ||
using HtmlTags; | ||
using NUnit.Framework; | ||
using StructureMap; | ||
|
||
namespace FubuMVC.AntiForgery.Testing | ||
{ | ||
[TestFixture] | ||
public class Default_policy_applies_anti_forgery_to_post_routes | ||
{ | ||
[Test] | ||
public void the_order_of_the_configuration_action_was_wrong() | ||
{ | ||
var registry = new FubuRegistry(); | ||
registry.Actions.IncludeType<TestEndpoint>(); | ||
using (var runtime = FubuApplication.For(registry).ContainerFacility(new StructureMapContainerFacility(new Container())).Bootstrap()) | ||
{ | ||
var graph = runtime.Factory.Get<BehaviorGraph>(); | ||
|
||
graph.BehaviorFor<TestEndpoint>(x => x.post_csrf(null)) | ||
.OfType<AntiForgeryNode>().Any() | ||
.ShouldBeTrue(); | ||
} | ||
|
||
|
||
} | ||
} | ||
|
||
public class TestEndpoint | ||
{ | ||
public HtmlTag post_csrf(PostRequest request) | ||
{ | ||
return new HtmlTag("h1", h => h.Text("POST HOLA")); | ||
} | ||
|
||
public HtmlTag get_csrf(GetRequest request) | ||
{ | ||
return new HtmlTag("h1", h => h.Text("GET HOLA")); | ||
} | ||
} | ||
|
||
public class GetResult | ||
{ | ||
} | ||
|
||
public class GetRequest | ||
{ | ||
} | ||
|
||
public class PostRequest | ||
{ | ||
} | ||
|
||
public class PostResult | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters