@Provides
    public SecurityContext securityContext(final UserDao userDao,
                                           final AppPermissionDao appPermissionDao) {
        return new MockSecurityContext() {
            @Override
            public UserRef getUserRef() {
                final Optional<User> optionalGroup = userDao.getGroupByName(ADMINISTRATORS);
                final User group = optionalGroup.orElseGet(() -> {
                    final User user = User.builder()
                            .subjectId(ADMINISTRATORS)
                            .uuid(UUID.randomUUID().toString())
                            .group(true)
                            .build();
                    user.setCreateUser(ADMIN);
                    user.setUpdateUser(ADMIN);
                    user.setCreateTimeMs(System.currentTimeMillis());
                    user.setUpdateTimeMs(System.currentTimeMillis());
                    final User created = userDao.create(user);
                    appPermissionDao.addPermission(created.getUuid(), AppPermission.ADMINISTRATOR);
                    return created;
                });

                final Optional<User> optional = userDao.getUserBySubjectId(ADMIN);
                final User persisted = optional.orElseGet(() -> {
                    final User user = User.builder()
                            .subjectId(ADMIN)
                            .uuid(UUID.randomUUID().toString())
                            .group(false)
                            .build();
                    user.setCreateUser(ADMIN);
                    user.setUpdateUser(ADMIN);
                    user.setCreateTimeMs(System.currentTimeMillis());
                    user.setUpdateTimeMs(System.currentTimeMillis());
                    final User created = userDao.create(user);
                    userDao.addUserToGroup(created.getUuid(), group.getUuid());
                    return created;
                });
                return persisted.asRef();
            }
        };
    }
Another mock security context module but one that provides a real user for the purposes of DB correctness for
`runAsUser` processor filter and other task execution.
stroom-security/stroom-security-mock/src/main/java/stroom/security/mock/MockUserSecurityContextModule.java