use of org.folio.okapi.common.OkapiClient in project okapi by folio-org.
the class SampleModuleTest method test1.
@Test
public void test1(TestContext context) {
Async async = context.async();
HashMap<String, String> headers = new HashMap<>();
headers.put(XOkapiHeaders.URL, URL);
headers.put(XOkapiHeaders.TENANT, "my-lib");
OkapiClient cli = new OkapiClient(URL, vertx, headers);
cli.get("/testb", res -> {
context.assertTrue(res.succeeded());
test2(context, cli, async);
});
}
use of org.folio.okapi.common.OkapiClient in project okapi by folio-org.
the class AuthModuleTest method testBadToken.
@Test
public void testBadToken(TestContext context) {
Async async = context.async();
HashMap<String, String> headers = new HashMap<>();
headers.put(XOkapiHeaders.URL, URL);
headers.put(XOkapiHeaders.TENANT, "my-lib");
OkapiClient cli = new OkapiClient(URL, vertx, headers);
cli.setOkapiToken("a.b");
cli.get("/badtoken", res -> {
cli.close();
context.assertTrue(res.failed());
context.assertEquals(ErrorType.USER, res.getType());
async.complete();
});
}
use of org.folio.okapi.common.OkapiClient in project okapi by folio-org.
the class AuthModuleTest method testBadTokenPayload.
@Test
public void testBadTokenPayload(TestContext context) {
Async async = context.async();
HashMap<String, String> headers = new HashMap<>();
headers.put(XOkapiHeaders.URL, URL);
headers.put(XOkapiHeaders.TENANT, "my-lib");
OkapiClient cli = new OkapiClient(URL, vertx, headers);
cli.setOkapiToken("dummyJwt.b.c");
cli.get("/badpayload", res -> {
cli.close();
context.assertTrue(res.failed());
context.assertEquals(ErrorType.USER, res.getType());
async.complete();
});
}
use of org.folio.okapi.common.OkapiClient in project okapi by folio-org.
the class HeaderModuleTest method test2.
private void test2(TestContext context, Async async) {
HashMap<String, String> headers = new HashMap<>();
headers.put("X-my-header", "hello");
OkapiClient cli = new OkapiClient(URL, vertx, headers);
cli.get("/testb", res -> {
cli.close();
context.assertTrue(res.succeeded());
context.assertEquals("hello,foo", cli.getRespHeaders().get("X-my-header"));
test3(context, async);
});
}
use of org.folio.okapi.common.OkapiClient in project okapi by folio-org.
the class HeaderModuleTest method test3.
public void test3(TestContext context, Async async) {
HashMap<String, String> headers = new HashMap<>();
OkapiClient cli = new OkapiClient(URL, vertx, headers);
cli.post("/_/tenantPermissions", "a, b,\nc", res -> {
cli.close();
context.assertTrue(res.succeeded());
context.assertEquals("a, b, c", cli.getRespHeaders().get("X-Tenant-Perms-Result"));
async.complete();
});
}
Aggregations