Search in sources :

Example 1 with UsernameCaseStrategyUtil

use of com.thinkbiganalytics.UsernameCaseStrategyUtil in project kylo by Teradata.

the class RefreshableDataSourceTest method init.

@Before
public void init() {
    env = Mockito.mock(Environment.class);
    securityContext = Mockito.mock(SecurityContext.class);
    authentication = Mockito.mock(Authentication.class);
    contextHolder = Mockito.mock(SecurityContextHolder.class);
    kerberosTicketConfiguration = Mockito.mock(KerberosTicketConfiguration.class);
    kerberosUtil = Mockito.mock(KerberosUtil.class);
    usernameCaseStrategyUtil = new UsernameCaseStrategyUtil();
    usernameCaseStrategyUtil.setEnvironment(env);
    Mockito.when(env.getProperty("hive.userImpersonation.enabled")).thenReturn("true");
    Mockito.when(env.getProperty("hive.datasource.driverClassName")).thenReturn("org.apache.hive.jdbc.HiveDriver");
    Mockito.when(env.getProperty("hive.datasource.url")).thenReturn("jdbc:hive2://localhost:10000/default");
    Mockito.when(env.getProperty("hive.datasource.username")).thenReturn(principal + "");
    Mockito.when(env.getProperty("hive.datasource.password")).thenReturn("password1234");
    Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
    SecurityContextHolder.setContext(securityContext);
    Mockito.when(authentication.getName()).thenReturn(principal);
    Mockito.when(kerberosTicketConfiguration.isKerberosEnabled()).thenReturn(false);
    hiveDs = new RefreshableDataSource(kerberosTicketConfiguration, usernameCaseStrategyUtil, env, "hive.datasource");
}
Also used : UsernameCaseStrategyUtil(com.thinkbiganalytics.UsernameCaseStrategyUtil) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) Environment(org.springframework.core.env.Environment) KerberosTicketConfiguration(com.thinkbiganalytics.kerberos.KerberosTicketConfiguration) KerberosUtil(com.thinkbiganalytics.kerberos.KerberosUtil) Before(org.junit.Before)

Aggregations

UsernameCaseStrategyUtil (com.thinkbiganalytics.UsernameCaseStrategyUtil)1 KerberosTicketConfiguration (com.thinkbiganalytics.kerberos.KerberosTicketConfiguration)1 KerberosUtil (com.thinkbiganalytics.kerberos.KerberosUtil)1 Before (org.junit.Before)1 Environment (org.springframework.core.env.Environment)1 Authentication (org.springframework.security.core.Authentication)1 SecurityContext (org.springframework.security.core.context.SecurityContext)1 SecurityContextHolder (org.springframework.security.core.context.SecurityContextHolder)1