Class TestAuthenticationUtilsImpl

java.lang.Object
ubic.gemma.core.util.test.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 Details

    • TestAuthenticationUtilsImpl

      public TestAuthenticationUtilsImpl()
  • Method Details

    • 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
    • runAsAgent

      public void runAsAgent()
      Specified by:
      runAsAgent 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 -
    • runAsAnonymous

      public void runAsAnonymous()
      Specified by:
      runAsAnonymous in interface TestAuthenticationUtils