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 6155817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:30:10+00:00 2026-05-23T20:30:10+00:00

I have a security rule that a newly registered user has full permissions over

  • 0

I have a security rule that a newly registered user has full permissions over their own user entity. I’m using Rhino.Security and the code works fine, but I want to create a unit test to make sure the appropriate call is made to setup the permission. Here is a simplified verison of the code:

public User Register(UserRegisterTask userRegistrationTask) {
   User user = User.Create(userRegistrationTask);
   this.userRepository.Save(user);

   // Give this user permission to do operations on itself
   this.permissionsBuilderService.Allow("Domain/User")
       .For(user)
       .On(user)
       .DefaultLevel()
       .Save();

   return user;
}

I’ve mocked the userRepository and the permissionBuilderService but the fluent interface of the permissionBuilderService requires different objects to be returned from each method call in the chain (i.e. .Allow(…).For(…).On(…) etc). But I can’t find a way to mock each of the objects in the chain.

Is there a way to test if the permissionBuilderService’s Allow method is being called but ignoring the rest of the chain?

Thanks
Dan

  • 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-05-23T20:30:11+00:00Added an answer on May 23, 2026 at 8:30 pm

    I also ran into this and ended up wrapping the Rhino Security functionality in a service layer for two reasons:

    1. It was making unit testing a real PITA and after spending a couple of hours hitting my head against a brick wall, this approach allowed me to mock this layer far more easily.
    2. I started to feel that Rhino Security was being coupled very tightly to my controller (my application uses MVC). Wrapping the calls in another layer allowed me looser coupling to a specific security implementation and will allow me to easily swap it out with another – if I so choose – in the future.

    Obviously, this is only one approach. But it made my life much easier…

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

Sidebar

Related Questions

This is a Spring Security question. In my application, I have a User entity
I have a security consultant demanding that we implement encrypted connections to mySQL. He
Is there a way to see users that have certain security role assigned? I'm
I use Spring Security 3 in my JSF2 webapp. I have a security rule
I have a web application that uses spring security. It uses <intercept-url ../> elements
I have a problem applying css to the web pages, using spring security (3.0.7
For my .net application i have a mechanism that creates a special user on
I'm using ASP.NET MVC2 RC and I have built security on top of the
greetings all, i am using spring security 3.0.2, urlRewrite 3.1.0 , and i have
I have a security manager in my application that works for both windows and

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.