src/test/java/edu/ucla/library/iiif/auth/handlers/AccessCookieHandlerTest.java
@Test
    public final void testIsOnNetwork(final Vertx aVertx, final VertxTestContext aContext) {
        final Cidr4Trie<String> network = new Cidr4Trie<>();
        final String[] subnets = { "192.168.0.0/24", "127.0.0.0/16" };
        final String[] onNetwork = { "192.168.0.1", "127.0.0.1", "127.0.1.1" };
        final String[] offNetwork = { "192.168.1.1", "127.1.0.1", "127.1.1.1" };

        for (final String subnet : subnets) {
            network.put(new Cidr4(subnet), subnet);
        }

        try {
            for (final String ip : onNetwork) {
                assertTrue(AccessCookieHandler.isOnNetwork(new Ip4(ip), network));
            }
            for (final String ip : offNetwork) {
                assertFalse(AccessCookieHandler.isOnNetwork(new Ip4(ip), network));
            }
            aContext.completeNow();
        } catch (final Exception details) {
            aContext.failNow(details);
        }
    }
/**
     * Tests the IP address subnet check.
     *
     * @param aVertx A Vert.x instance
     * @param aContext A test context
     */
Tests the IP address subnet check.
@param aVertx A Vert.x instance
@param aContext A test context
Tests the IP address subnet check . @param aVertx A Vert . x instance @param aContext A test context
@Test
    public final void testIsOnNetwork(final Vertx aVertx, final VertxTestContext aContext) {
        final Cidr4Trie<String> network = new Cidr4Trie<>();
        final String[] subnets = { "192.168.0.0/24", "127.0.0.0/16" };
        final String[] onNetwork = { "192.168.0.1", "127.0.0.1", "127.0.1.1" };
        final String[] offNetwork = { "192.168.1.1", "127.1.0.1", "127.1.1.1" };
        for (final String subnet : subnets) {
            network.put(new Cidr4(subnet), subnet);
        }
        try {
            for (final String ip : onNetwork) {
                assertTrue(AccessCookieHandler.isOnNetwork(new Ip4(ip), network));
            }
            for (final String ip : offNetwork) {
                assertFalse(AccessCookieHandler.isOnNetwork(new Ip4(ip), network));
            }
            aContext.completeNow();
        } catch (final Exception details) {
            aContext.failNow(details);
        }
    }
@ Test public final void testIsOnNetwork ( final Vertx aVertx , final VertxTestContext aContext ) { final Cidr4Trie < String > network = new Cidr4Trie < > ( ) ; final String [ ] subnets = { "192.168.0.0/24" , "127.0.0.0/16" } ; final String [ ] onNetwork = { "192.168.0.1" , "127.0.0.1" , "127.0.1.1" } ; final String [ ] offNetwork = { "192.168.1.1" , "127.1.0.1" , "127.1.1.1" } ; for ( final String subnet : subnets ) { network . put ( new Cidr4 ( subnet ) , subnet ) ; } try { for ( final String ip : onNetwork ) { assertTrue ( AccessCookieHandler . isOnNetwork ( new Ip4 ( ip ) , network ) ) ; } for ( final String ip : offNetwork ) { assertFalse ( AccessCookieHandler . isOnNetwork ( new Ip4 ( ip ) , network ) ) ; } aContext . completeNow ( ) ; } catch ( final Exception details ) { aContext . failNow ( details ) ; } }
Tests the IP address subnet check.
Tests the IP address subnet check .