How to write Controller tests for actions requiring authentication?

I haven’t been able to find any documentation regarding this while I think it is quite a common use case. Most websites have some form of authentication or access control and being able to test this could improve our workflow significantly.

I think one approach could be to mock our Authentication service, but this is also difficult given that it is retrieved through the service manager.

Did anyone implement a somewhat similar test in their open source repository that I can check out?