2014-01-14 135 views
0

我正在开发用于IBM worklight适配器集成测试的POC。这样做我使用RESTAssured framework。我有适用于它的安全测试的适配器。 XML片段:IBM worklight适配器与安全测试的集成测试

<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&parameters=[\"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&parameters=[]")); 
    String catalog_json = catalog_response.asString(); 
    System.out.println(catalog_json); 
} 

按好像验证是不是在我getCatalog的要求持续的响应。我怎么能这样做?

回答

1

不知道如何编写适配器过程很难调查上述问题。你能否提供submitAuthentication的适配器程序以及getCatalog?

我可以为您提供一个示例和教程Worklight支持基于适配器的身份验证,该身份验证将详细介绍身份验证过程的工作原理。您甚至可以将此项目用作基础,因为它可以完成单步适配器身份验证。使用它提供的身份验证机制并添加到getCatalog方法中进行测试。

适配器Based验证演示: http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/08_03_Adapter_based_authentication.pdf

适配器Based验证项目: http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/AdapterBasedAuthenticationProject.zip