Correct test implementation with Authentication Enable

This commit is contained in:
Lee moon soo 2017-02-28 21:13:12 +09:00
parent 21d91ef6bc
commit 0360108870

View file

@ -40,7 +40,7 @@ public class SecurityRestApiTest extends AbstractTestRestApi {
@BeforeClass
public static void init() throws Exception {
AbstractTestRestApi.startUpWithAuthenticationEnable();;
AbstractTestRestApi.startUpWithAuthenticationEnable();
}
@AfterClass
@ -50,21 +50,21 @@ public class SecurityRestApiTest extends AbstractTestRestApi {
@Test
public void testTicket() throws IOException {
GetMethod get = httpGet("/security/ticket");
GetMethod get = httpGet("/security/ticket", "admin", "password1");
get.addRequestHeader("Origin", "http://localhost");
Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(),
new TypeToken<Map<String, Object>>(){}.getType());
Map<String, String> body = (Map<String, String>) resp.get("body");
collector.checkThat("Paramater principal", body.get("principal"),
CoreMatchers.equalTo("anonymous"));
CoreMatchers.equalTo("admin"));
collector.checkThat("Paramater ticket", body.get("ticket"),
CoreMatchers.equalTo("anonymous"));
CoreMatchers.not("anonymous"));
get.releaseConnection();
}
@Test
public void testGetUserList() throws IOException {
GetMethod get = httpGet("/security/userlist/admi");
GetMethod get = httpGet("/security/userlist/admi", "admin", "password1");
get.addRequestHeader("Origin", "http://localhost");
Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(),
new TypeToken<Map<String, Object>>(){}.getType());
@ -75,7 +75,7 @@ public class SecurityRestApiTest extends AbstractTestRestApi {
CoreMatchers.equalTo(true));
get.releaseConnection();
GetMethod notUser = httpGet("/security/userlist/randomString");
GetMethod notUser = httpGet("/security/userlist/randomString", "admin", "password1");
notUser.addRequestHeader("Origin", "http://localhost");
Map<String, Object> notUserResp = gson.fromJson(notUser.getResponseBodyAsString(),
new TypeToken<Map<String, Object>>(){}.getType());
@ -85,6 +85,5 @@ public class SecurityRestApiTest extends AbstractTestRestApi {
notUser.releaseConnection();
}
}