test/jdk/javax/management/remote/rest/RestAdapterConfigTest.java
author hb
Thu, 04 Jan 2018 14:39:04 +0530
branchjmx-rest-api
changeset 56006 352a4f213fc6
parent 56003 4f7f76f6be2f
child 56026 bd531f08d7c7
permissions -rw-r--r--
1. URL decoding of URL 2. MBean info availble in MBeanCollection page 3. MBeanCollection post supports objectname filtering 4. Tests now use reflection instead of Methodhndles 3. couple of bug fixes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
     1
import org.testng.annotations.AfterClass;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
     2
import org.testng.annotations.BeforeClass;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
     3
import org.testng.annotations.Test;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
     4
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
     5
import javax.management.remote.rest.PlatformRestAdapter;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
     6
import javax.net.ssl.HttpsURLConnection;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
     7
import javax.net.ssl.KeyManagerFactory;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
     8
import javax.net.ssl.SSLContext;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
     9
import javax.net.ssl.TrustManagerFactory;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    10
import java.io.*;
56006
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
    11
import java.lang.reflect.Method;
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    12
import java.net.InetAddress;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    13
import java.net.UnknownHostException;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    14
import java.security.KeyStore;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    15
import java.util.Properties;
56006
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
    16
import java.util.Set;
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
    17
import java.util.stream.Collectors;
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
    18
