Not able to get through webseal authentication using rest-assured

725 views Asked by At

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();
}
1

There are 1 answers

1
Sunder On

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();