IBM Support

HTTP/1.1 401 Authorization Required during playback

Troubleshooting


Problem

Attempts to playback an IBM Rational Performance Tester (RPT) test result in HTTP 401"Unexpected challenge".

Symptom

You see the following message.


GET

/javax.faces.resource/event-custom/event-custom-min.js.jsf?ln=yui/3_1_1 HTTP/1.1

Unexpected challenge(HTTP status code=401) received during HTTP playback to web-server 'myhost.com' retrieving URI '/javax.faces.resource/event-custom/event-custom-min.js.jsf?ln=yui/3_1_1'. This behavior differs from the behavior recorded during test creation. For authentication to playback correctly a challenge must be recorded during test creation.

Cause

The error tells that the server received either no authorization credentials or the wrong credentials.

Resolving The Problem

Add the following custom code before the request that is failing. You need the class only at one point in the first page of test. That is, just before the 401 error.


Disclaimer
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.



package test;

import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;

import com.ibm.rational.test.lt.execution.http.cookie.IHTTPVirtualUserInfo;

import com.ibm.rational.test.lt.execution.http.cookie.ICookie;

import com.ibm.rational.test.lt.kernel.IDataArea;

import java.text.ParseException;

/**

 * The ModifyCookie class sets the Path to / for a Cookie name passed in as the only argument.

 */

/**

 * @author IBM Level 3 Support

 */

public class ModifyCookie implements

                com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {

        public ModifyCookie() {

        }

        public String exec(ITestExecutionServices tes, String[] args) {

          String cookieName = "OBBasicAuth";

           String newCookie;

            IDataArea dataArea = tes.findDataArea(IDataArea.VIRTUALUSER);

            IHTTPVirtualUserInfo httpInfo =   (IHTTPVirtualUserInfo)dataArea.get(IHTTPVirtualUserInfo.KEY);

            ICookie serverSuppliedCookie[] = httpInfo.getCookieCache().getCookieByName(cookieName);

       

        if (serverSuppliedCookie.length != 1)

        {

                if (serverSuppliedCookie.length == 0)

                        tes.getTestLogManager().reportMessage("Cannot find existing Cookie named " + cookieName);

                else

                        tes.getTestLogManager().reportMessage("Found more than 1 cookie named " + cookieName);

                return "Problem";

        }

     

       newCookie = cookieName + "=" + "fromDialog" + ";Path=/;Domain=" + serverSuppliedCookie[0].getDomain();

        try {

            httpInfo.getCookieCache().setCookie(newCookie);

        } catch (ParseException e) {

            tes.getTestLogManager().reportMessage("ERROR: Can't parse Cookie string: " + newCookie);

        }

        return "Success";

        }

}

[{"Product":{"code":"SSMMM5","label":"IBM Rational Performance Tester"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Record \/ Author tests","Platform":[{"code":"PF033","label":"Windows"}],"Version":"8.2.1.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21585440