use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class PipelineStagesFeedServiceTest method shouldReturnUnauthorizedIfUserDoesNotHaveViewPermissionsForFeedBefore.
@Test
public void shouldReturnUnauthorizedIfUserDoesNotHaveViewPermissionsForFeedBefore() {
when(securityService.hasViewPermissionForPipeline(user, "cruise")).thenReturn(false);
FeedEntries feedEntries = pipelineStagesFeedResolver.feedBefore(user, 100L, operationResult);
assertThat(feedEntries, is(nullValue()));
verifyThatUserIsUnauthorized();
verifyNoMoreInteractions(stageService);
}
use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class StageServiceTest method shouldReturnFeedsEvenIfUpstreamPipelineIsDeleted.
@Test
public void shouldReturnFeedsEvenIfUpstreamPipelineIsDeleted() {
Date updateDate = new Date();
CruiseConfig config = mock(BasicCruiseConfig.class);
PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("down");
Map<Long, List<ModificationForPipeline>> expectedModMapDown = new HashMap<>();
Modification mod1 = checkinWithComment("revision", "#123 hello wolrd", updateDate);
expectedModMapDown.put(1L, asList(new ModificationForPipeline(new PipelineId("down", 1L), mod1, "Svn", "fooBarBaaz")));
FeedEntry expected = stageFeedEntry("down", updateDate);
when(stageDao.findCompletedStagesFor("down", FeedModifier.Latest, -1, 25)).thenReturn(asList(stageFeedEntry("down", updateDate), stageFeedEntry("down", updateDate)));
when(goConfigService.currentCruiseConfig()).thenReturn(config);
when(changesetService.modificationsOfPipelines(asList(1L, 1L), "down", Username.ANONYMOUS)).thenReturn(expectedModMapDown);
when(config.hasPipelineNamed(any(CaseInsensitiveString.class))).thenReturn(false).thenReturn(true);
when(config.pipelineConfigByName(any(CaseInsensitiveString.class))).thenReturn(pipelineConfig);
StageService service = new StageService(stageDao, null, null, null, null, null, changesetService, goConfigService, transactionTemplate, transactionSynchronizationManager, new StubGoCache(transactionSynchronizationManager));
FeedEntries feedEntries = service.feed("down", Username.ANONYMOUS);
assertThat(feedEntries).isEqualTo(new FeedEntries(asList(expected, expected)));
assertThat(feedEntries.get(0).getAuthors()).isEqualTo(asList(new Author(MOD_USER_COMMITTER, EMAIL_ADDRESS)));
assertThat(feedEntries.get(1).getAuthors()).isEqualTo(asList(new Author(MOD_USER_COMMITTER, EMAIL_ADDRESS)));
}
use of com.thoughtworks.go.domain.feed.FeedEntries in project gocd by gocd.
the class StageServiceIntegrationTest method shouldNotLoadStageAuthors_fromUpstreamInvisibleToUser.
@Test
public void shouldNotLoadStageAuthors_fromUpstreamInvisibleToUser() throws Exception {
PipelineConfig downstream = setup2DependentInstances();
configFileHelper.enableSecurity();
configFileHelper.addAdmins("super-hero");
configFileHelper.addAuthorizedUserForPipelineGroup("loser", "upstream-without-mingle");
configFileHelper.addAuthorizedUserForPipelineGroup("loser", "downstream");
configFileHelper.addAuthorizedUserForPipelineGroup("boozer", "upstream-with-mingle");
FeedEntries feed = stageService.feed(downstream.name().toString(), new Username(new CaseInsensitiveString("loser")));
assertAuthorsOnEntry((StageFeedEntry) feed.get(0), Arrays.asList(new Author("svn 3 guy", "svn.3@gmail.com"), new Author("p4 2 guy", "p4.2@gmail.com")));
assertAuthorsOnEntry((StageFeedEntry) feed.get(1), Arrays.asList(new Author("svn 1 guy", "svn.1@gmail.com"), new Author("svn 2 guy", "svn.2@gmail.com"), new Author("p4 1 guy", "p4.1@gmail.com")));
}
Aggregations