Search in sources :

Example 11 with ConfigData

use of org.apache.kafka.common.config.ConfigData in project kafka by apache.

the class DirectoryConfigProviderTest method testNullPathWithKey.

@Test
public void testNullPathWithKey() {
    ConfigData configData = provider.get(null, Collections.singleton("foo"));
    assertTrue(configData.data().isEmpty());
    assertNull(configData.ttl());
}
Also used : ConfigData(org.apache.kafka.common.config.ConfigData) Test(org.junit.jupiter.api.Test)

Example 12 with ConfigData

use of org.apache.kafka.common.config.ConfigData in project kafka by apache.

the class DirectoryConfigProviderTest method testNoSubdirs.

@Test
public void testNoSubdirs() {
    // Only regular files directly in the path directory are allowed, not in subdirs
    Set<String> keys = toSet(asList(subdir.getName(), String.join(File.separator, subdir.getName(), subdirFile.getName())));
    ConfigData configData = provider.get(dir.getAbsolutePath(), keys);
    assertTrue(configData.data().isEmpty());
    assertNull(configData.ttl());
}
Also used : ConfigData(org.apache.kafka.common.config.ConfigData) Test(org.junit.jupiter.api.Test)

Example 13 with ConfigData

use of org.apache.kafka.common.config.ConfigData in project kafka by apache.

the class DirectoryConfigProviderTest method testGetAllKeysAtPath.

@Test
public void testGetAllKeysAtPath() throws IOException {
    ConfigData configData = provider.get(dir.getAbsolutePath());
    assertEquals(toSet(asList(foo.getName(), bar.getName())), configData.data().keySet());
    assertEquals("FOO", configData.data().get(foo.getName()));
    assertEquals("BAR", configData.data().get(bar.getName()));
    assertNull(configData.ttl());
}
Also used : ConfigData(org.apache.kafka.common.config.ConfigData) Test(org.junit.jupiter.api.Test)

Example 14 with ConfigData

use of org.apache.kafka.common.config.ConfigData in project kafka by apache.

the class DirectoryConfigProviderTest method testEmptyPath.

@Test
public void testEmptyPath() {
    ConfigData configData = provider.get("");
    assertTrue(configData.data().isEmpty());
    assertNull(configData.ttl());
}
Also used : ConfigData(org.apache.kafka.common.config.ConfigData) Test(org.junit.jupiter.api.Test)

Example 15 with ConfigData

use of org.apache.kafka.common.config.ConfigData in project kafka by apache.

the class DirectoryConfigProviderTest method testNoTraversal.

@Test
public void testNoTraversal() {
    // Check we can't escape outside the path directory
    Set<String> keys = toSet(asList(String.join(File.separator, "..", siblingFile.getName()), String.join(File.separator, "..", siblingDir.getName()), String.join(File.separator, "..", siblingDir.getName(), siblingDirFile.getName())));
    ConfigData configData = provider.get(dir.getAbsolutePath(), keys);
    assertTrue(configData.data().isEmpty());
    assertNull(configData.ttl());
}
Also used : ConfigData(org.apache.kafka.common.config.ConfigData) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigData (org.apache.kafka.common.config.ConfigData)18 Test (org.junit.jupiter.api.Test)14 HashMap (java.util.HashMap)4 IOException (java.io.IOException)2 Reader (java.io.Reader)2 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2 ConfigException (org.apache.kafka.common.config.ConfigException)2 Test (org.junit.Test)2