Search in sources :

Example 6 with SecurityService

use of net.nemerosa.ontrack.model.security.SecurityService in project ontrack by nemerosa.

the class JenkinsServiceTest method before.

@Before
public void before() {
    SecurityService securityService = mock(SecurityService.class);
    configurationRepository = mock(ConfigurationRepository.class);
    encryptionService = mock(EncryptionService.class);
    JenkinsClientFactory jenkinsClientFactory = mock(JenkinsClientFactory.class);
    JenkinsClient okJenkinsClient = mock(JenkinsClient.class);
    when(jenkinsClientFactory.getClient(any(JenkinsConfiguration.class))).thenReturn(okJenkinsClient);
    OntrackConfigProperties ontrackConfigProperties = new OntrackConfigProperties();
    jenkinsService = new JenkinsConfigurationServiceImpl(configurationRepository, securityService, encryptionService, mock(EventPostService.class), mock(EventFactory.class), jenkinsClientFactory, ontrackConfigProperties);
}
Also used : JenkinsClient(net.nemerosa.ontrack.extension.jenkins.client.JenkinsClient) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) EncryptionService(net.nemerosa.ontrack.model.security.EncryptionService) JenkinsConfigurationServiceImpl(net.nemerosa.ontrack.extension.jenkins.JenkinsConfigurationServiceImpl) JenkinsClientFactory(net.nemerosa.ontrack.extension.jenkins.client.JenkinsClientFactory) ConfigurationRepository(net.nemerosa.ontrack.model.support.ConfigurationRepository) OntrackConfigProperties(net.nemerosa.ontrack.model.support.OntrackConfigProperties) JenkinsConfiguration(net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration) Before(org.junit.Before)

Example 7 with SecurityService

use of net.nemerosa.ontrack.model.security.SecurityService in project ontrack by nemerosa.

the class JIRAServiceTest method before.

@Before
public void before() {
    SecurityService securityService = mock(SecurityService.class);
    configurationRepository = mock(ConfigurationRepository.class);
    encryptionService = mock(EncryptionService.class);
    JIRASession jiraSession = mock(JIRASession.class);
    when(jiraSession.getClient()).thenReturn(mock(JIRAClient.class));
    JIRASessionFactory jiraSessionFactory = mock(JIRASessionFactory.class);
    when(jiraSessionFactory.create(any(JIRAConfiguration.class))).thenReturn(jiraSession);
    OntrackConfigProperties ontrackConfigProperties = new OntrackConfigProperties();
    jiraService = new JIRAConfigurationServiceImpl(configurationRepository, securityService, encryptionService, mock(EventPostService.class), mock(EventFactory.class), jiraSessionFactory, ontrackConfigProperties);
}
Also used : JIRAClient(net.nemerosa.ontrack.extension.jira.client.JIRAClient) JIRASession(net.nemerosa.ontrack.extension.jira.tx.JIRASession) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) EncryptionService(net.nemerosa.ontrack.model.security.EncryptionService) ConfigurationRepository(net.nemerosa.ontrack.model.support.ConfigurationRepository) JIRASessionFactory(net.nemerosa.ontrack.extension.jira.tx.JIRASessionFactory) OntrackConfigProperties(net.nemerosa.ontrack.model.support.OntrackConfigProperties) Before(org.junit.Before)

Example 8 with SecurityService

use of net.nemerosa.ontrack.model.security.SecurityService in project ontrack by nemerosa.

the class SVNBranchConfigurationPropertyTypeTest method not_editable_when_project_not_configured.

@Test
public void not_editable_when_project_not_configured() {
    Project project = Project.of(new NameDescription("P", "Project")).withId(ID.of(1));
    Branch branch = Branch.of(project, new NameDescription("B", "Branch")).withId(ID.of(1));
    PropertyService propertiesService = mock(PropertyService.class);
    when(propertiesService.hasProperty(project, SVNProjectConfigurationPropertyType.class)).thenReturn(false);
    SecurityService securityService = mock(SecurityService.class);
    when(securityService.isProjectFunctionGranted(1, ProjectConfig.class)).thenReturn(true);
    BuildSvnRevisionLinkService buildSvnRevisionLinkService = mock(BuildSvnRevisionLinkService.class);
    TagNameSvnRevisionLink tagNameSvnRevisionLink = new TagNameSvnRevisionLink(mock(SVNService.class), mock(StructureService.class));
    SVNBranchConfigurationPropertyType propertyType = new SVNBranchConfigurationPropertyType(new SVNExtensionFeature(new SCMExtensionFeature()), propertiesService, buildSvnRevisionLinkService, tagNameSvnRevisionLink);
    assertFalse(propertyType.canEdit(branch, securityService));
}
Also used : SVNExtensionFeature(net.nemerosa.ontrack.extension.svn.SVNExtensionFeature) TagNameSvnRevisionLink(net.nemerosa.ontrack.extension.svn.support.TagNameSvnRevisionLink) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) SCMExtensionFeature(net.nemerosa.ontrack.extension.scm.SCMExtensionFeature) BuildSvnRevisionLinkService(net.nemerosa.ontrack.extension.svn.model.BuildSvnRevisionLinkService) SVNService(net.nemerosa.ontrack.extension.svn.service.SVNService) Test(org.junit.Test)

