Search in sources :

Example 1 with ClientBwListEntryDTO

use of com.hazelcast.internal.management.dto.ClientBwListEntryDTO in project hazelcast by hazelcast.

the class ClientBwListConfigHandler method createSelector.

private static ClientSelector createSelector(List<ClientBwListEntryDTO> entries) {
    ClientSelector selector = ClientSelectors.none();
    for (ClientBwListEntryDTO entryDTO : entries) {
        ClientSelector entrySelector = createSelector(entryDTO);
        selector = ClientSelectors.or(selector, entrySelector);
    }
    return selector;
}
Also used : ClientSelector(com.hazelcast.client.impl.ClientSelector) ClientBwListEntryDTO(com.hazelcast.internal.management.dto.ClientBwListEntryDTO)

Example 2 with ClientBwListEntryDTO

use of com.hazelcast.internal.management.dto.ClientBwListEntryDTO in project hazelcast by hazelcast.

the class ClientBwListConfigHandlerTest method testApplyConfig_whitelist.

@Test
public void testApplyConfig_whitelist() {
    ClientBwListDTO config = createConfig(Mode.WHITELIST, new ClientBwListEntryDTO(Type.IP_ADDRESS, "127.0.0.*"), new ClientBwListEntryDTO(Type.IP_ADDRESS, "192.168.0.1"), new ClientBwListEntryDTO(Type.IP_ADDRESS, "192.168.0.42-43"), new ClientBwListEntryDTO(Type.IP_ADDRESS, "fe80:0:0:0:45c5:47ee:fe15:493a"), new ClientBwListEntryDTO(Type.INSTANCE_NAME, "client*"), new ClientBwListEntryDTO(Type.LABEL, "label*"));
    handler.applyConfig(config);
    Client[] allowed = { createClient("127.0.0.3", "a_name"), createClient("192.168.0.1", "a_name"), createClient("192.168.0.42", "a_name"), createClient("fe80:0:0:0:45c5:47ee:fe15:493a", "a_name"), createClient("192.168.0.101", "client4"), createClient("192.168.0.101", "a_name", "label") };
    for (Client client : allowed) {
        assertTrue(clientEngine.isClientAllowed(client));
    }
    Client[] denied = { createClient("192.168.0.101", "a_name", "random"), createClient("fe70:0:0:0:35c5:16ee:fe15:491a", "a_name", "random") };
    for (Client client : denied) {
        assertFalse(clientEngine.isClientAllowed(client));
    }
}
Also used : ClientBwListEntryDTO(com.hazelcast.internal.management.dto.ClientBwListEntryDTO) Client(com.hazelcast.client.Client) ClientBwListDTO(com.hazelcast.internal.management.dto.ClientBwListDTO) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with ClientBwListEntryDTO

use of com.hazelcast.internal.management.dto.ClientBwListEntryDTO in project hazelcast by hazelcast.

the class ClientBwListConfigHandlerTest method testApplyConfig_nullEntryValue_throws.

@Test
public void testApplyConfig_nullEntryValue_throws() {
    ClientBwListDTO config = createConfig(Mode.WHITELIST, new ClientBwListEntryDTO(Type.IP_ADDRESS, null));
    assertThrows(NullPointerException.class, () -> handler.applyConfig(config));
}
Also used : ClientBwListEntryDTO(com.hazelcast.internal.management.dto.ClientBwListEntryDTO) ClientBwListDTO(com.hazelcast.internal.management.dto.ClientBwListDTO) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with ClientBwListEntryDTO

use of com.hazelcast.internal.management.dto.ClientBwListEntryDTO in project hazelcast by hazelcast.

the class ClientBwListConfigHandlerTest method testApplyConfig_blacklist.

@Test
public void testApplyConfig_blacklist() {
    ClientBwListDTO config = createConfig(Mode.BLACKLIST, new ClientBwListEntryDTO(Type.IP_ADDRESS, "127.0.0.*"), new ClientBwListEntryDTO(Type.IP_ADDRESS, "192.168.0.1"), new ClientBwListEntryDTO(Type.IP_ADDRESS, "192.168.*.42"), new ClientBwListEntryDTO(Type.IP_ADDRESS, "fe80:0:0:0:45c5:47ee:fe15:*"), new ClientBwListEntryDTO(Type.INSTANCE_NAME, "*_client"), new ClientBwListEntryDTO(Type.LABEL, "test*label"));
    handler.applyConfig(config);
    Client[] allowed = { createClient("192.168.0.101", "a_name", "random"), createClient("fe70:0:0:0:35c5:16ee:fe15:491a", "a_name", "random") };
    for (Client client : allowed) {
        assertTrue(clientEngine.isClientAllowed(client));
    }
    Client[] denied = { createClient("127.0.0.3", "a_name"), createClient("192.168.0.1", "a_name"), createClient("192.168.0.42", "a_name"), createClient("fe80:0:0:0:45c5:47ee:fe15:493a", "a_name"), createClient("192.168.0.101", "java_client"), createClient("192.168.0.101", "a_name", "test_label"), createClient("192.168.0.101", "a_name", "testlabel") };
    for (Client client : denied) {
        assertFalse(clientEngine.isClientAllowed(client));
    }
}
Also used : ClientBwListEntryDTO(com.hazelcast.internal.management.dto.ClientBwListEntryDTO) Client(com.hazelcast.client.Client) ClientBwListDTO(com.hazelcast.internal.management.dto.ClientBwListDTO) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with ClientBwListEntryDTO

use of com.hazelcast.internal.management.dto.ClientBwListEntryDTO in project hazelcast by hazelcast.

the class ClientBwListConfigHandlerTest method testApplyConfig_nullEntryType_throws.

@Test
public void testApplyConfig_nullEntryType_throws() {
    ClientBwListDTO config = createConfig(Mode.WHITELIST, new ClientBwListEntryDTO(null, "127.0.0.*"));
    assertThrows(NullPointerException.class, () -> handler.applyConfig(config));
}
Also used : ClientBwListEntryDTO(com.hazelcast.internal.management.dto.ClientBwListEntryDTO) ClientBwListDTO(com.hazelcast.internal.management.dto.ClientBwListDTO) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientBwListEntryDTO (com.hazelcast.internal.management.dto.ClientBwListEntryDTO)5 ClientBwListDTO (com.hazelcast.internal.management.dto.ClientBwListDTO)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 Client (com.hazelcast.client.Client)2 ClientSelector (com.hazelcast.client.impl.ClientSelector)1