use of org.apache.accumulo.core.client.security.tokens.KerberosToken in project accumulo by apache.
the class SaslConnectionParamsTest method testDefaultParams.
@Test
public void testDefaultParams() throws Exception {
final KerberosToken token = EasyMock.createMock(KerberosToken.class);
testUser.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
final ClientConfiguration clientConf = ClientConfiguration.loadDefault();
// The primary is the first component of the principal
final String primary = "accumulo";
clientConf.withSasl(true, primary);
final AccumuloConfiguration rpcConf = ClientContext.convertClientConfig(clientConf);
assertEquals("true", clientConf.get(ClientProperty.INSTANCE_RPC_SASL_ENABLED));
final SaslConnectionParams saslParams = new SaslConnectionParams(rpcConf, token);
assertEquals(primary, saslParams.getKerberosServerPrimary());
final QualityOfProtection defaultQop = QualityOfProtection.get(Property.RPC_SASL_QOP.getDefaultValue());
assertEquals(defaultQop, saslParams.getQualityOfProtection());
Map<String, String> properties = saslParams.getSaslProperties();
assertEquals(1, properties.size());
assertEquals(defaultQop.getQuality(), properties.get(Sasl.QOP));
assertEquals(username, saslParams.getPrincipal());
return null;
}
});
}
Aggregations