Search in sources :

Example 1 with SecurityService

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

the class StructureServiceImplTest method before.

@Before
public void before() {
    SecurityService securityService = mock(SecurityService.class);
    ValidationRunStatusService validationRunStatusService = mock(ValidationRunStatusService.class);
    structureRepository = mock(StructureRepository.class);
    EventPostService eventService = mock(EventPostService.class);
    EventFactory eventFactory = mock(EventFactory.class);
    ExtensionManager extensionManager = mock(ExtensionManager.class);
    PropertyService propertyService = mock(PropertyService.class);
    PredefinedPromotionLevelService predefinedPromotionLevelService = mock(PredefinedPromotionLevelService.class);
    PredefinedValidationStampService predefinedValidationStampService = mock(PredefinedValidationStampService.class);
    DecorationService decorationService = mock(DecorationService.class);
    ProjectFavouriteService projectFavouriteService = mock(ProjectFavouriteService.class);
    service = new StructureServiceImpl(securityService, eventService, eventFactory, validationRunStatusService, structureRepository, extensionManager, propertyService, predefinedPromotionLevelService, predefinedValidationStampService, decorationService, projectFavouriteService);
    // Model
    Project project = Project.of(nd("P", "Project")).withId(ID.of(1));
    Branch branch = Branch.of(project, nd("B", "Branch")).withId(ID.of(1));
    copper = PromotionLevel.of(branch, nd("COPPER", "")).withId(ID.of(1));
    build = Build.of(branch, nd("1", "Build 1"), Signature.of("test")).withId(ID.of(1));
}
Also used : PredefinedPromotionLevelService(net.nemerosa.ontrack.model.settings.PredefinedPromotionLevelService) EventPostService(net.nemerosa.ontrack.model.events.EventPostService) EventFactory(net.nemerosa.ontrack.model.events.EventFactory) PredefinedValidationStampService(net.nemerosa.ontrack.model.settings.PredefinedValidationStampService) StructureRepository(net.nemerosa.ontrack.repository.StructureRepository) ExtensionManager(net.nemerosa.ontrack.extension.api.ExtensionManager) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) Before(org.junit.Before)

Example 2 with SecurityService

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

the class SecurityServiceTestUtils method securityService.

public static SecurityService securityService() {
    SecurityService service = mock(SecurityService.class);
    when(service.runAsAdmin(any(Runnable.class))).thenAnswer(invocation -> (Runnable) invocation.getArguments()[0]);
    return service;
}
Also used : SecurityService(net.nemerosa.ontrack.model.security.SecurityService)

Example 3 with SecurityService

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

the class ConfigurationServiceTest method before.

@Before
public void before() {
    configurationRepository = mock(ConfigurationRepository.class);
    securityService = mock(SecurityService.class);
    encryptionService = mock(EncryptionService.class);
    eventPostService = mock(EventPostService.class);
    eventFactory = mock(EventFactory.class);
    OntrackConfigProperties ontrackConfigProperties = new OntrackConfigProperties();
    configurationService = new TestConfigurationServiceImpl(configurationRepository, securityService, encryptionService, eventPostService, eventFactory, ontrackConfigProperties);
}
Also used : SecurityService(net.nemerosa.ontrack.model.security.SecurityService) EncryptionService(net.nemerosa.ontrack.model.security.EncryptionService) EventPostService(net.nemerosa.ontrack.model.events.EventPostService) EventFactory(net.nemerosa.ontrack.model.events.EventFactory) TestConfigurationServiceImpl(net.nemerosa.ontrack.extension.api.support.TestConfigurationServiceImpl) ConfigurationRepository(net.nemerosa.ontrack.model.support.ConfigurationRepository) OntrackConfigProperties(net.nemerosa.ontrack.model.support.OntrackConfigProperties) Before(org.junit.Before)

Example 4 with SecurityService

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

the class AbstractResourceTest method before.

@Before
public void before() {
    securityService = Mockito.mock(SecurityService.class);
    mapper = new ResourceObjectMapperFactory().resourceObjectMapper(Collections.emptyList(), new DefaultResourceContext(new MockURIBuilder(), securityService));
}
Also used : SecurityService(net.nemerosa.ontrack.model.security.SecurityService) MockURIBuilder(net.nemerosa.ontrack.ui.controller.MockURIBuilder) Before(org.junit.Before)

Example 5 with SecurityService

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

the class ArtifactoryPromotionSyncServiceImplTest method setup.

@Before
public void setup() {
    structureService = mock(StructureService.class);
    propertyService = mock(PropertyService.class);
    ArtifactoryClientFactory artifactoryClientFactory = mock(ArtifactoryClientFactory.class);
    ArtifactoryConfigurationService configurationService = mock(ArtifactoryConfigurationService.class);
    ArtifactoryConfProperties artifactoryConfProperties = new ArtifactoryConfProperties();
    SecurityService securityService = mock(SecurityService.class);
    doAnswer(invocation -> {
        Supplier run = (Supplier) invocation.getArguments()[0];
        return run.get();
    }).when(securityService).asAdmin(any(Supplier.class));
    service = new ArtifactoryPromotionSyncServiceImpl(structureService, propertyService, artifactoryClientFactory, configurationService, artifactoryConfProperties, securityService);
    // Fake Artifactory client
    artifactoryClient = mock(ArtifactoryClient.class);
    when(artifactoryClientFactory.getClient(any())).thenReturn(artifactoryClient);
    // Branch to sync
    project = Project.of(new NameDescription("P", "Project")).withId(ID.of(1));
    branch = Branch.of(project, new NameDescription("B", "Branch")).withId(ID.of(10));
    // Existing build
    build = Build.of(branch, new NameDescription("1.0.0", "Build 1.0.0"), Signature.of("test")).withId(ID.of(100));
    when(structureService.findBuildByName("P", "B", "1.0.0")).thenReturn(Optional.of(build));
    // Existing promotions
    when(artifactoryClient.getStatuses(any())).thenReturn(Collections.singletonList(new ArtifactoryStatus("COPPER", "x", Time.now())));
    // Existing promotion level
    promotionLevel = PromotionLevel.of(branch, new NameDescription("COPPER", "Copper level")).withId(ID.of(100));
    when(structureService.findPromotionLevelByName("P", "B", "COPPER")).thenReturn(Optional.of(promotionLevel));
}
Also used : ArtifactoryConfProperties(net.nemerosa.ontrack.extension.artifactory.ArtifactoryConfProperties) ArtifactoryClientFactory(net.nemerosa.ontrack.extension.artifactory.client.ArtifactoryClientFactory) ArtifactoryConfigurationService(net.nemerosa.ontrack.extension.artifactory.configuration.ArtifactoryConfigurationService) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) Supplier(java.util.function.Supplier) ArtifactoryStatus(net.nemerosa.ontrack.extension.artifactory.model.ArtifactoryStatus) ArtifactoryClient(net.nemerosa.ontrack.extension.artifactory.client.ArtifactoryClient) 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