我正在开发一个用于 IBM Worklight 适配器集成测试的 POC。在这样做时,我正在使用RESTAssured framework。我有一个应用了安全测试的适配器。XML 片段:
<procedure name="getCatalog"
securityTest="SingleStepAuthAdapter-securityTest" />
对于身份验证,我有另一个适配器:
<procedure name="submitAuthentication" />
在我的测试中,我调用了 SubmitAuthentication 适配器,然后调用了 getCatalog 适配器。这将返回我以下错误响应:
运行时:资源 'proc:SampleHttpAdapter.getCatalog' 只能在领域 'SingleStepAuthRealm' 中进行身份验证时访问。
下面是我正在执行的测试用例:
public void testGetCatalog() {
Response response = RestAssured.given().get(BASE_URL.concat("SampleHttpAdapter&
procedure=submitAuthentication¶meters=[\"worklight\",\"worklight\"]"));
String sessionid = response.getSessionId();
Cookie cookie1 = new Cookie.Builder("JSESSIONID", sessionid).build();
System.out.println("cookie value" + cookie1.getValue());
RequestSpecification spec_two = new RequestSpecBuilder().addCookie(cookie1)
.setSessionId(sessionid).build();
Response catalog_response = RestAssured.given()
.spec(spec_two)
.get(BASE_URL.concat("SampleHttpAdapter&procedure=getCatalog¶meters=[]"));
String catalog_json = catalog_response.asString();
System.out.println(catalog_json);
}
根据响应,我的 getCatalog 请求中似乎没有持续进行身份验证。我该怎么做?