use of org.apache.jena.atlas.web.HttpException in project jena by apache.
the class TestFusekiTestAuth method testServer_auth_bad_password.
@Test(expected = HttpException.class)
public void testServer_auth_bad_password() {
BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
credsProv.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(USER, "WRONG"));
HttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
try (TypedInputStream in = HttpOp.execHttpGet(FusekiTestAuth.urlDataset(), "*/*", client, null)) {
} catch (HttpException ex) {
throw assertAuthHttpException(ex);
}
}
use of org.apache.jena.atlas.web.HttpException in project jena by apache.
the class TestFusekiTestServer method testServer_2.
@Test
public void testServer_2() {
BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
credsProv.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("USER", "PASSWORD"));
HttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
// No auth set - should work.
try (TypedInputStream in = HttpOp.execHttpGet(FusekiTestServer.urlDataset(), "*/*")) {
} catch (HttpException ex) {
Assert.assertTrue(ex.getResponseCode() == HttpSC.FORBIDDEN_403 || ex.getResponseCode() == HttpSC.UNAUTHORIZED_401);
throw ex;
}
}
use of org.apache.jena.atlas.web.HttpException in project jena by apache.
the class TestFusekiTestAuth method testServer_auth_bad_user.
@Test(expected = HttpException.class)
public void testServer_auth_bad_user() {
BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
Credentials credentials = new UsernamePasswordCredentials("USERUSER", PASSWORD);
credsProvider.setCredentials(AuthScope.ANY, credentials);
HttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
try (TypedInputStream in = HttpOp.execHttpGet(FusekiTestAuth.urlDataset(), "*/*", client, null)) {
} catch (HttpException ex) {
throw assertAuthHttpException(ex);
}
}
use of org.apache.jena.atlas.web.HttpException in project jena by apache.
the class TestHttpOp method queryGet_02.
@Test(expected = HttpException.class)
public void queryGet_02() {
try {
// No query.
TypedInputStream in = HttpOp.execHttpGet(queryURL + "?query=");
IO.close(in);
} catch (HttpException ex) {
assertEquals(ex.getResponseCode(), HttpSC.BAD_REQUEST_400);
throw ex;
}
}
use of org.apache.jena.atlas.web.HttpException in project jena by apache.
the class TestHttpOp method httpGet_02.
@Test(expected = HttpException.class)
public void httpGet_02() {
try {
TypedInputStream in = HttpOp.execHttpGet(urlRoot() + "does-not-exist");
IO.close(in);
} catch (HttpException ex) {
assertEquals(HttpSC.NOT_FOUND_404, ex.getResponseCode());
throw ex;
}
}
Aggregations