use of com.searchcode.app.dto.api.RepoResultApiResponse in project searchcode-server by boyter.
the class ApiRouteServiceTest method testRepoListApiEnabledAuthValid.
public void testRepoListApiEnabledAuthValid() {
Request mockRequest = Mockito.mock(Request.class);
ApiService mockApiService = Mockito.mock(ApiService.class);
Repo mockRepo = Mockito.mock(Repo.class);
when(mockApiService.validateRequest("test", "test", "pub=test", ApiService.HmacType.SHA1)).thenReturn(true);
ApiRouteService apiRouteService = new ApiRouteService(mockApiService, null, mockRepo, null, null);
apiRouteService.apiEnabled = true;
apiRouteService.apiAuth = true;
when(mockRequest.queryParams("pub")).thenReturn("test");
when(mockRequest.queryParams("sig")).thenReturn("test");
RepoResultApiResponse apiResponse = apiRouteService.repoList(mockRequest, null);
assertThat(apiResponse.getMessage()).isEqualTo("");
assertThat(apiResponse.getRepoResultList()).hasSize(0);
assertThat(apiResponse.isSucessful()).isTrue();
}
Aggregations