1

working on an automation assignment and i am trying to test a web service hosted on a webseal server. the issue is i have pretty my tried every method in rest assured to get to the response json but what i am getting is the authentication screen html.

here is some of my non working code. what i was expecting it the json but no matter what authentication method i run i get the webseal's authentication page only.

private String serviceTestGET(WebServiceTest serviceTest) {
    System.out.println("Credential : " + userName + " -- " + password);
    // RestAssured.
    // RestAssured.authentication = basic(userName, password);
    // RestAssured.authentication = digest(userId, password);
    // RestAssured.authentication = oauth(consumerKey, consumerSecret,
    // accessToken, secretToken);//form(userName, password);
    // RestAssured.authentication = form(userId, password, config);
    RestAssured.useRelaxedHTTPSValidation();
    return given().get(serviceTest.getEntryPoint()).asString();
}
Sunder
  • 61
  • 5

1 Answers1

1

I have found the answer after googling a bit. there are few things we have to consider that webseal is going to authenticate the request by throwing back a authentication form. once that form is authenticated its expected that you will use the same session(cookies) to access the application behind the webseal server.

so here is my working code

    System.out.println("Credentials : " + username + " - " + password);
    RestAssured.useRelaxedHTTPSValidation();
    SessionFilter sessionFilter = new SessionFilter();

    Map<String,String> cookies = given().
            filter(sessionFilter).
            param("username", username).
            param("password", password).
            param("login-form-type", "pwd").
    expect().
        statusCode(200).
    when().
        post("https://your-web-seal-server/pkmslogin.form").getCookies();

    Reporter.log("Server Authenticated");

    return given().filter(sessionFilter).cookies(cookies).expect().statusCode(200).
    when().get(serviceTest.getEntryPoint()).asString();
Sunder
  • 61
  • 5
  • Exactly, login-form-type is needed. Please see full documentation at https://www.ibm.com/support/knowledgecenter/SSXJVR_2.0.0/com.ibm.sso.doc/wrp_config/task/tsk_submt_form_data_ws.html – Marcin P Nov 24 '17 at 10:11