kristofferahl/FluentSecurity — Issue #6: Testing issues
Author: viswaug
Created: 2011-10-18 20:41:33+00:00
State: open

Hi,

I currently have these expectations in my tests

expectations.Expect().Has();
expectations.Expect().Has();
expectations.Expect().Has();
expectations.Expect().Has();

The above expectations pass with the security config below

configuration.For().AddPolicy(MvcApplication.Container.Resolve());
configuration.For().AddPolicy(MvcApplication.Container.Resolve());
configuration.For().AddPolicy(MvcApplication.Container.Resolve());
configuration.For().AddPolicy(MvcApplication.Container.Resolve());

As soon as I add more policies to certain actions in my admin controller like below, the same tests fail. Am I doing anything wrong?

configuration.For().AddPolicy(MvcApplication.Container.Resolve());
configuration.For().AddPolicy(MvcApplication.Container.Resolve());
configuration.For().AddPolicy(MvcApplication.Container.Resolve());
configuration.For().AddPolicy(MvcApplication.Container.Resolve());

//Only allow the national admin to see errors in the appliation
configuration.For(x => x.Errors(null))
.RequireRole(RoleHelpers.NationalAdministrator);
//Only allow national or state admin to see the manage users page
configuration.For(x => x.Users(null, null, null, null, null))
.RequireRole(new string[] { RoleHelpers.NationalAdministrator, RoleHelpers.StateAdministrator });
//Only allow the national or state admin to see the edit user details page
configuration.For(x => x.User(string.Empty))
.RequireRole(new string[] { RoleHelpers.NationalAdministrator, RoleHelpers.StateAdministrator });

Am I doing something wrong here? Don't look like it... I add a base set of policies to all actions on a controller and add more targeted policies to some of the actions in the controller. I am not sure why adding the targeted policies to certain actions would cause the tests for the base policies added to the controller to fail... Any ideas or thoughts?

Thank You,
Vish