Search in sources :

Example 11 with SecurityService

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

the class BuildFilterServiceImplTest method before.

@Before
public void before() {
    BuildFilterRepository buildFilterRepository = mock(BuildFilterRepository.class);
    StructureService structureService = mock(StructureService.class);
    SecurityService securityService = mock(SecurityService.class);
    service = new BuildFilterServiceImpl(Collections.singletonList(new StandardBuildFilterProvider(structureService, mock(ValidationRunStatusService.class), mock(PropertyService.class), mock(CoreBuildFilterRepository.class))), buildFilterRepository, structureService, securityService);
}
Also used : CoreBuildFilterRepository(net.nemerosa.ontrack.repository.CoreBuildFilterRepository) BuildFilterRepository(net.nemerosa.ontrack.repository.BuildFilterRepository) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) StructureService(net.nemerosa.ontrack.model.structure.StructureService) Before(org.junit.Before)

Example 12 with SecurityService

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

the class DecorationServiceImplTest method base_exception_decoration_generates_default_error_decoration.

@Test
public void base_exception_decoration_generates_default_error_decoration() {
    ProjectEntity projectEntity = mock(ProjectEntity.class);
    DecorationExtension decorator = mock(DecorationExtension.class);
    when(decorator.getDecorations(any(ProjectEntity.class))).thenThrow(new TestBaseException());
    ExtensionManager extensionManager = mock(ExtensionManager.class);
    when(extensionManager.getExtensions(DecorationExtension.class)).thenReturn(Collections.singletonList(decorator));
    SecurityService securityService = mock(SecurityService.class);
    DecorationServiceImpl service = new DecorationServiceImpl(extensionManager, securityService);
    @SuppressWarnings("unchecked") List<? extends Decoration> decorations = service.getDecorations(projectEntity, decorator);
    assertNotNull(decorations);
    assertEquals(1, decorations.size());
    Decoration decoration = decorations.get(0);
    assertEquals("Known exception", decoration.getError());
    assertNull(decoration.getData());
}
Also used : ProjectEntity(net.nemerosa.ontrack.model.structure.ProjectEntity) ExtensionManager(net.nemerosa.ontrack.extension.api.ExtensionManager) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) DecorationExtension(net.nemerosa.ontrack.extension.api.DecorationExtension) Decoration(net.nemerosa.ontrack.model.structure.Decoration) Test(org.junit.Test)

Example 13 with SecurityService

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

the class DecorationServiceImplTest method error_decoration_generates_default_error_decoration.

@Test
public void error_decoration_generates_default_error_decoration() {
    ProjectEntity projectEntity = mock(ProjectEntity.class);
    DecorationExtension decorator = mock(DecorationExtension.class);
    when(decorator.getDecorations(any(ProjectEntity.class))).thenThrow(new RuntimeException("Error while generating the decoration"));
    ExtensionManager extensionManager = mock(ExtensionManager.class);
    when(extensionManager.getExtensions(DecorationExtension.class)).thenReturn(Collections.singletonList(decorator));
    SecurityService securityService = mock(SecurityService.class);
    DecorationServiceImpl service = new DecorationServiceImpl(extensionManager, securityService);
    @SuppressWarnings("unchecked") List<? extends Decoration> decorations = service.getDecorations(projectEntity, decorator);
    assertNotNull(decorations);
    assertEquals(1, decorations.size());
    Decoration decoration = decorations.get(0);
    assertNull(decoration.getData());
    assertEquals("Problem while getting decoration", decoration.getError());
}
Also used : ProjectEntity(net.nemerosa.ontrack.model.structure.ProjectEntity) ExtensionManager(net.nemerosa.ontrack.extension.api.ExtensionManager) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) DecorationExtension(net.nemerosa.ontrack.extension.api.DecorationExtension) Decoration(net.nemerosa.ontrack.model.structure.Decoration) Test(org.junit.Test)

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