use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class AdminRouteServiceTest method testDeleteRepo.
public void testDeleteRepo() {
Repo mockRepo = Mockito.mock(Repo.class);
JobService mockJobService = Mockito.mock(JobService.class);
DataService mockDataService = Mockito.mock(DataService.class);
AdminRouteService adminRouteService = new AdminRouteService(mockRepo, mockJobService, mockDataService, null, null, null);
Request mockRequest = Mockito.mock(Request.class);
when(mockRequest.queryParams("repoName")).thenReturn("myRepo");
when(mockRepo.getRepoByName("myRepo")).thenReturn(new RepoResult());
adminRouteService.deleteRepo(mockRequest, null);
verify(mockDataService, times(1)).addToPersistentDelete("");
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class ApiRouteServiceTest method testRepoDeleteAuthReponameAuth.
public void testRepoDeleteAuthReponameAuth() {
Request mockRequest = mock(Request.class);
Repo mockRepo = mock(Repo.class);
DataService dataServiceMock = mock(DataService.class);
ApiService mockApiService = mock(ApiService.class);
when(mockApiService.validateRequest("test", "test", "pub=test&reponame=unit-test", ApiService.HmacType.SHA1)).thenReturn(true);
when(mockRepo.getRepoByName("unit-test")).thenReturn(new RepoResult());
ApiRouteService apiRouteService = new ApiRouteService(mockApiService, null, mockRepo, dataServiceMock, null);
apiRouteService.apiEnabled = true;
apiRouteService.apiAuth = true;
when(mockRequest.queryParams("pub")).thenReturn("test");
when(mockRequest.queryParams("sig")).thenReturn("test");
when(mockRequest.queryParams("reponame")).thenReturn("unit-test");
ApiResponse apiResponse = apiRouteService.repoDelete(mockRequest, null);
assertThat(apiResponse.getMessage()).isEqualTo("repository queued for deletion");
assertThat(apiResponse.isSucessful()).isTrue();
verify(dataServiceMock, times(1)).addToPersistentDelete("");
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class ApiRouteServiceTest method testRepoDeleteAuthReponameFailedAuth.
public void testRepoDeleteAuthReponameFailedAuth() {
Request mockRequest = Mockito.mock(Request.class);
Repo mockRepo = Mockito.mock(Repo.class);
UniqueRepoQueue uniqueRepoQueue = new UniqueRepoQueue(new ConcurrentLinkedQueue<>());
ApiService mockApiService = Mockito.mock(ApiService.class);
when(mockApiService.validateRequest("test", "test", "pub=test", ApiService.HmacType.SHA1)).thenReturn(false);
when(mockRepo.getRepoByName("unit-test")).thenReturn(new RepoResult());
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");
when(mockRequest.queryParams("reponame")).thenReturn("unit-test");
ApiResponse apiResponse = apiRouteService.repoDelete(mockRequest, null);
assertThat(apiResponse.getMessage()).isEqualTo("invalid signed url");
assertThat(apiResponse.isSucessful()).isFalse();
assertThat(uniqueRepoQueue.size()).isEqualTo(0);
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class RepoTest method testRepoSaveGetCacheBug.
public void testRepoSaveGetCacheBug() {
this.repo.saveRepo(new RepoResult(-1, "myname", "git", "myurl", "username", "password", "mysource", "mybranch", "{}"));
for (int i = 0; i < 200; i++) {
assertThat(repo.getRepoByName("myname")).isNotNull();
}
this.repo.deleteRepoByName("myname");
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class RepoTest method testGetRepoByNameUsingNull.
public void testGetRepoByNameUsingNull() {
RepoResult repoResult = this.repo.getRepoByName(null);
assertThat(repoResult).isNull();
}
Aggregations