Search in sources :

Example 6 with RepoResultApiResponse

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();
}
Also used : Repo(com.searchcode.app.dao.Repo) ApiRouteService(com.searchcode.app.service.route.ApiRouteService) Request(spark.Request) RepoResultApiResponse(com.searchcode.app.dto.api.RepoResultApiResponse)

Aggregations

RepoResultApiResponse (com.searchcode.app.dto.api.RepoResultApiResponse)6 ApiRouteService (com.searchcode.app.service.route.ApiRouteService)6 Request (spark.Request)5 Repo (com.searchcode.app.dao.Repo)2 SQLiteMemoryDatabaseConfig (com.searchcode.app.config.SQLiteMemoryDatabaseConfig)1 Helpers (com.searchcode.app.util.Helpers)1