use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil in project hub-alert by blackducksoftware.
the class SettingsEncryptionValidatorTest method validateNotInitializedTest.
@Test
public void validateNotInitializedTest() {
MockAlertProperties alertPropertiesNoEncryption = new MockAlertProperties();
alertPropertiesNoEncryption.setEncryptionPassword("");
alertPropertiesNoEncryption.setEncryptionSalt("");
FilePersistenceUtil filePersistenceUtilWithoutProperties = new FilePersistenceUtil(alertPropertiesNoEncryption, gson);
EncryptionUtility encryptionUtilityWithoutProperties = new EncryptionUtility(alertPropertiesNoEncryption, filePersistenceUtilWithoutProperties);
SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
settingsEncryptionModel.setEncryptionPassword("password");
settingsEncryptionModel.setEncryptionGlobalSalt("globalSalt");
SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtilityWithoutProperties, systemMessageAccessor);
ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
assertFalse(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil in project hub-alert by blackducksoftware.
the class SamlManagerTest method init.
@BeforeEach
public void init() throws Exception {
gson = new Gson();
context = Mockito.mock(SAMLContext.class);
parserPool = Mockito.mock(ParserPool.class);
extendedMetadata = Mockito.mock(ExtendedMetadata.class);
metadataManager = new CachingMetadataManager(Collections.emptyList());
metadataManager.setKeyManager(new EmptyKeyManager());
metadataGenerator = Mockito.mock(MetadataGenerator.class);
currentConfiguration = Mockito.mock(ConfigurationModel.class);
alertProperties = Mockito.mock(AlertProperties.class);
Mockito.when(alertProperties.getAlertSecretsDir()).thenReturn("./testDB/run/secrets");
filePersistenceUtil = new FilePersistenceUtil(alertProperties, gson);
}
use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil in project hub-alert by blackducksoftware.
the class AuthenticationConfigurationValidatorTest method hasSamlMetadataFile.
@Test
public void hasSamlMetadataFile() {
Map<String, FieldValueModel> keyToValues = createValidSamlValues();
keyToValues.remove(AuthenticationDescriptor.KEY_SAML_METADATA_URL);
keyToValues.remove(AuthenticationDescriptor.KEY_SAML_ENTITY_BASE_URL);
FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class);
Mockito.when(filePersistenceUtil.uploadFileExists(Mockito.anyString())).thenReturn(true);
AuthenticationConfigurationFieldModelValidator authenticationConfigurationValidator = new AuthenticationConfigurationFieldModelValidator(filePersistenceUtil);
Set<AlertFieldStatus> alertFieldStatuses = authenticationConfigurationValidator.validate(new FieldModel(new AuthenticationDescriptorKey().getUniversalKey(), ConfigContextEnum.GLOBAL.name(), keyToValues));
assertEquals(1, alertFieldStatuses.size());
}
use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil in project hub-alert by blackducksoftware.
the class AuthenticationConfigurationValidatorTest method createValidatorAsserter.
private GlobalConfigurationValidatorAsserter createValidatorAsserter(Map<String, FieldValueModel> keyToValues) {
AlertProperties mockAlertProperties = new MockAlertProperties();
FilePersistenceUtil filePersistenceUtil = new FilePersistenceUtil(mockAlertProperties, new Gson());
return new GlobalConfigurationValidatorAsserter(new AuthenticationDescriptorKey().getUniversalKey(), new AuthenticationConfigurationFieldModelValidator(filePersistenceUtil), keyToValues);
}
use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil in project hub-alert by blackducksoftware.
the class SAMLStartupComponentTest method testInitialize.
@Test
public void testInitialize() throws Exception {
SAMLContext context = Mockito.mock(SAMLContext.class);
ParserPool parserPool = Mockito.mock(ParserPool.class);
ExtendedMetadata extendedMetadata = Mockito.mock(ExtendedMetadata.class);
MetadataManager metadataManager = Mockito.mock(MetadataManager.class);
MetadataGenerator metadataGenerator = Mockito.mock(MetadataGenerator.class);
ConfigurationModel currentConfiguration = Mockito.mock(ConfigurationModel.class);
FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class);
Mockito.when(context.getCurrentConfiguration()).thenReturn(currentConfiguration);
Mockito.when(context.isSAMLEnabled(Mockito.any(ConfigurationModel.class))).thenReturn(Boolean.TRUE.booleanValue());
Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.eq(AuthenticationDescriptor.KEY_SAML_METADATA_URL))).thenReturn("metadataURL");
Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.eq(AuthenticationDescriptor.KEY_SAML_ENTITY_ID))).thenReturn("entityId");
Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.eq(AuthenticationDescriptor.KEY_SAML_ENTITY_BASE_URL))).thenReturn("baseURL");
SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context);
SAMLStartupComponent startupComponent = new SAMLStartupComponent(samlManager);
startupComponent.initializeComponent();
Mockito.verify(context).disableSAML();
}
Aggregations