use of io.confluent.kafka.schemaregistry.client.security.basicauth.BasicAuthCredentialProvider in project flink by apache.
the class CachedSchemaCoderProviderTest method testThatBasicAuthIsInitializedForBasicAuthProperties.
@Test
public void testThatBasicAuthIsInitializedForBasicAuthProperties() {
String userPassword = "user:pwd";
Map<String, String> configs = new HashMap<>();
configs.put("basic.auth.credentials.source", "USER_INFO");
configs.put("basic.auth.user.info", userPassword);
CachedSchemaCoderProvider provider = initCachedSchemaCoderProvider(configs);
BasicAuthCredentialProvider basicAuthCredentialProvider = getBasicAuthFromProvider(provider);
assertNotNull(basicAuthCredentialProvider);
assertEquals(basicAuthCredentialProvider.getUserInfo(null), userPassword);
}
use of io.confluent.kafka.schemaregistry.client.security.basicauth.BasicAuthCredentialProvider in project flink-mirror by flink-ci.
the class CachedSchemaCoderProviderTest method testThatBasicAuthIsInitializedForBasicAuthProperties.
@Test
public void testThatBasicAuthIsInitializedForBasicAuthProperties() {
String userPassword = "user:pwd";
Map<String, String> configs = new HashMap<>();
configs.put("basic.auth.credentials.source", "USER_INFO");
configs.put("basic.auth.user.info", userPassword);
CachedSchemaCoderProvider provider = initCachedSchemaCoderProvider(configs);
BasicAuthCredentialProvider basicAuthCredentialProvider = getBasicAuthFromProvider(provider);
assertNotNull(basicAuthCredentialProvider);
assertEquals(basicAuthCredentialProvider.getUserInfo(null), userPassword);
}
use of io.confluent.kafka.schemaregistry.client.security.basicauth.BasicAuthCredentialProvider in project flink by splunk.
the class CachedSchemaCoderProviderTest method testThatBasicAuthIsInitializedForBasicAuthProperties.
@Test
public void testThatBasicAuthIsInitializedForBasicAuthProperties() {
String userPassword = "user:pwd";
Map<String, String> configs = new HashMap<>();
configs.put("basic.auth.credentials.source", "USER_INFO");
configs.put("basic.auth.user.info", userPassword);
CachedSchemaCoderProvider provider = initCachedSchemaCoderProvider(configs);
BasicAuthCredentialProvider basicAuthCredentialProvider = getBasicAuthFromProvider(provider);
assertNotNull(basicAuthCredentialProvider);
assertEquals(basicAuthCredentialProvider.getUserInfo(null), userPassword);
}
use of io.confluent.kafka.schemaregistry.client.security.basicauth.BasicAuthCredentialProvider in project flink by splunk.
the class CachedSchemaCoderProviderTest method testThatBasicAuthIsNotInitializedForNoBasicAuthProperties.
@Test
public void testThatBasicAuthIsNotInitializedForNoBasicAuthProperties() {
CachedSchemaCoderProvider provider = initCachedSchemaCoderProvider(new HashMap<>());
BasicAuthCredentialProvider basicAuthCredentialProvider = getBasicAuthFromProvider(provider);
assertNull(basicAuthCredentialProvider);
}
use of io.confluent.kafka.schemaregistry.client.security.basicauth.BasicAuthCredentialProvider in project schema-registry by confluentinc.
the class RestServiceTest method testSetBasicAuthRequestHeader.
/*
* Test setBasicAuthRequestHeader (private method) indirectly through getAllSubjects.
*/
@Test
public void testSetBasicAuthRequestHeader() throws Exception {
RestService restService = new RestService("http://localhost:8081");
BasicAuthCredentialProvider basicAuthCredentialProvider = createMock(BasicAuthCredentialProvider.class);
restService.setBasicAuthCredentialProvider(basicAuthCredentialProvider);
HttpURLConnection httpURLConnection = createNiceMock(HttpURLConnection.class);
InputStream inputStream = createNiceMock(InputStream.class);
expectNew(URL.class, anyString()).andReturn(url);
expect(url.openConnection()).andReturn(httpURLConnection);
expect(httpURLConnection.getURL()).andReturn(url);
expect(basicAuthCredentialProvider.getUserInfo(anyObject(URL.class))).andReturn("user:password");
expect(httpURLConnection.getResponseCode()).andReturn(HttpURLConnection.HTTP_OK);
// Make sure that the Authorization header is set with the correct value for "user:password"
httpURLConnection.setRequestProperty("Authorization", "Basic dXNlcjpwYXNzd29yZA==");
expectLastCall().once();
expect(httpURLConnection.getInputStream()).andReturn(inputStream);
expect(inputStream.read(anyObject(), anyInt(), anyInt())).andDelegateTo(createInputStream("[\"abc\"]")).anyTimes();
replay(URL.class, url);
replay(HttpURLConnection.class, httpURLConnection);
replay(basicAuthCredentialProvider);
replay(InputStream.class, inputStream);
restService.getAllSubjects();
verify(httpURLConnection);
}
Aggregations