IN the past I ran into issues with users testing as global admin in my multitenant setup. I there now enforce non-nullability on all my business entities.
I was using the generated AuthenticatedAsTestUser as documented. This of course no longer works and all my tests fail. I need to have a tenant user with full-access-role.
I see a few options in how to resolve this
- insert a tenant user, test|user
- mock out one of the security related classes.
- provide an additional AuthenticationProvider as a test component.
What is the recommended approach, and do you happen to have a sample?
UPDATE
I experimented a bit and changed my mind on how to solve this.
My initial concern was just to get an authenticated user. But If in option 2 and 3, there Is no actual user in the db and it will cause other problems.
In addition I also want to be able to write simple security tests by setting up
- user with a role, action allowed
- user without role action disallowed