Class TestAuthenticationUtilsImpl

  • All Implemented Interfaces:
    org.springframework.beans.factory.InitializingBean, TestAuthenticationUtils

    @Service
    public class TestAuthenticationUtilsImpl
    extends Object
    implements org.springframework.beans.factory.InitializingBean, TestAuthenticationUtils
    Utilities for manipulating the SecurityContextHolder in a test envirnoment.
    Author:
    poirigui
    • Constructor Detail

      • TestAuthenticationUtilsImpl

        public TestAuthenticationUtilsImpl()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      • runAsAdmin

        public void runAsAdmin()
        Elevate to administrative privileges (tests normally run this way, this can be used to set it back if you called runAsUser). This gets called before each test, no need to run it yourself otherwise.
        Specified by:
        runAsAdmin in interface TestAuthenticationUtils
      • runAsUser

        public void runAsUser​(String userName,
                              boolean createIfMissing)
        Run as a regular user.
        Specified by:
        runAsUser in interface TestAuthenticationUtils
        Parameters:
        userName - user name
        createIfMissing -