Search in sources :

Example 36 with PipelineSelections

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)));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Example 37 with PipelineSelections

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));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Example 38 with PipelineSelections

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")));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Example 39 with PipelineSelections

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)));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Example 40 with PipelineSelections

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")));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Aggregations

PipelineSelections (com.thoughtworks.go.server.domain.user.PipelineSelections)57 Test (org.junit.Test)44 DateTime (org.joda.time.DateTime)12 Username (com.thoughtworks.go.server.domain.Username)9 User (com.thoughtworks.go.domain.User)8 Date (java.util.Date)8 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)5 BaseMatcher (org.hamcrest.BaseMatcher)4 Description (org.hamcrest.Description)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Permissions (com.thoughtworks.go.config.security.Permissions)2 PipelineInstanceModels.createPipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 PipelineSelectionResponse (com.thoughtworks.go.apiv1.pipelineselection.representers.PipelineSelectionResponse)1 DashboardFor (com.thoughtworks.go.apiv2.dashboard.representers.DashboardFor)1 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)1 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)1 GoDashboardPipelineGroup (com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1