use of com.synopsys.integration.alert.component.authentication.security.UserManagementAuthoritiesPopulator 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