use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method shouldNotUpdatePipelineSelectionsWhenTheUserIsLoggedIn_WithBlacklist.
@Test
public void shouldNotUpdatePipelineSelectionsWhenTheUserIsLoggedIn_WithBlacklist() {
mockConfigWithSecurity();
when(pipelineRepository.findPipelineSelectionsByUserId(1L)).thenReturn(new PipelineSelections(Arrays.asList("pipeline1", "pipeline2"), null, null, true));
goConfigService.updateUserPipelineSelections(null, 1L, new CaseInsensitiveString("pipelineNew"));
verify(pipelineRepository).findPipelineSelectionsByUserId(1L);
verify(pipelineRepository, times(0)).saveSelectedPipelines(argThat(Matchers.any(PipelineSelections.class)));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnPersistedPipelineSelectionsAgainstCookieId_WhenSecurityisDisabled.
@Test
public void shouldReturnPersistedPipelineSelectionsAgainstCookieId_WhenSecurityisDisabled() {
PipelineSelections pipelineSelections = new PipelineSelections(Arrays.asList("pip1"));
when(pipelineRepository.findPipelineSelectionsById("123")).thenReturn(pipelineSelections);
assertThat(goConfigService.getSelectedPipelines("123", null), is(pipelineSelections));
assertThat(goConfigService.getSelectedPipelines("", null), is(PipelineSelections.ALL));
assertThat(goConfigService.getSelectedPipelines("345", null), is(PipelineSelections.ALL));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method shouldUpdatePipelineSelectionsWhenTheUserIsAnonymousAndHasSelectedPipelines_WithWhitelist.
@Test
public void shouldUpdatePipelineSelectionsWhenTheUserIsAnonymousAndHasSelectedPipelines_WithWhitelist() {
when(pipelineRepository.findPipelineSelectionsById("1")).thenReturn(new PipelineSelections(Arrays.asList("pipeline1", "pipeline2"), null, null, false));
goConfigService.updateUserPipelineSelections("1", null, new CaseInsensitiveString("pipelineNew"));
verify(pipelineRepository).findPipelineSelectionsById("1");
verify(pipelineRepository, times(1)).saveSelectedPipelines(argThat(isAPipelineSelectionsInstanceWith(false, "pipeline1", "pipeline2", "pipelineNew")));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method shouldNotUpdatePipelineSelectionsWhenTheUserIsAnonymousAndHasSelectedPipelines_WithBlacklist.
@Test
public void shouldNotUpdatePipelineSelectionsWhenTheUserIsAnonymousAndHasSelectedPipelines_WithBlacklist() {
when(pipelineRepository.findPipelineSelectionsById("1")).thenReturn(new PipelineSelections(Arrays.asList("pipeline1", "pipeline2"), null, null, true));
goConfigService.updateUserPipelineSelections("1", null, new CaseInsensitiveString("pipelineNew"));
verify(pipelineRepository).findPipelineSelectionsById("1");
verify(pipelineRepository, times(0)).saveSelectedPipelines(argThat(Matchers.any(PipelineSelections.class)));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method shouldUpdatePipelineSelectionsWhenTheUserIsLoggedIn_WithWhitelist.
@Test
public void shouldUpdatePipelineSelectionsWhenTheUserIsLoggedIn_WithWhitelist() {
mockConfigWithSecurity();
when(pipelineRepository.findPipelineSelectionsByUserId(1L)).thenReturn(new PipelineSelections(Arrays.asList("pipeline1", "pipeline2"), null, null, false));
goConfigService.updateUserPipelineSelections(null, 1L, new CaseInsensitiveString("pipelineNew"));
verify(pipelineRepository).findPipelineSelectionsByUserId(1L);
verify(pipelineRepository, times(1)).saveSelectedPipelines(argThat(isAPipelineSelectionsInstanceWith(false, "pipeline1", "pipeline2", "pipelineNew")));
}
Aggregations