Re: HTTPS testing
Eric Jablow <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
What I'd like is the ability to apply an arbitrary set of client X.509
certificates to my connections. In pseudocode, it would be like
@Test
public void testSuperuser() throws Exception {
X509Certificate supercert = certificate(SUPER_USER);
HttpClient httpclient = new HttpClient();
httpclient.getHostConfiguration().setProxy("myproxyhost", 8080);
httpclient.getState().setClientCertificate(supercert);
GetMethod httpget = new GetMethod("https://example.com/");
try {
httpclient.executeMethod(httpget);
// assert response code = 200.
} finally {
httpget.releaseConnection();
}
}
@Test
public void testUnauthorizeduser() throws Exception {
X509Certificate unauthcert = certificate(UNAUTHORIZED_USER);
HttpClient httpclient = new HttpClient();
httpclient.getHostConfiguration().setProxy("myproxyhost", 8080);
httpclient.getState().setClientCertificate(unauthcert);
GetMethod httpget = new GetMethod("https://example.com/");
try {
httpclient.executeMethod(httpget);
// assert response code == 401.
} finally {
httpget.releaseConnection();
}
}
If I need to play with socket factories, I'll learn how.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace