【问题标题】:Not able to get through webseal authentication using rest-assured无法使用放心通过 webseal 身份验证
【发布时间】:2018-05-04 03:24:05
【问题描述】:

从事自动化任务,我正在尝试测试托管在 webseal 服务器上的 web 服务。问题是我已经尝试了所有方法,放心获得响应 json,但我得到的是身份验证屏幕 html。

这是我的一些非工作代码。我期望它是 json,但无论我运行什么身份验证方法,我都只会得到 webseal 的身份验证页面。

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

【问题讨论】:

    标签: rest-assured webseal


    【解决方案1】:

    我在谷歌搜索了一下后找到了答案。 我们需要考虑的事情很少,webseal 将通过返回一个验证表单来验证请求。一旦该表单通过身份验证,您将使用相同的会话(cookies)来访问 webseal 服务器后面的应用程序。

    这是我的工作代码

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-18
    • 2016-10-24
    • 1970-01-01
    • 1970-01-01
    • 2022-10-06
    • 1970-01-01
    相关资源
    最近更新 更多