@Test public void shouldNotConsiderNoMingleConfigAnError() { HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); MingleConfig mingleConfig = mingleConfigService.mingleConfigForPipelineNamed( "bar", new Username(new CaseInsensitiveString("admin")), result); assertThat(mingleConfig, is(nullValue())); assertThat(result.isSuccessful(), is(true)); }
@Test public void shouldNotAllowUnauthorizedUserToGetMingleConfig() { HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); MingleConfig mingleConfig = mingleConfigService.mingleConfigForPipelineNamed( "foo", new Username(new CaseInsensitiveString("some_loser")), result); assertThat(mingleConfig, is(nullValue())); assertThat(result.isSuccessful(), is(false)); assertThat( result.message(localizer), is("You do not have view permissions for pipeline 'foo'.")); assertThat(result.httpCode(), is(401)); }
@Test public void shouldFetchMingleConfigForAGivenPipeline() { HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); MingleConfig mingleConfig = mingleConfigService.mingleConfigForPipelineNamed( "foo", new Username(new CaseInsensitiveString("authorized_user")), result); assertThat( mingleConfig, is( new MingleConfig( "https://some-tracking-tool:8443", "project-super-secret", "hello=world"))); assertThat(result.isSuccessful(), is(true)); result = new HttpLocalizedOperationResult(); mingleConfig = mingleConfigService.mingleConfigForPipelineNamed( "foo", new Username(new CaseInsensitiveString("admin")), result); assertThat( mingleConfig, is( new MingleConfig( "https://some-tracking-tool:8443", "project-super-secret", "hello=world"))); assertThat(result.isSuccessful(), is(true)); }