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());
}
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);
}
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);
}
Aggregations