Search in sources :

Example 1 with Authorization

use of com.thoughtworks.go.config.Authorization in project gocd by gocd.

the class CcTrayViewAuthorityTest method shouldNotConsiderAllUsersAsViewersOfAGroup_WhenExplicitGroupAdminIsSetup.

@Test
public void shouldNotConsiderAllUsersAsViewersOfAGroup_WhenExplicitGroupAdminIsSetup() throws Exception {
    configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1", "job1A2");
    configMother.addAdminUserForPipelineGroup(config, "groupadmin1", "group1");
    PipelineConfigs group = config.findGroup("group1");
    assertThat(group.getAuthorization(), is(not(new Authorization())));
    Viewers viewersOfGroup1 = getGroupsAndTheirViewers().get("group1");
    assertThat(viewersOfGroup1.contains("groupadmin1"), is(true));
    assertThat(viewersOfGroup1.contains("some-user"), is(false));
    assertThat(viewersOfGroup1.contains("some-other-user"), is(false));
}
Also used : Authorization(com.thoughtworks.go.config.Authorization) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) Test(org.junit.Test)

Example 2 with Authorization

use of com.thoughtworks.go.config.Authorization in project gocd by gocd.

the class CcTrayViewAuthorityTest method shouldConsiderAllUsersAsViewersOfAGroupWithNoAuthorizationConfigurationSetup.

@Test
public void shouldConsiderAllUsersAsViewersOfAGroupWithNoAuthorizationConfigurationSetup() throws Exception {
    configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1", "job1A2");
    PipelineConfigs group = config.findGroup("group1");
    assertThat(group.getAuthorization(), is(new Authorization()));
    Viewers viewersOfGroup1 = getGroupsAndTheirViewers().get("group1");
    assertThat(viewersOfGroup1.contains("some-user"), is(true));
    assertThat(viewersOfGroup1.contains("some-other-user"), is(true));
    assertThat(viewersOfGroup1.contains("any-random-user"), is(true));
}
Also used : Authorization(com.thoughtworks.go.config.Authorization) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) Test(org.junit.Test)

Example 3 with Authorization

use of com.thoughtworks.go.config.Authorization in project gocd by gocd.

the class CcTrayViewAuthorityTest method shouldConsiderAllUsersAsViewersOfAGroupWithNoAuthorizationConfigurationSetup_EvenWhenExplicitSuperAdminsAreSetup.

@Test
public void shouldConsiderAllUsersAsViewersOfAGroupWithNoAuthorizationConfigurationSetup_EvenWhenExplicitSuperAdminsAreSetup() throws Exception {
    configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1", "job1A2");
    configMother.addUserAsSuperAdmin(config, "superadmin1");
    PipelineConfigs group = config.findGroup("group1");
    assertThat(group.getAuthorization(), is(new Authorization()));
    Viewers viewersOfGroup1 = getGroupsAndTheirViewers().get("group1");
    assertThat(viewersOfGroup1.contains("superadmin1"), is(true));
    assertThat(viewersOfGroup1.contains("some-user"), is(true));
    assertThat(viewersOfGroup1.contains("some-other-user"), is(true));
    assertThat(viewersOfGroup1.contains("any-random-user"), is(true));
}
Also used : Authorization(com.thoughtworks.go.config.Authorization) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) Test(org.junit.Test)

Example 4 with Authorization

use of com.thoughtworks.go.config.Authorization in project gocd by gocd.

the class MingleConfigServiceIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    dbHelper.onSetUp();
    configHelper = new GoConfigFileHelper(goConfigDao);
    configHelper.onSetUp();
    configHelper.addPipeline("bar", "stage", MaterialConfigsMother.defaultMaterialConfigs(), "build");
    pipelineConfig = configHelper.addPipeline("foo", "stage", MaterialConfigsMother.defaultMaterialConfigs(), "build");
    configHelper.addMingleConfigToPipeline("foo", new MingleConfig("https://some-tracking-tool:8443", "project-super-secret", "hello=world"));
    CruiseConfig cruiseConfig = configHelper.load();
    PipelineConfigs group = cruiseConfig.findGroup("defaultGroup");
    group.setAuthorization(new Authorization(new ViewConfig(new AdminUser(new CaseInsensitiveString("authorized_user")))));
    configHelper.writeConfigFile(cruiseConfig);
    SecurityConfig securityConfig = new SecurityConfig(new LdapConfig(new GoCipher()), new PasswordFileConfig("/tmp/foo.passwd"), true);
    securityConfig.adminsConfig().add(new AdminUser(new CaseInsensitiveString("admin")));
    configHelper.addSecurity(securityConfig);
}
Also used : Authorization(com.thoughtworks.go.config.Authorization) LdapConfig(com.thoughtworks.go.config.LdapConfig) GoCipher(com.thoughtworks.go.security.GoCipher) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) ViewConfig(com.thoughtworks.go.config.ViewConfig) AdminUser(com.thoughtworks.go.config.AdminUser) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) MingleConfig(com.thoughtworks.go.config.MingleConfig) PasswordFileConfig(com.thoughtworks.go.config.PasswordFileConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Before(org.junit.Before)

Aggregations

Authorization (com.thoughtworks.go.config.Authorization)4 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)4 AllowedViewers (com.thoughtworks.go.domain.cctray.viewers.AllowedViewers)3 Viewers (com.thoughtworks.go.domain.cctray.viewers.Viewers)3 Test (org.junit.Test)3 AdminUser (com.thoughtworks.go.config.AdminUser)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 LdapConfig (com.thoughtworks.go.config.LdapConfig)1 MingleConfig (com.thoughtworks.go.config.MingleConfig)1 PasswordFileConfig (com.thoughtworks.go.config.PasswordFileConfig)1 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)1 ViewConfig (com.thoughtworks.go.config.ViewConfig)1 GoCipher (com.thoughtworks.go.security.GoCipher)1 GoConfigFileHelper (com.thoughtworks.go.util.GoConfigFileHelper)1 Before (org.junit.Before)1