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