import java.util.stream.Stream;
56003
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    19
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    20
/* @test
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    21
 * @summary Configuration test for rest adapter
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    22
 * @library /test/lib
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    23
 * @modules java.management.rest/com.oracle.jmx.remote.rest.http
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    24
 *          java.management.rest/com.oracle.jmx.remote.rest.json
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    25
 *          java.management.rest/com.oracle.jmx.remote.rest.json.parser
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    26
 *          java.management.rest/com.oracle.jmx.remote.rest.mapper
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    27
 * @build RestAdapterConfigTest RestAdapterTest
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    28
 * @run testng/othervm RestAdapterConfigTest
4f7f76f6be2f * Start Rest adapter via command line arguments
hb
parents: 56002
diff changeset
    29
 */
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    30
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    31
@Test
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    32
public class RestAdapterConfigTest {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    33
    private static String sslAgentConfig;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    34
    private static String sslClientConfig;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    35
    private static String passwordFile;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    36
    private static String configFile;
56006
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
    37
    private static RestAdapterTest restAdapterTest = new RestAdapterTest();
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
    38
    private static final Set<Method> tests;
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    39
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    40
    static {
56006
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
    41
        tests = Stream.of(RestAdapterTest.class.getMethods())
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
    42
                .filter(a -> a.getName().startsWith("test"))
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
    43
                .collect(Collectors.toSet());
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    44
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    45
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    46
    private void createAgentSslConfigFile(String fileName) throws IOException {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    47
        File f = new File(fileName);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    48
        if (f.exists()) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    49
            f.delete();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    50
        }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    51
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    52
        Properties props = new Properties();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    53
        String testDir = System.getProperty("test.src");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    54
        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreAgent");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    55
        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    56
        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreAgent");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    57
        props.setProperty("javax.net.ssl.trustStorePassword", "glopglop");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    58
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    59
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    60
            props.store(writer, "");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    61
        }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    62
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    63
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    64
    private void createClientSslConfigFile(String fileName) throws IOException {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    65
        File f = new File(fileName);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    66
        if (f.exists()) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    67
            f.delete();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    68
        }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    69
        Properties props = new Properties();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    70
        String testDir = System.getProperty("test.src");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    71
        props.setProperty("javax.net.ssl.keyStore", testDir + File.separator + "keystoreClient");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    72
        props.setProperty("javax.net.ssl.keyStorePassword", "glopglop");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    73
        props.setProperty("javax.net.ssl.trustStore", testDir + File.separator + "truststoreClient");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    74
        props.setProperty("javax.net.ssl.trustStorePassword", "glopglop");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    75
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    76
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    77
            props.store(writer, "");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    78
        }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    79
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    80
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    81
    private void setupMgmtConfig(String fileName, boolean isSSL, boolean isAuth) throws IOException {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    82
        Properties props = new Properties();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    83
        File f = new File(fileName);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    84
        if (f.exists()) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    85
            f.delete();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    86
        }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    87
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    88
        props.setProperty("com.sun.management.jmxremote.ssl", isSSL ? "true" : "false");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    89
        if(isSSL) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    90
            props.setProperty("com.sun.management.jmxremote.ssl.config.file", sslAgentConfig);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    91
        }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    92
        props.setProperty("com.sun.management.jmxremote.authenticate", isAuth ? "true" : "false");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    93
        if (isAuth) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    94
            props.setProperty("com.sun.management.jmxremote.password.file", passwordFile);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    95
        }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    96
        props.setProperty("com.sun.management.jmxremote.rest.port", "0");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    97
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    98
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
    99
            props.store(writer, "");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   100
        }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   101
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   102
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   103
    @BeforeClass
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   104
    public void init() throws Exception {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   105
        String testSrcRoot = System.getProperty("test.src") + File.separator;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   106
        sslAgentConfig = testSrcRoot + "sslConfigAgent";
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   107
        sslClientConfig = testSrcRoot + "sslConfigClient";
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   108
        passwordFile = testSrcRoot + "password.properties";
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   109
        configFile = testSrcRoot + "mgmt.properties";
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   110
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   111
        createAgentSslConfigFile(sslAgentConfig);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   112
        createClientSslConfigFile(sslClientConfig);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   113
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   114
        SSLContext ctx = getSSlContext(sslClientConfig);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   115
        HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   116
        HttpsURLConnection.setDefaultHostnameVerifier(
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   117
                (String hostname, javax.net.ssl.SSLSession sslSession) -> {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   118
                    try {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   119
                        return hostname.equals(InetAddress.getLocalHost().getHostName());
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   120
                    } catch (UnknownHostException ex) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   121
                        throw new RuntimeException(ex);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   122
                    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   123
                });
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   124
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   125
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   126
    private static SSLContext getSSlContext(String sslConfigFileName) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   127
        final String keyStore, keyStorePassword, trustStore, trustStorePassword;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   128
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   129
        try {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   130
            Properties p = new Properties();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   131
            BufferedInputStream bin = new BufferedInputStream(new FileInputStream(sslConfigFileName));
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   132
            p.load(bin);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   133
            keyStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_FILE);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   134
            keyStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_KEYSTORE_PASSWORD);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   135
            trustStore = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_FILE);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   136
            trustStorePassword = p.getProperty(PlatformRestAdapter.PropertyNames.SSL_TRUSTSTORE_PASSWORD);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   137
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   138
            char[] keyStorePasswd = null;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   139
            if (keyStorePassword.length() != 0) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   140
                keyStorePasswd = keyStorePassword.toCharArray();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   141
            }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   142
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   143
            char[] trustStorePasswd = null;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   144
            if (trustStorePassword.length() != 0) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   145
                trustStorePasswd = trustStorePassword.toCharArray();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   146
            }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   147
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   148
            KeyStore ks = null;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   149
            if (keyStore != null) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   150
                ks = KeyStore.getInstance(KeyStore.getDefaultType());
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   151
                FileInputStream ksfis = new FileInputStream(keyStore);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   152
                ks.load(ksfis, keyStorePasswd);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   153
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   154
            }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   155
            KeyManagerFactory kmf = KeyManagerFactory.getInstance(
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   156
                    KeyManagerFactory.getDefaultAlgorithm());
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   157
            kmf.init(ks, keyStorePasswd);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   158
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   159
            KeyStore ts = null;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   160
            if (trustStore != null) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   161
                ts = KeyStore.getInstance(KeyStore.getDefaultType());
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   162
                FileInputStream tsfis = new FileInputStream(trustStore);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   163
                ts.load(tsfis, trustStorePasswd);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   164
            }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   165
            TrustManagerFactory tmf = TrustManagerFactory.getInstance(
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   166
                    TrustManagerFactory.getDefaultAlgorithm());
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   167
            tmf.init(ts);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   168
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   169
            SSLContext ctx = SSLContext.getInstance("SSL");
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   170
            ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   171
            return ctx;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   172
        } catch (Exception ex) {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   173
        }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   174
        return null;
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   175
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   176
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   177
    @Test
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   178
    public void testHttpNoAuth() throws Exception {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   179
        setupMgmtConfig(configFile, false, false);
56006
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   180
        restAdapterTest.setupServers();
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   181
        for (Method m : tests) {
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   182
            m.invoke(restAdapterTest);
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   183
        }
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   184
        restAdapterTest.tearDownServers();
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   185
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   186
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   187
    public void testHttpsNoAuth() throws Exception {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   188
        setupMgmtConfig(configFile, true, false);
56006
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   189
        restAdapterTest.setupServers();
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   190
        for (Method m : tests) {
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   191
            m.invoke(restAdapterTest);
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   192
        }
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   193
        restAdapterTest.tearDownServers();
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   194
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   195
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   196
    public void testHttpAuth() throws Exception {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   197
        setupMgmtConfig(configFile, false, true);
56006
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   198
        restAdapterTest.setupServers();
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   199
        for (Method m : tests) {
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   200
            m.invoke(restAdapterTest);
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   201
        }
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   202
        restAdapterTest.tearDownServers();
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   203
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   204
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   205
    public void testHttpsAuth() throws Exception {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   206
        setupMgmtConfig(configFile, true, true);
56006
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   207
        restAdapterTest.setupServers();
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   208
        for (Method m : tests) {
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   209
            m.invoke(restAdapterTest);
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   210
        }
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   211
        restAdapterTest.tearDownServers();
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   212
    }
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   213
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   214
    @AfterClass
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   215
    public void tearDown() {
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   216
        File f = new File(sslAgentConfig);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   217
        if (f.exists())
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   218
            f.delete();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   219
        f = new File(sslClientConfig);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   220
        if (f.exists())
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   221
            f.delete();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   222
        f = new File(configFile);
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   223
        if (f.exists())
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   224
            f.delete();
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   225
    }
56006
352a4f213fc6 1. URL decoding of URL
hb
parents: 56003
diff changeset
   226
56002
60ab3b595a8e Lot of bug fixes
hb
parents:
diff changeset
   227
}