diff options
author | Jonathan Gathman <jonathan.gathman@att.com> | 2019-03-14 00:16:56 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-14 00:16:56 +0000 |
commit | 8832889f5707d5983c729753968919bb3aa38b8a (patch) | |
tree | 1307a7100eb3c1a183d60c016f41df8b665b2667 /sidecar/rproxy/src/test/java/org | |
parent | a2798182d222dad96af88ff486f7c3536c12a6a1 (diff) | |
parent | 94f286b3ab4da2d73f9cbdf3849aebb72c0476ea (diff) |
Merge "Enhance RProxy authorization to use request method"
Diffstat (limited to 'sidecar/rproxy/src/test/java/org')
-rw-r--r-- | sidecar/rproxy/src/test/java/org/onap/aaf/cadi/sidecar/rproxy/test/PermissionMatchingTest.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sidecar/rproxy/src/test/java/org/onap/aaf/cadi/sidecar/rproxy/test/PermissionMatchingTest.java b/sidecar/rproxy/src/test/java/org/onap/aaf/cadi/sidecar/rproxy/test/PermissionMatchingTest.java index e9dd95b..51f4ffc 100644 --- a/sidecar/rproxy/src/test/java/org/onap/aaf/cadi/sidecar/rproxy/test/PermissionMatchingTest.java +++ b/sidecar/rproxy/src/test/java/org/onap/aaf/cadi/sidecar/rproxy/test/PermissionMatchingTest.java @@ -29,6 +29,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import javax.annotation.Resource; + import org.eclipse.jetty.util.security.Password; import org.junit.Before; import org.junit.Test; @@ -141,6 +142,47 @@ public class PermissionMatchingTest { } @Test + public void testURIPUTMatchSinglePermissionMatch() throws Exception { + + String transactionId = "63f88b50-6345-4a61-bc59-3a48cabb60a4"; + String testUrl = "/single/permission/required"; + String testResponse = "Response from MockRestService"; + + mockServer + .expect(requestTo(primaryServiceBaseUrl + testUrl)) + .andExpect(method(HttpMethod.PUT)) + .andExpect(header(transactionIdHeaderName, transactionId)) + .andRespond(withSuccess(testResponse, MediaType.APPLICATION_JSON)); + + // Send request to mock server with transaction Id + mockMvc + .perform(MockMvcRequestBuilders.put(testUrl).accept(MediaType.APPLICATION_JSON).header(transactionIdHeaderName, transactionId)) + .andExpect(status().isOk()) + .andExpect(content().string(equalTo(testResponse))); + + mockServer.verify(); + + } + + + @Test + public void testURIPATCHMatchSinglePermissionMatch() throws Exception { + + String transactionId = "63f88b50-6345-4a61-bc59-3a48cabb60a4"; + String testUrl = "/single/permission/required"; + String testResponse = "Sorry, the request is not allowed"; + + // Send request to mock server with transaction Id + mockMvc + .perform(MockMvcRequestBuilders.patch(testUrl).accept(MediaType.APPLICATION_JSON).header(transactionIdHeaderName, transactionId)) + .andExpect(status().isForbidden()) + .andExpect(status().reason(testResponse)); + + mockServer.verify(); + + } + + @Test public void testURIMatchMultiplePermissionMatch() throws Exception { String transactionId = "63f88b50-6345-4a61-bc59-3a48cabb60a4"; |