Hyper quick post for the morning π – I have once again been tasked with security related work in Sitecore. I know there are many approaches to this – wrapping, Virtual Users (which requires dummy config) , but on this occasion (have done it a few times before too) I am not particularly interested in interrogating the user once I have finished with it – just ‘mocking’ / stubbing one as an argument or a return. So I thought I use this:
public class TestUser : User { public TestUser(string name, bool isAuthenticated) : base(name, isAuthenticated) { } }
Works a treat π
I was just about to shy away from doing this exact same thing in case it created some weird behavior. But if it gets your seal of approval, then it’s OK with me π
The user should only really be used as an input for methods etc that you are mocking.