Search in sources :

Example 1 with StringValueConfig

use of com.nextdoor.bender.config.value.StringValueConfig in project bender by Nextdoor.

the class HttpTransportFactoryTest method testBasicAuthHeaders.

@Test
public void testBasicAuthHeaders() {
    HttpTransportConfig config = new HttpTransportConfig();
    config.addHttpHeader("foo", "bar");
    BasicHttpAuthConfig auth = new BasicHttpAuthConfig();
    auth.setUsername("foo");
    auth.setPassword(new StringValueConfig("bar"));
    config.setBasicHttpAuth(auth);
    HttpTransportFactory factory = spy(new HttpTransportFactory());
    factory.setConf(config);
    ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
    verify(factory, times(1)).getClient(anyBoolean(), anyString(), captor.capture(), anyInt());
    Map<String, String> expected = new HashMap<String, String>();
    expected.put("foo", "bar");
    expected.put("Authorization", "Basic Zm9vOmJhcg==");
    assertEquals(expected, captor.getValue());
}
Also used : HashMap(java.util.HashMap) StringValueConfig(com.nextdoor.bender.config.value.StringValueConfig) Matchers.anyString(org.mockito.Matchers.anyString) HashMap(java.util.HashMap) Map(java.util.Map) BasicHttpAuthConfig(com.nextdoor.bender.auth.BasicHttpAuthConfig) Test(org.junit.Test)

Example 2 with StringValueConfig

use of com.nextdoor.bender.config.value.StringValueConfig in project bender by Nextdoor.

the class DatadogTransportSerializerTest method shouldSerialize.

@Test
public void shouldSerialize() {
    StringValueConfig apiKey = new StringValueConfig("foo");
    DatadogTransportSerializer serializer = new DatadogTransportSerializer(apiKey);
    InternalEvent record = new InternalEvent("", null, 0);
    record.setEventTime(1521645289128L);
    record.setSerialized("bar");
    String actual = new String(serializer.serialize(record), StandardCharsets.UTF_8);
    assertEquals("foo bar\n", actual);
}
Also used : StringValueConfig(com.nextdoor.bender.config.value.StringValueConfig) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Aggregations

StringValueConfig (com.nextdoor.bender.config.value.StringValueConfig)2 Test (org.junit.Test)2 InternalEvent (com.nextdoor.bender.InternalEvent)1 BasicHttpAuthConfig (com.nextdoor.bender.auth.BasicHttpAuthConfig)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matchers.anyString (org.mockito.Matchers.anyString)1