Search in sources :

Example 1 with AuthenticationDescriptorKey

use of com.synopsys.integration.alert.component.authentication.descriptor.AuthenticationDescriptorKey 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());
}
Also used : FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) AlertFieldStatus(com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) AuthenticationDescriptorKey(com.synopsys.integration.alert.component.authentication.descriptor.AuthenticationDescriptorKey) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel) Test(org.junit.jupiter.api.Test)

Example 2 with AuthenticationDescriptorKey

use of com.synopsys.integration.alert.component.authentication.descriptor.AuthenticationDescriptorKey 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);
}
Also used : FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) Gson(com.google.gson.Gson) AlertProperties(com.synopsys.integration.alert.common.AlertProperties) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) GlobalConfigurationValidatorAsserter(com.synopsys.integration.alert.test.common.channel.GlobalConfigurationValidatorAsserter) AuthenticationDescriptorKey(com.synopsys.integration.alert.component.authentication.descriptor.AuthenticationDescriptorKey)

Example 3 with AuthenticationDescriptorKey

use of com.synopsys.integration.alert.component.authentication.descriptor.AuthenticationDescriptorKey in project hub-alert by blackducksoftware.

the class UserDetailsServiceTest method initializeAuthoritiesPopulator.

@BeforeEach
public void initializeAuthoritiesPopulator() {
    Set<UserRoleModel> roles = Arrays.stream(VALID_DB_ROLES).map(UserRoleModel::of).collect(Collectors.toSet());
    UserModel userModel = UserModel.newUser(USER_NAME, "password", EMAIL, AuthenticationType.SAML, roles, true);
    AuthenticationDescriptorKey key = new AuthenticationDescriptorKey();
    ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
    ConfigurationModel configuration = Mockito.mock(ConfigurationModel.class);
    UserAccessor userAccessor = Mockito.mock(UserAccessor.class);
    Mockito.when(configuration.getField(Mockito.anyString())).thenReturn(Optional.empty());
    Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.eq(key))).thenReturn(List.of(configuration));
    Mockito.when(userAccessor.getUser(Mockito.anyString())).thenReturn(Optional.of(userModel));
    authoritiesPopulator = new UserManagementAuthoritiesPopulator(key, configurationModelConfigurationAccessor, userAccessor);
}
Also used : UserModel(com.synopsys.integration.alert.common.persistence.model.UserModel) ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) UserManagementAuthoritiesPopulator(com.synopsys.integration.alert.component.authentication.security.UserManagementAuthoritiesPopulator) UserAccessor(com.synopsys.integration.alert.common.persistence.accessor.UserAccessor) AuthenticationDescriptorKey(com.synopsys.integration.alert.component.authentication.descriptor.AuthenticationDescriptorKey) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor) UserRoleModel(com.synopsys.integration.alert.common.persistence.model.UserRoleModel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

AuthenticationDescriptorKey (com.synopsys.integration.alert.component.authentication.descriptor.AuthenticationDescriptorKey)3 FilePersistenceUtil (com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil)2 Gson (com.google.gson.Gson)1 AlertProperties (com.synopsys.integration.alert.common.AlertProperties)1 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)1 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)1 UserAccessor (com.synopsys.integration.alert.common.persistence.accessor.UserAccessor)1 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)1 UserModel (com.synopsys.integration.alert.common.persistence.model.UserModel)1 UserRoleModel (com.synopsys.integration.alert.common.persistence.model.UserRoleModel)1 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)1 FieldValueModel (com.synopsys.integration.alert.common.rest.model.FieldValueModel)1 UserManagementAuthoritiesPopulator (com.synopsys.integration.alert.component.authentication.security.UserManagementAuthoritiesPopulator)1 MockAlertProperties (com.synopsys.integration.alert.test.common.MockAlertProperties)1 GlobalConfigurationValidatorAsserter (com.synopsys.integration.alert.test.common.channel.GlobalConfigurationValidatorAsserter)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1