Example 9 with SecurityService

use of net.nemerosa.ontrack.model.security.SecurityService in project ontrack by nemerosa.

the class SVNBranchConfigurationPropertyTypeTest method editable_when_project_configured.

@Test
public void editable_when_project_configured() {
    Project project = Project.of(new NameDescription("P", "Project")).withId(ID.of(1));
    Branch branch = Branch.of(project, new NameDescription("B", "Branch")).withId(ID.of(1));
    PropertyService propertiesService = mock(PropertyService.class);
    when(propertiesService.hasProperty(project, SVNProjectConfigurationPropertyType.class)).thenReturn(true);
    SecurityService securityService = mock(SecurityService.class);
    when(securityService.isProjectFunctionGranted(1, ProjectConfig.class)).thenReturn(true);
    BuildSvnRevisionLinkService buildSvnRevisionLinkService = mock(BuildSvnRevisionLinkService.class);
    TagNameSvnRevisionLink tagNameSvnRevisionLink = new TagNameSvnRevisionLink(mock(SVNService.class), mock(StructureService.class));
    SVNBranchConfigurationPropertyType propertyType = new SVNBranchConfigurationPropertyType(new SVNExtensionFeature(new SCMExtensionFeature()), propertiesService, buildSvnRevisionLinkService, tagNameSvnRevisionLink);
    assertTrue(propertyType.canEdit(branch, securityService));
}
Also used : SVNExtensionFeature(net.nemerosa.ontrack.extension.svn.SVNExtensionFeature) TagNameSvnRevisionLink(net.nemerosa.ontrack.extension.svn.support.TagNameSvnRevisionLink) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) SCMExtensionFeature(net.nemerosa.ontrack.extension.scm.SCMExtensionFeature) BuildSvnRevisionLinkService(net.nemerosa.ontrack.extension.svn.model.BuildSvnRevisionLinkService) SVNService(net.nemerosa.ontrack.extension.svn.service.SVNService) Test(org.junit.Test)

Example 10 with SecurityService

use of net.nemerosa.ontrack.model.security.SecurityService in project ontrack by nemerosa.

the class GitChangeLogResourceDecoratorTest method before.

@Before
public void before() {
    SecurityService securityService = mock(SecurityService.class);
    gitService = mock(GitService.class);
    mapper = new ResourceObjectMapperFactory().resourceObjectMapper(new DefaultResourceContext(new MockURIBuilder(), securityService), new GitChangeLogResourceDecorator(gitService));
}
Also used : SecurityService(net.nemerosa.ontrack.model.security.SecurityService) MockURIBuilder(net.nemerosa.ontrack.ui.controller.MockURIBuilder) GitService(net.nemerosa.ontrack.extension.git.service.GitService) DefaultResourceContext(net.nemerosa.ontrack.ui.resource.DefaultResourceContext) ResourceObjectMapperFactory(net.nemerosa.ontrack.ui.resource.ResourceObjectMapperFactory) Before(org.junit.Before)

Aggregations

SecurityService (net.nemerosa.ontrack.model.security.SecurityService)13 Before (org.junit.Before)8 Test (org.junit.Test)4 ExtensionManager (net.nemerosa.ontrack.extension.api.ExtensionManager)3 EncryptionService (net.nemerosa.ontrack.model.security.EncryptionService)3 ConfigurationRepository (net.nemerosa.ontrack.model.support.ConfigurationRepository)3 OntrackConfigProperties (net.nemerosa.ontrack.model.support.OntrackConfigProperties)3 DecorationExtension (net.nemerosa.ontrack.extension.api.DecorationExtension)2 SCMExtensionFeature (net.nemerosa.ontrack.extension.scm.SCMExtensionFeature)2 SVNExtensionFeature (net.nemerosa.ontrack.extension.svn.SVNExtensionFeature)2 BuildSvnRevisionLinkService (net.nemerosa.ontrack.extension.svn.model.BuildSvnRevisionLinkService)2 SVNService (net.nemerosa.ontrack.extension.svn.service.SVNService)2 TagNameSvnRevisionLink (net.nemerosa.ontrack.extension.svn.support.TagNameSvnRevisionLink)2 EventFactory (net.nemerosa.ontrack.model.events.EventFactory)2 EventPostService (net.nemerosa.ontrack.model.events.EventPostService)2 Decoration (net.nemerosa.ontrack.model.structure.Decoration)2 ProjectEntity (net.nemerosa.ontrack.model.structure.ProjectEntity)2 MockURIBuilder (net.nemerosa.ontrack.ui.controller.MockURIBuilder)2 Supplier (java.util.function.Supplier)1 TestConfigurationServiceImpl (net.nemerosa.ontrack.extension.api.support.TestConfigurationServiceImpl)1