Search in sources :

Example 66 with HttpOperationResult

use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.

the class MaterialConfigServiceTest method shouldPopulateErrorCorrectlyWhenUnauthorizedToViewMaterial_getMaterialConfigByFingerprint.

@Test
public void shouldPopulateErrorCorrectlyWhenUnauthorizedToViewMaterial_getMaterialConfigByFingerprint() {
    HttpOperationResult result = new HttpOperationResult();
    GitMaterialConfig gitMaterialConfig = new GitMaterialConfig("http://another.com");
    MaterialConfig materialConfig = materialConfigService.getMaterialConfig(user, gitMaterialConfig.getFingerprint(), result);
    assertThat(materialConfig, is(nullValue()));
    assertThat(result.httpCode(), is(401));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.Test)

Example 67 with HttpOperationResult

use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.

the class MaterialConfigServiceTest method shouldGetMaterialConfigByFingerprint.

@Test
public void shouldGetMaterialConfigByFingerprint() {
    HttpOperationResult result = new HttpOperationResult();
    GitMaterialConfig gitMaterialConfig = new GitMaterialConfig("http://crap.com");
    MaterialConfig materialConfig = materialConfigService.getMaterialConfig(user, gitMaterialConfig.getFingerprint(), result);
    assertThat(materialConfig, is(gitMaterialConfig));
    assertThat(result.canContinue(), is(true));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.Test)

Example 68 with HttpOperationResult

use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.

the class PipelineOperationsControllerV1Delegate method schedule.

public String schedule(Request req, Response res) throws IOException {
    HttpOperationResult result = new HttpOperationResult();
    String pipelineName = req.params("pipeline_name");
    pipelineTriggerService.schedule(pipelineName, getScheduleOptions(req), currentUsername(), result);
    return renderHTTPOperationResult(result, req, res);
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult)

Example 69 with HttpOperationResult

use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.

the class AgentServiceIntegrationTest method testShouldThrowErrorOnUpdatingAgentOnInvalidInputs.

@Test
public void testShouldThrowErrorOnUpdatingAgentOnInvalidInputs() throws Exception {
    AgentConfig agent = createDisabledAndIdleAgent(UUID);
    String originalHostname = agent.getHostname();
    List<String> originalResourceNames = agent.getResourceConfigs().resourceNames();
    goConfigDao.load();
    assertThat(agentService.agents().size(), is(1));
    assertThat(getFirstAgent().getHostname(), is(not("some-hostname")));
    HttpOperationResult operationResult = new HttpOperationResult();
    AgentInstance agentInstance = agentService.updateAgentAttributes(USERNAME, operationResult, UUID, "some-hostname", "lin!ux", null, TriState.UNSET);
    assertThat(operationResult.httpCode(), is(422));
    assertThat(operationResult.message(), is("Updating agent failed:"));
    assertThat(agentInstance.agentConfig().getResourceConfigs().first().errors().on(JobConfig.RESOURCES), is("Resource name 'lin!ux' is not valid. Valid names much match '^[-\\w\\s|.]*$'"));
    assertThat(agentService.agents().size(), is(1));
    assertThat(getFirstAgent().getHostname(), is(originalHostname));
    assertThat(getFirstAgent().getResourceConfigs().resourceNames(), is(originalResourceNames));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Test(org.junit.Test)

Example 70 with HttpOperationResult

use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.

the class AgentServiceIntegrationTest method shouldDisableMultipleAgents.

@Test
public void shouldDisableMultipleAgents() {
    AgentConfig agentConfig1 = createEnabledAgent(UUID);
    AgentConfig agentConfig2 = createEnabledAgent(UUID2);
    HttpOperationResult operationResult = new HttpOperationResult();
    agentService.disableAgents(USERNAME, operationResult, Arrays.asList(UUID, UUID2));
    assertThat(operationResult.httpCode(), is(200));
    assertThat(isDisabled(agentConfig1), is(true));
    assertThat(isDisabled(agentConfig2), is(true));
    assertThat(operationResult.message(), containsString("Disabled 2 agent(s)"));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Test(org.junit.Test)

Aggregations

HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)146 Test (org.junit.jupiter.api.Test)64 Test (org.junit.Test)53 Username (com.thoughtworks.go.server.domain.Username)34 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 TriStateSelection (com.thoughtworks.go.presentation.TriStateSelection)12 Pagination (com.thoughtworks.go.server.util.Pagination)7 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)6 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)6 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)6 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)6 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 NullStage (com.thoughtworks.go.domain.NullStage)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 PipelineStatusModel (com.thoughtworks.go.presentation.PipelineStatusModel)4 Stage (com.thoughtworks.go.domain.Stage)3