Class DslAuthManager

  • All Implemented Interfaces:
    DslConfig, DslTestElement, DslTestPlan.TestPlanChild, BaseSampler.SamplerChild, MultiLevelTestElement, BaseThreadGroup.ThreadGroupChild

    public class DslAuthManager
    extends BaseConfigElement
    Allows specifying HTTP authentication to be automatically included in HTTP requests.

    This is a handy way of specifying HTTP authentication without having to worry about particular requests or HTTP header handling.

    When specifying multiple authentications, consider that the first matching authentication will be applied. So, if you have two urls with different authentication which one is contained by the other, define the longest one first and then the shorter one to get expected behavior. E.g:

    
      httpAuth()
        .basicAuth("http://myservice/user", "user1", "pass1")
        .basicAuth("http://myservice", "user2", "pass2")
     
    Since:
    1.5
    • Constructor Detail

      • DslAuthManager

        public DslAuthManager()
    • Method Detail

      • basicAuth

        public DslAuthManager basicAuth​(String baseUrl,
                                        String user,
                                        String password)
        Specifies authentication credentials to use with HTTP Basic authentication for a given base url.
        Parameters:
        baseUrl - allows filtering requests to which HTTP Basic authentication should be sent. All requests with a URL starting with this given base url will include Basic authentication.

        Even though you can use empty string to match any URL and simplify configuration, this is not advised since it may lead to sending the authentication credentials to an unexpected URL and cause a security leak.

        user - specifies the username for the basic authentication.
        password - specifies the password for the basic authentication.
        Returns:
        the test element for further configuration and usage.