Search in sources :

Example 1 with CertificatesDescriptorKey

use of com.synopsys.integration.alert.component.certificates.CertificatesDescriptorKey in project hub-alert by blackducksoftware.

the class CertificateControllerTestIT method init.

@BeforeEach
public void init() throws Exception {
    AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
    Mockito.when(authorizationManager.hasCreatePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    Mockito.when(authorizationManager.hasReadPermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    Mockito.when(authorizationManager.hasDeletePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    Mockito.when(authorizationManager.hasWritePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    Mockito.when(authorizationManager.hasExecutePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    certificateActions = new CertificateActions(certificatesDescriptorKey, authorizationManager, certificateAccessor, trustStoreService);
    mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(SecurityMockMvcConfigurers.springSecurity()).build();
    certTestUtil.init(alertProperties);
}
Also used : DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) CertificatesDescriptorKey(com.synopsys.integration.alert.component.certificates.CertificatesDescriptorKey) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) ConfigContextEnum(com.synopsys.integration.alert.common.enumeration.ConfigContextEnum) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with CertificatesDescriptorKey

use of com.synopsys.integration.alert.component.certificates.CertificatesDescriptorKey in project hub-alert by blackducksoftware.

the class CertificateActionsTestIT method createExceptionTest.

@Test
public void createExceptionTest() throws Exception {
    String certificateContent = certTestUtil.readCertificateContents();
    CertificateModel certificate = new CertificateModel(TEST_ALIAS, certificateContent, DateUtils.createCurrentDateString(DateUtils.UTC_DATE_FORMAT_TO_MINUTE));
    AlertTrustStoreManager trustStoreService = Mockito.mock(AlertTrustStoreManager.class);
    AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
    Mockito.when(authorizationManager.hasCreatePermission(Mockito.anyString(), Mockito.anyString())).thenReturn(Boolean.TRUE);
    Mockito.doThrow(new AlertException("Test exception")).when(trustStoreService).importCertificate(Mockito.any(CustomCertificateModel.class));
    CertificateActions certificateActions = new CertificateActions(new CertificatesDescriptorKey(), authorizationManager, certificateAccessor, trustStoreService);
    ActionResponse<CertificateModel> response = certificateActions.create(certificate);
    assertTrue(response.isError());
    assertTrue(certificateAccessor.getCertificates().isEmpty());
}
Also used : CustomCertificateModel(com.synopsys.integration.alert.common.persistence.model.CustomCertificateModel) CertificatesDescriptorKey(com.synopsys.integration.alert.component.certificates.CertificatesDescriptorKey) AlertTrustStoreManager(com.synopsys.integration.alert.component.certificates.AlertTrustStoreManager) CustomCertificateModel(com.synopsys.integration.alert.common.persistence.model.CustomCertificateModel) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with CertificatesDescriptorKey

use of com.synopsys.integration.alert.component.certificates.CertificatesDescriptorKey in project hub-alert by blackducksoftware.

the class CertificateActionsTestIT method init.

@BeforeEach
public void init() throws Exception {
    AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
    Mockito.when(authorizationManager.hasCreatePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    Mockito.when(authorizationManager.hasReadPermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    Mockito.when(authorizationManager.hasDeletePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    Mockito.when(authorizationManager.hasWritePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    Mockito.when(authorizationManager.hasExecutePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
    certificateActions = new CertificateActions(certificatesDescriptorKey, authorizationManager, certificateAccessor, trustStoreService);
    certTestUtil.init(alertProperties);
}
Also used : DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) CertificatesDescriptorKey(com.synopsys.integration.alert.component.certificates.CertificatesDescriptorKey) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) ConfigContextEnum(com.synopsys.integration.alert.common.enumeration.ConfigContextEnum) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)3 CertificatesDescriptorKey (com.synopsys.integration.alert.component.certificates.CertificatesDescriptorKey)3 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)2 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 CustomCertificateModel (com.synopsys.integration.alert.common.persistence.model.CustomCertificateModel)1 AlertTrustStoreManager (com.synopsys.integration.alert.component.certificates.AlertTrustStoreManager)1 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)1 Test (org.junit.jupiter.api.Test)1