All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.boot.test.HostnameVerifierImplTest Maven / Gradle / Ivy

There is a newer version: 1.16.0
Show newest version
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

/*
 * @(#) $Id: HostnameVerifierImplTest.java 2647 2008-08-26 13:53:08Z webok $
 */
package at.spardat.xma.boot.test;

import java.util.Properties;

import at.spardat.xma.boot.Statics;
import at.spardat.xma.boot.transport.HostnameVerifierImpl;
import junit.framework.Assert;
import junit.framework.TestCase;

/**
 * @author s2877
 * @since version_number
 */
public class HostnameVerifierImplTest extends TestCase {

    /**
     * @param arg0
     */
    public HostnameVerifierImplTest(String arg0) {
        super(arg0);
    }

    public static void main(String[] args) {
        junit.awtui.TestRunner.run(HostnameVerifierImplTest.class);
    }

    public void testVerify() {
        Properties props = new Properties();
        props.setProperty("boot.transport.hostnameverify.ignore","*host|local*|pre*post|a*a*a|10.18.*");
        HostnameVerifierImpl hv =new HostnameVerifierImpl(props.getProperty(Statics.CFG_PROP_HOSTNAMEVERIFYIGNORE));
        Assert.assertTrue(hv.verify("myhost",null));
        Assert.assertTrue(!hv.verify("myhosty",null));
        Assert.assertTrue(hv.verify("host",null));
        Assert.assertTrue(hv.verify("localpc",null));
        Assert.assertTrue(!hv.verify("llocalpc",null));
        Assert.assertTrue(hv.verify("local",null));
        Assert.assertTrue(hv.verify("prepost",null));
        Assert.assertTrue(hv.verify("pre.gurke.post",null));
        Assert.assertTrue(!hv.verify("ababa",null));
        Assert.assertTrue(hv.verify("w0188000962",null));

        // wildcard for all hosts
        props = new Properties();
        props.setProperty("boot.transport.hostnameverify.ignore","*");
        hv =new HostnameVerifierImpl(props.getProperty(Statics.CFG_PROP_HOSTNAMEVERIFYIGNORE));
        Assert.assertTrue(hv.verify("alles",null));

        // no ignors at all
        props = new Properties();
        hv =new HostnameVerifierImpl(props.getProperty(Statics.CFG_PROP_HOSTNAMEVERIFYIGNORE));
        Assert.assertTrue(!hv.verify("alles",null));

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy