Search in sources :

Example 11 with Username

use of com.thoughtworks.go.server.domain.Username in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldLoadPipelineInstanceWithMultipleRevisions.

@Test
public void shouldLoadPipelineInstanceWithMultipleRevisions() {
    Pipeline pipeline = pipelineOne.createPipelineWithFirstStageScheduled(ModificationsMother.multipleModifications(pipelineOne.pipelineConfig()));
    configHelper.setViewPermissionForGroup("group1", "foo");
    PipelineInstanceModel pipelineInstance = pipelineHistoryService.load(pipeline.getId(), new Username(new CaseInsensitiveString("foo")), new HttpOperationResult());
    assertThat(pipelineInstance, is(not(nullValue())));
    assertThat(pipelineInstance.hasNewRevisions(), is(false));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Example 12 with Username

use of com.thoughtworks.go.server.domain.Username in project gocd by gocd.

the class PipelinePauseServiceIntegrationTest method shouldTruncatePauseMessageIfGreaterThanAllowedLength.

@Test
public void shouldTruncatePauseMessageIfGreaterThanAllowedLength() throws Exception {
    String name = "pipeline-name";
    CruiseConfig cruiseConfig = GoConfigMother.configWithPipelines(name);
    configHelper.writeConfigFile(cruiseConfig);
    cachedGoConfig.forceReload();
    Username userName = new Username(new CaseInsensitiveString("UserFoo"));
    pipelinePauseService.pause(name, "tiny pause cause", userName);
    assertThat(pipelinePauseService.pipelinePauseInfo(name).getPauseCause(), is("tiny pause cause"));
    String stringWith255Chars = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    pipelinePauseService.pause(name, stringWith255Chars + "aa", userName);
    assertThat(pipelinePauseService.pipelinePauseInfo(name).getPauseCause(), is(stringWith255Chars));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 13 with Username

use of com.thoughtworks.go.server.domain.Username in project gocd by gocd.

the class PipelineScheduleServiceTest method manualSchedule.

private Pipeline manualSchedule(String pipelineName) throws Exception, StageAlreadyBuildingException {
    scheduleHelper.manuallySchedulePipelineWithRealMaterials(pipelineName, new Username(new CaseInsensitiveString("some user name")));
    scheduleService.autoSchedulePipelinesFromRequestBuffer();
    return pipelineService.mostRecentFullPipelineByName(pipelineName);
}
Also used : Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 14 with Username

use of com.thoughtworks.go.server.domain.Username in project gocd by gocd.

the class StageJsonPresentationModelTest method shouldEscapeBuildCauseMessage.

@Test
public void shouldEscapeBuildCauseMessage() throws Exception {
    String userWithHtmlCharacters = "<user>";
    pipeline.setBuildCause(BuildCause.createManualForced(materialRevisions(userWithHtmlCharacters), new Username(new CaseInsensitiveString(userWithHtmlCharacters))));
    StageJsonPresentationModel presenter = new StageJsonPresentationModel(pipeline, stage, null, new Agents());
    JsonTester jsonTester = new JsonTester(presenter.toJson());
    String expected = StringEscapeUtils.escapeHtml(userWithHtmlCharacters);
    jsonTester.shouldContain("{'buildCause':'Forced by " + expected + "'}");
}
Also used : Username(com.thoughtworks.go.server.domain.Username) Agents(com.thoughtworks.go.config.Agents) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 15 with Username

use of com.thoughtworks.go.server.domain.Username in project gocd by gocd.

the class UserHelperTest method shouldGetDisplayNameForAPasswordFileUser.

@Test
public void shouldGetDisplayNameForAPasswordFileUser() {
    GrantedAuthority[] authorities = { new GrantedAuthorityImpl("anything") };
    TestingAuthenticationToken authentication = new TestingAuthenticationToken(new GoUserPrinciple("user", "Full Name", "password", true, true, true, true, authorities), null, authorities);
    assertThat(UserHelper.getUserName(authentication), is(new Username(new CaseInsensitiveString("user"), "Full Name")));
}
Also used : GrantedAuthorityImpl(org.springframework.security.GrantedAuthorityImpl) Username(com.thoughtworks.go.server.domain.Username) GrantedAuthority(org.springframework.security.GrantedAuthority) GoUserPrinciple(com.thoughtworks.go.server.security.userdetail.GoUserPrinciple) TestingAuthenticationToken(org.springframework.security.providers.TestingAuthenticationToken) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

Username (com.thoughtworks.go.server.domain.Username)331 Test (org.junit.Test)268 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)133 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)84 Before (org.junit.Before)39 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)35 Pipeline (com.thoughtworks.go.domain.Pipeline)34 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)28 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)21 StringContains.containsString (org.hamcrest.core.StringContains.containsString)20 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)18 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)18 Modification (com.thoughtworks.go.domain.materials.Modification)17 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)15 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)15 ArrayList (java.util.ArrayList)15 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)14 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)13 UpdateConfigFromUI (com.thoughtworks.go.config.update.UpdateConfigFromUI)12 Date (java.util.Date)12