forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEODE-7869: Cleanup warnings in geode-web-api
- Loading branch information
1 parent
9b269de
commit 9d1e682
Showing
20 changed files
with
279 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
|
@@ -57,35 +59,35 @@ public static void before() { | |
} | ||
|
||
@Test | ||
public void testListFunctions() throws Exception { | ||
public void testListFunctions() { | ||
assertResponse(restClient.doGet("/functions", "user", "wrongPswd")).hasStatusCode(401); | ||
assertResponse(restClient.doGet("/functions", "user", "user")).hasStatusCode(403); | ||
assertResponse(restClient.doGet("/functions", "dataRead", "dataRead")) | ||
.hasStatusCode(200) | ||
.hasContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); | ||
.hasContentType(MediaType.APPLICATION_JSON_VALUE); | ||
} | ||
|
||
@Test | ||
public void executeNotRegisteredFunction() throws Exception { | ||
public void executeNotRegisteredFunction() { | ||
assertResponse(restClient.doPost("/functions/invalid-function-id", "user", "wrongPswd", "")) | ||
.hasStatusCode(401); | ||
assertResponse(restClient.doPost("/functions/invalid-function-id", "user", "user", "")) | ||
.hasStatusCode(404); | ||
} | ||
|
||
@Test | ||
public void testQueries() throws Exception { | ||
public void testQueries() { | ||
restClient.doGetAndAssert("/queries", "user", "wrongPswd") | ||
.hasStatusCode(401); | ||
restClient.doGetAndAssert("/queries", "user", "user") | ||
.hasStatusCode(403); | ||
restClient.doGetAndAssert("/queries", "dataRead", "dataRead") | ||
.hasStatusCode(200) | ||
.hasContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); | ||
.hasContentType(MediaType.APPLICATION_JSON_VALUE); | ||
} | ||
|
||
@Test | ||
public void testAdhocQuery() throws Exception { | ||
public void testAdhocQuery() { | ||
restClient.doGetAndAssert("/queries/adhoc?q=", "user", "wrongPswd") | ||
.hasStatusCode(401); | ||
restClient.doGetAndAssert("/queries/adhoc?q=", "user", "user") | ||
|
@@ -97,7 +99,7 @@ public void testAdhocQuery() throws Exception { | |
} | ||
|
||
@Test | ||
public void testPostQuery() throws Exception { | ||
public void testPostQuery() { | ||
assertResponse(restClient.doPost("/queries?id=0&q=", "user", "wrongPswd", "")) | ||
.hasStatusCode(401); | ||
assertResponse(restClient.doPost("/queries?id=0&q=", "user", "user", "")) | ||
|
@@ -107,7 +109,7 @@ public void testPostQuery() throws Exception { | |
} | ||
|
||
@Test | ||
public void testPostQuery2() throws Exception { | ||
public void testPostQuery2() { | ||
assertResponse(restClient.doPost("/queries/id", "user", "wrongPswd", "{\"id\" : \"foo\"}")) | ||
.hasStatusCode(401); | ||
assertResponse(restClient.doPost("/queries/id", "user", "user", "{\"id\" : \"foo\"}")) | ||
|
@@ -117,7 +119,7 @@ public void testPostQuery2() throws Exception { | |
} | ||
|
||
@Test | ||
public void testPutQuery() throws Exception { | ||
public void testPutQuery() { | ||
assertResponse(restClient.doPut("/queries/id", "user", "wrongPswd", "{\"id\" : \"foo\"}")) | ||
.hasStatusCode(401); | ||
assertResponse(restClient.doPut("/queries/id", "user", "user", "{\"id\" : \"foo\"}")) | ||
|
@@ -127,7 +129,7 @@ public void testPutQuery() throws Exception { | |
} | ||
|
||
@Test | ||
public void testDeleteQuery() throws Exception { | ||
public void testDeleteQuery() { | ||
assertResponse(restClient.doDelete("/queries/id", "user", "wrongPswd")) | ||
.hasStatusCode(401); | ||
assertResponse(restClient.doDelete("/queries/id", "stranger", "stranger")) | ||
|
@@ -137,22 +139,22 @@ public void testDeleteQuery() throws Exception { | |
} | ||
|
||
@Test | ||
public void testServers() throws Exception { | ||
public void testServers() { | ||
assertResponse(restClient.doGet("/servers", "user", "wrongPswd")) | ||
.hasStatusCode(401); | ||
assertResponse(restClient.doGet("/servers", "stranger", "stranger")) | ||
.hasStatusCode(403); | ||
assertResponse(restClient.doGet("/servers", "cluster", "cluster")) | ||
.hasStatusCode(200) | ||
.hasContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); | ||
.hasContentType(MediaType.APPLICATION_JSON_VALUE); | ||
} | ||
|
||
/** | ||
* This test should always return an OK, whether the user is known or unknown. A phishing script | ||
* should not be able to determine whether a user/password combination is good | ||
*/ | ||
@Test | ||
public void testPing() throws Exception { | ||
public void testPing() { | ||
assertResponse(restClient.doHEAD("/ping", "stranger", "stranger")) | ||
.hasStatusCode(200); | ||
assertResponse(restClient.doGet("/ping", "stranger", "stranger")) | ||
|
@@ -168,9 +170,9 @@ public void testPing() throws Exception { | |
* Test permissions on retrieving a list of regions. | ||
*/ | ||
@Test | ||
public void getRegions() throws Exception { | ||
public void getRegions() throws IOException { | ||
JsonNode jsonObject = assertResponse(restClient.doGet("", "dataRead", "dataRead")) | ||
.hasStatusCode(200).hasContentType(MediaType.APPLICATION_JSON_UTF8_VALUE) | ||
.hasStatusCode(200).hasContentType(MediaType.APPLICATION_JSON_VALUE) | ||
.getJsonObject(); | ||
|
||
JsonNode regions = jsonObject.get("regions"); | ||
|
@@ -194,7 +196,7 @@ public void getRegions() throws Exception { | |
* Test permissions on getting a region | ||
*/ | ||
@Test | ||
public void getRegion() throws Exception { | ||
public void getRegion() { | ||
// Test an unknown user - 401 error | ||
assertResponse(restClient.doGet("/" + REGION_NAME, "user", "wrongPswd")) | ||
.hasStatusCode(401); | ||
|
@@ -205,14 +207,14 @@ public void getRegion() throws Exception { | |
|
||
// Test an authorized user - 200 | ||
assertResponse(restClient.doGet("/" + REGION_NAME, "data", "data")) | ||
.hasStatusCode(200).hasContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); | ||
.hasStatusCode(200).hasContentType(MediaType.APPLICATION_JSON_VALUE); | ||
} | ||
|
||
/** | ||
* Test permissions on HEAD region | ||
*/ | ||
@Test | ||
public void headRegion() throws Exception { | ||
public void headRegion() { | ||
// Test an unknown user - 401 error | ||
assertResponse(restClient.doHEAD("/" + REGION_NAME, "user", "wrongPswd")) | ||
.hasStatusCode(401); | ||
|
@@ -230,7 +232,7 @@ public void headRegion() throws Exception { | |
* Test permissions on deleting a region | ||
*/ | ||
@Test | ||
public void deleteRegion() throws Exception { | ||
public void deleteRegion() { | ||
// Test an unknown user - 401 error | ||
assertResponse(restClient.doDelete("/" + REGION_NAME, "user", "wrongPswd")) | ||
.hasStatusCode(401); | ||
|
@@ -244,10 +246,10 @@ public void deleteRegion() throws Exception { | |
* Test permissions on getting a region's keys | ||
*/ | ||
@Test | ||
public void getRegionKeys() throws Exception { | ||
public void getRegionKeys() { | ||
// Test an authorized user | ||
assertResponse(restClient.doGet("/" + REGION_NAME + "/keys", "data", "data")) | ||
.hasStatusCode(200).hasContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); | ||
.hasStatusCode(200).hasContentType(MediaType.APPLICATION_JSON_VALUE); | ||
// Test an unauthorized user | ||
assertResponse(restClient.doGet("/" + REGION_NAME + "/keys", "dataWrite", "dataWrite")) | ||
.hasStatusCode(403); | ||
|
@@ -257,11 +259,11 @@ public void getRegionKeys() throws Exception { | |
* Test permissions on retrieving a key from a region | ||
*/ | ||
@Test | ||
public void getRegionKey() throws Exception { | ||
public void getRegionKey() { | ||
// Test an authorized user | ||
assertResponse(restClient.doGet("/" + REGION_NAME + "/key1", "dataReadAuthRegionKey1", | ||
"dataReadAuthRegionKey1")) | ||
.hasStatusCode(200).hasContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); | ||
.hasStatusCode(200).hasContentType(MediaType.APPLICATION_JSON_VALUE); | ||
|
||
// Test an unauthorized user | ||
assertResponse(restClient.doGet("/" + REGION_NAME + "/key1", "dataWrite", "dataWrite")) | ||
|
@@ -272,7 +274,7 @@ public void getRegionKey() throws Exception { | |
* Test permissions on deleting a region's key(s) | ||
*/ | ||
@Test | ||
public void deleteRegionKey() throws Exception { | ||
public void deleteRegionKey() { | ||
// Test an unknown user - 401 error | ||
assertResponse(restClient.doDelete("/" + REGION_NAME + "/key1", "user", "wrongPswd")) | ||
.hasStatusCode(401); | ||
|
@@ -291,7 +293,7 @@ public void deleteRegionKey() throws Exception { | |
* Test permissions on deleting a region's key(s) | ||
*/ | ||
@Test | ||
public void postRegionKey() throws Exception { | ||
public void postRegionKey() { | ||
// Test an unknown user - 401 error | ||
assertResponse(restClient.doPost("/" + REGION_NAME + "?key9", "user", "wrongPswd", | ||
"{ \"key9\" : \"foo\" }")) | ||
|
@@ -312,7 +314,7 @@ public void postRegionKey() throws Exception { | |
* Test permissions on deleting a region's key(s) | ||
*/ | ||
@Test | ||
public void putRegionKey() throws Exception { | ||
public void putRegionKey() { | ||
|
||
String json = | ||
"{\"@type\":\"com.gemstone.gemfire.web.rest.domain.Order\",\"purchaseOrderNo\":1121,\"customerId\":1012,\"description\":\"Order for XYZ Corp\",\"orderDate\":\"02/10/2014\",\"deliveryDate\":\"02/20/2014\",\"contact\":\"Jelly Bean\",\"email\":\"[email protected]\",\"phone\":\"01-2048096\",\"items\":[{\"itemNo\":1,\"description\":\"Product-100\",\"quantity\":12,\"unitPrice\":5,\"totalPrice\":60}],\"totalPrice\":225}"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.