Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:34:52+00:00 2026-06-04T18:34:52+00:00

I have been writing some tests on my Fluent Security configuration off late. Though

  • 0

I have been writing some tests on my Fluent Security configuration off late. Though I can write tests verifying if a controller action method has a particular policy applied e.g.

expectations.Expect<HomeController>(x=>x.Index()).Has<IgnorePolicy>();

However, what I am looking for is, if I can write role specific tests.

e.g If I have given Admin Role access only to Index() of HomeController, I want to test something like

expectations.Expect<HomeController>(x=>x.Index()).Has<RequireRolePolicy>().For("Admin");

I do not find any examples on net, or any extensions in FLuentSecurity.TestHelper that can help me do this. any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:34:54+00:00Added an answer on June 4, 2026 at 6:34 pm

    The Has extension has an overload that takes a predicate:

    expectations.Expect<HomeController>(x => x.Index())
        .Has<RequireRolePolicy>(policy => policy.RolesRequired.Contains("Admin"));
    

    As you can see the RequireRolePolicy exposes a RolesRequired property that you can test against.

    If you find yourself doing a lot of checking for a particular set of roles I would recommend creating a custom policy and just check for that policy instead. There’s an example of this (an AdministratorPolicy) in the sample application on github: https://github.com/kristofferahl/FluentSecurity/blob/master/FluentSecurity.SampleApplication/AdministratorPolicy.cs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing some rspec tests, and right now I want to verify
I have just been writing some tests when a fundamental problem emerged. I wrote
I have been writing some code to create a byte array I will be
I have been messing around with writing some stored procedures in .NET code with
I've been writing some jQuery functions that have JavaScript variables and looping, etc inside
I have been given the task of re-writing some libraries written in C# so
I have been writing unit tests using NUnit and Moq with my Silverlight code
I'm writing some integration tests using a robot. I have the robot opening a
I have been having a query regarding writing unit tests for web methods which
I have a simpletest suite I've been working on writing for some of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.