Skip to content

Commit

Permalink
Remove extra test cases for custom allowed queries configuration reso…
Browse files Browse the repository at this point in the history
…urce file
  • Loading branch information
rehammuzzamil committed Sep 27, 2023
1 parent d69d79c commit 4434fd2
Showing 1 changed file with 0 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,61 +200,4 @@ public void denyRequestTypeMisMatch() throws IOException {

assertThat(testInstance.checkAccess(requestMock).canAccess(), equalTo(false));
}

@Test
public void validGetCompositionQuery() throws IOException {
// Query: GET /Composition
when(requestMock.getRequestPath()).thenReturn("/Composition");
URL configFileUrl = Resources.getResource("hapi_page_url_allowed_queries.json");
AllowedQueriesChecker testInstance = new AllowedQueriesChecker(configFileUrl.getPath());
assertThat(testInstance.checkAccess(requestMock).canAccess(), equalTo(true));
}

@Test
public void validGetListQueryWithSpecificPathVariableValue() throws IOException {
// Query: PUT /List/some-value-x-anything
when(requestMock.getRequestPath()).thenReturn("/List/some-value-x-anything");
URL configFileUrl = Resources.getResource("hapi_page_url_allowed_queries.json");
AllowedQueriesChecker testInstance = new AllowedQueriesChecker(configFileUrl.getPath());
assertThat(testInstance.checkAccess(requestMock).canAccess(), equalTo(true));
}

@Test
public void validGetBinaryQueryWithExpectedPathVariable() throws IOException {
// Query: GET /Binary/1234567
when(requestMock.getRequestPath()).thenReturn("/Binary/1234567");
URL configFileUrl = Resources.getResource("hapi_page_url_allowed_queries.json");
AllowedQueriesChecker testInstance = new AllowedQueriesChecker(configFileUrl.getPath());
assertThat(testInstance.checkAccess(requestMock).canAccess(), equalTo(true));
}

@Test
public void denyGetBinaryQueryWithUnexpectedPathVariable() throws IOException {
// Query: GET /Binary/unauthorized-path-variable
when(requestMock.getRequestPath()).thenReturn("/Binary/unauthorized-path-variable");
URL configFileUrl = Resources.getResource("hapi_page_url_allowed_queries.json");
AllowedQueriesChecker testInstance = new AllowedQueriesChecker(configFileUrl.getPath());
assertThat(testInstance.checkAccess(requestMock).canAccess(), equalTo(false));
}

@Test
public void validGetPatientQueryWithExpectedGetParamsAndPathVariable() throws IOException {
// Query: GET /Patient/8899900
when(requestMock.getRequestPath()).thenReturn("/Patient/8899900");
Map<String, String[]> params = Maps.newHashMap();
params.put("_sort", new String[] {"name"});
when(requestMock.getParameters()).thenReturn(params);
URL configFileUrl = Resources.getResource("hapi_page_url_allowed_queries.json");
AllowedQueriesChecker testInstance = new AllowedQueriesChecker(configFileUrl.getPath());
assertThat(testInstance.checkAccess(requestMock).canAccess(), equalTo(true));
}

@Test
public void denyGetPatientQueryWithEmptyPathVariable() throws IOException {
// Query: GET /Patient/
when(requestMock.getRequestPath()).thenReturn("/Patient/");
URL configFileUrl = Resources.getResource("hapi_page_url_allowed_queries.json");
AllowedQueriesChecker testInstance = new AllowedQueriesChecker(configFileUrl.getPath());
assertThat(testInstance.checkAccess(requestMock).canAccess(), equalTo(false));
}
}

0 comments on commit 4434fd2

Please sign in to comment.