Form Based Authentication

Web Forms for Authentication

Some web services require form based authentication. In order to be able to use API calls, you typically need to launch a browser, log into a web form, and then establish a session.


A form that asks for authentication credentials might look like this

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

This would render a HTML form:

Form view

A SoapUI Test Case

The way to deal with this in SoapUI would be to:

1) Create a HTTP Request Step with the appropriate settings (username, password, method).

2) Set the TestStep to keep the session alive with the option Maintain HTTP Session.

Creating HTTP Test Request

In your TestCase, create an HTTP Request Step.

HTTP Request Step

Username is “admin”, and the password “p@ssw0rd” in this case. The HTTP method is specified as POST.

Maintaining Session

When you have a HTTP Request TestStep that works, you can set the TestCase to maintain the session provided by the TestStep.

1) Open the TestCase window.

2) Click Option.

3) In TestCase Options, check the Maintain HTTP Session checkbox.

Test case options

You should now be able to add SOAP and/or REST test steps further in the test case that will maintain the authenticated session.