2014-01-14 35 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