use of org.apache.druid.metadata.DefaultPasswordProvider in project druid by druid-io.
the class HttpInputSourceTest method testSerde.
@Test
public void testSerde() throws IOException {
HttpInputSourceConfig httpInputSourceConfig = new HttpInputSourceConfig(null);
final ObjectMapper mapper = new ObjectMapper();
mapper.setInjectableValues(new Std().addValue(HttpInputSourceConfig.class, httpInputSourceConfig));
final HttpInputSource source = new HttpInputSource(ImmutableList.of(URI.create("http://test.com/http-test")), "myName", new DefaultPasswordProvider("myPassword"), httpInputSourceConfig);
final byte[] json = mapper.writeValueAsBytes(source);
final HttpInputSource fromJson = (HttpInputSource) mapper.readValue(json, InputSource.class);
Assert.assertEquals(source, fromJson);
}
use of org.apache.druid.metadata.DefaultPasswordProvider in project druid by druid-io.
the class AWSCredentialsConfigTest method testJsonProperty.
@Test
public void testJsonProperty() throws Exception {
final String someSecret = new ObjectMapper().writeValueAsString(new DefaultPasswordProvider(SOME_SECRET));
properties.put(PROPERTY_PREFIX + ".accessKey", someSecret);
properties.put(PROPERTY_PREFIX + ".secretKey", someSecret);
final Injector injector = Guice.createInjector(binder -> {
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/test/redis");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(-1);
binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
binder.bindScope(LazySingleton.class, Scopes.SINGLETON);
binder.bind(JsonConfigurator.class).in(LazySingleton.class);
binder.bind(Properties.class).toInstance(properties);
JsonConfigProvider.bind(binder, PROPERTY_PREFIX, AWSCredentialsConfig.class);
});
final AWSCredentialsConfig credentialsConfig = injector.getInstance(AWSCredentialsConfig.class);
Assert.assertEquals(SOME_SECRET, credentialsConfig.getAccessKey().getPassword());
Assert.assertEquals(SOME_SECRET, credentialsConfig.getSecretKey().getPassword());
}
use of org.apache.druid.metadata.DefaultPasswordProvider in project druid by druid-io.
the class CoordinatorBasicAuthenticatorResourceTest method setUp.
@Before
public void setUp() {
req = EasyMock.createStrictMock(HttpServletRequest.class);
objectMapper = new ObjectMapper(new SmileFactory());
TestDerbyConnector connector = derbyConnectorRule.getConnector();
MetadataStorageTablesConfig tablesConfig = derbyConnectorRule.metadataTablesConfigSupplier().get();
connector.createConfigTable();
ObjectMapper objectMapper = new ObjectMapper(new SmileFactory());
AuthenticatorMapper authenticatorMapper = new AuthenticatorMapper(ImmutableMap.of(AUTHENTICATOR_NAME, new BasicHTTPAuthenticator(null, AUTHENTICATOR_NAME, null, new DefaultPasswordProvider("druid"), new DefaultPasswordProvider("druid"), null, null, null, false, null), AUTHENTICATOR_NAME2, new BasicHTTPAuthenticator(null, AUTHENTICATOR_NAME2, null, new DefaultPasswordProvider("druid"), new DefaultPasswordProvider("druid"), null, null, null, false, null), AUTHENTICATOR_NAME_LDAP, new BasicHTTPAuthenticator(null, AUTHENTICATOR_NAME2, null, new DefaultPasswordProvider("druid"), new DefaultPasswordProvider("druid"), null, null, null, false, null)));
storageUpdater = new CoordinatorBasicAuthenticatorMetadataStorageUpdater(authenticatorMapper, connector, tablesConfig, new BasicAuthCommonCacheConfig(null, null, null, null), objectMapper, new NoopBasicAuthenticatorCacheNotifier(), null);
resource = new BasicAuthenticatorResource(new CoordinatorBasicAuthenticatorResourceHandler(storageUpdater, authenticatorMapper, objectMapper), authValidator);
storageUpdater.start();
}
use of org.apache.druid.metadata.DefaultPasswordProvider in project druid by druid-io.
the class HttpFirehoseFactoryTest method testSerde.
@Test
public void testSerde() throws IOException {
final HttpInputSourceConfig inputSourceConfig = new HttpInputSourceConfig(null);
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new Std().addValue(HttpInputSourceConfig.class, inputSourceConfig));
final DefaultPasswordProvider pwProvider = new DefaultPasswordProvider("testPassword");
final HttpFirehoseFactory factory = new HttpFirehoseFactory(ImmutableList.of(URI.create("http://foo/bar"), URI.create("http://foo/bar2")), 2048L, 1024L, 512L, 100L, 5, "testUser", pwProvider, inputSourceConfig);
final HttpFirehoseFactory outputFact = mapper.readValue(mapper.writeValueAsString(factory), HttpFirehoseFactory.class);
Assert.assertEquals(factory, outputFact);
}
Aggregations