HTTP Authorization Tutorial

This tutorial explains how to enable HTTP authorization for the following HTTP form:

<form method="post" action="/login">
    Username: <input type="text" name="username" required>
    Password: <input type="password" name="password" required>
    <input type="submit" value="Login">
</form>

This form renders in a browser as a username field, a password field, and a login button.

To authorize using this form:

  1. Create an HTTP Request test step with the appropriate settings (username, password, and method).

    The New HTTP Request Step dialog in ReadyAPI. The Test Step Name is set to HTTP Request, the Endpoint is http://localhost:8081/login, and the Parameters table lists two QUERY parameters: username mapped to {#TestCase#username} and password mapped to {#Tes

    In this example, the username is admin, the password is p@ssw0rd, and the HTTP method is specified as POST.

    Important

    Make sure the HTTP request endpoint matches the address in the action attribute of the form element.

  2. Open the created HTTP request and select the Post QueryString option.

    The HTTP Request editor in ReadyAPI. The Method is set to POST and the Request URL is http://localhost:8081/login. The Request tab shows two QUERY parameters: username mapped to {#TestCase#username} and password mapped to {#TestCase#password}. The Media T
  3. Set the HTTP Request test step to keep the session alive by using the Maintain HTTP Session option.

    1. Select the test case in the Navigator.

    2. Click on the test case toolbar.

    3. Switch to the Basic tab.

    4. Select the Maintain HTTP Session option.

      The Test Case Options dialog in ReadyAPI, showing the Basic tab. The Session row is highlighted with an orange border, drawing attention to the selected Maintain HTTP session checkbox. Other settings shown include Search Properties, Abort on Error, Fail T
    5. Click OK.

When everything is set up, the session will be maintained, and any other requests in the test will use the authenticated session.

See Also

Publication date: