Search in sources :

Example 1 with UserSettingsClient

use of org.apache.metron.rest.user.UserSettingsClient in project metron by apache.

the class HBaseConfig method userSettingsClient.

@Bean()
public UserSettingsClient userSettingsClient() {
    UserSettingsClient userSettingsClient = new UserSettingsClient();
    userSettingsClient.init(() -> {
        try {
            return globalConfigService.get();
        } catch (RestException e) {
            throw new IllegalStateException("Unable to retrieve the global config.", e);
        }
    }, getTableProvider());
    return userSettingsClient;
}
Also used : UserSettingsClient(org.apache.metron.rest.user.UserSettingsClient) RestException(org.apache.metron.rest.RestException) Bean(org.springframework.context.annotation.Bean)

Example 2 with UserSettingsClient

use of org.apache.metron.rest.user.UserSettingsClient in project metron by apache.

the class AlertsUIServiceImplTest method setUp.

@BeforeEach
public void setUp() {
    kafkaService = mock(KafkaService.class);
    environment = mock(Environment.class);
    userSettingsClient = mock(UserSettingsClient.class);
    alertsUIService = new AlertsUIServiceImpl(kafkaService, environment, userSettingsClient);
    // use a fake clock for testing
    clock = new FakeClock();
    clock.elapseSeconds(1000);
    alertsUIService.setClock(clock);
    // assume user1 is logged in for tests
    Authentication authentication = Mockito.mock(Authentication.class);
    UserDetails userDetails = Mockito.mock(UserDetails.class);
    when(authentication.getPrincipal()).thenReturn(userDetails);
    when(userDetails.getUsername()).thenReturn(user1);
    SecurityContextHolder.getContext().setAuthentication(authentication);
}
Also used : KafkaService(org.apache.metron.rest.service.KafkaService) UserDetails(org.springframework.security.core.userdetails.UserDetails) UserSettingsClient(org.apache.metron.rest.user.UserSettingsClient) FakeClock(org.apache.metron.common.system.FakeClock) Authentication(org.springframework.security.core.Authentication) Environment(org.springframework.core.env.Environment) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

UserSettingsClient (org.apache.metron.rest.user.UserSettingsClient)2 FakeClock (org.apache.metron.common.system.FakeClock)1 RestException (org.apache.metron.rest.RestException)1 KafkaService (org.apache.metron.rest.service.KafkaService)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Bean (org.springframework.context.annotation.Bean)1 Environment (org.springframework.core.env.Environment)1 Authentication (org.springframework.security.core.Authentication)1 UserDetails (org.springframework.security.core.userdetails.UserDetails)1