Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Feat: no basic auth (#183)
Browse files Browse the repository at this point in the history
* feat: removed auth check

* feat: removed auth check
* fix: tests mocks
  • Loading branch information
RadovanTomik authored Feb 9, 2023
1 parent a21daa1 commit 3546897
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public Response createQueryOptions(String queryString, @Context HttpServletReque
public Response createQuery(String queryString, @Context HttpServletRequest request) {
String apiCallId = UUID.randomUUID().toString();
logger.info(apiCallId + " API call via create_query API.");
checkAuthentication(request);

try(Config config = getConfigFromDactory()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,8 @@ void tearDown() {
@Test
@DisplayName("Create new Request with no Token")
void testCreateQuery_withNoToken() throws SQLException {
// Mock config classes
Mockito.when(negotiatorConfig.getMolgenisUsername()).thenReturn("username");
Mockito.when(negotiatorConfig.getMolgenisPassword()).thenReturn("password");
Mockito.when(request.getHeader("Authorization")).thenReturn("Basic dXNlcm5hbWU6cGFzc3dvcmQ=");

// Mock object under test
Directory directorySpy = Mockito.spy(directory);
Mockito.doReturn(config).when(directorySpy).getConfigFromDactory();
Mockito.doReturn(negotiatorConfig).when(directorySpy).getNegotiatorConfig();

JsonQueryRecord jsonQueryRecord = new JsonQueryRecord();
jsonQueryRecord.setJsonText(queryJsonNoNToken);
Expand All @@ -67,23 +60,16 @@ void testCreateQuery_withNoToken() throws SQLException {
@Test
@DisplayName("Create new Request with Token")
void testCreateQuery_withToken() throws SQLException {
// Mock classes
Mockito.when(negotiatorConfig.getMolgenisUsername()).thenReturn("username");
Mockito.when(negotiatorConfig.getMolgenisPassword()).thenReturn("password");
Mockito.when(request.getHeader("Authorization")).thenReturn("Basic dXNlcm5hbWU6cGFzc3dvcmQ=");
Mockito.when(queryRecord.getJsonText()).thenReturn(recordJsonWithMultipleQueries);
Mockito.when(queryRecord.getJsonText()).thenReturn(recordJsonWithMultipleQueries);

// Mock object under test
Directory directorySpy = Mockito.spy(directory);
Mockito.doReturn(config).when(directorySpy).getConfigFromDactory();
Mockito.doReturn(negotiatorConfig).when(directorySpy).getNegotiatorConfig();
Mockito.doReturn(queryRecord).when(directorySpy).getQueryForNToken(Mockito.any(), Mockito.any());
Mockito.doNothing().when(directorySpy).updateRecord(queryRecord);

JsonQueryRecord jsonQueryRecord = new JsonQueryRecord();
jsonQueryRecord.setJsonText(queryJsonNToken);
jsonQueryRecord.setId(1);
//Mockito.doReturn(jsonQueryRecord).when(directorySpy).saveJsonQueryRecord(queryJsonNToken, config);

// Test call
Response response = directorySpy.createQuery(queryJsonNToken, request);
Expand Down

0 comments on commit 3546897

Please sign in to comment.