programWideAuthentication function

Authentication? programWideAuthentication()

The authentication outside every scope: who all the code that runs outside a request (and outside withMockUser) acts as, or null.

On a server it is null unless the application means otherwise; check it after a test that makes requests, or in a tearDown:

tearDown(() => expect(programWideAuthentication(), isNull));

With a strategy of the application's own (not the default ZoneSecurityContextHolderStrategy) it is the authentication of the current context.

Implementation

Authentication? programWideAuthentication() =>
    switch (SecurityContextHolder.getContextHolderStrategy()) {
      final ZoneSecurityContextHolderStrategy zone =>
        zone.programWideAuthentication,
      final other => other.getContext().authentication,
    };