use of org.folio.okapi.service.impl.DockerModuleHandle.DOCKER_REGISTRIES_EMPTY_LIST in project okapi by folio-org.
the class DockerModuleHandleTest method testGetImage.
@Test
public void testGetImage(TestContext context) {
Vertx vertx = Vertx.vertx();
Router router = Router.router(vertx);
router.routeWithRegex("/.*").handler(this::dockerMockHandle);
HttpServerOptions so = new HttpServerOptions().setHandle100ContinueAutomatically(true);
Async async1 = context.async();
HttpServer listen = vertx.createHttpServer(so).requestHandler(router).listen(MOCK_PORT, context.asyncAssertSuccess(x -> async1.complete()));
async1.await();
dockerImageMatch = "foo";
JsonObject conf = new JsonObject().put("dockerUrl", "tcp://localhost:" + MOCK_PORT);
assertThat(getImage(context, vertx, conf)).contains("not found");
assertThat(getImage(context, vertx, conf)).contains("not found");
dockerImageMatch = "folioci/mod-x";
assertThat(getImage(context, vertx, conf)).isEqualTo("succeeded");
// zero registries, pull is disabled
conf.put("dockerRegistries", new JsonArray());
assertThat(getImage(context, vertx, conf)).isEqualTo(DOCKER_REGISTRIES_EMPTY_LIST);
conf.put("dockerRegistries", new JsonArray().add(new JsonObject().put("registry", "reg1")).add(new JsonObject().put("registry", "reg2")));
assertThat(getImage(context, vertx, conf)).contains("not found");
dockerImageMatch = "reg1/folioci/mod-x";
assertThat(getImage(context, vertx, conf)).isEqualTo("succeeded");
dockerImageMatch = "reg2/folioci/mod-x";
assertThat(getImage(context, vertx, conf)).isEqualTo("succeeded");
dockerImageMatch = "reg3/folioci/mod-x";
assertThat(getImage(context, vertx, conf)).contains("not found");
dockerImageMatch = null;
listen.close(context.asyncAssertSuccess());
}
use of org.folio.okapi.service.impl.DockerModuleHandle.DOCKER_REGISTRIES_EMPTY_LIST in project okapi by folio-org.
the class DockerModuleHandleTest method testDockerPull.
@Test
public void testDockerPull(TestContext context) {
Vertx vertx = Vertx.vertx();
Router router = Router.router(vertx);
router.routeWithRegex("/.*").handler(this::dockerMockHandle);
HttpServerOptions so = new HttpServerOptions().setHandle100ContinueAutomatically(true);
Async async1 = context.async();
HttpServer listen = vertx.createHttpServer(so).requestHandler(router).listen(MOCK_PORT, context.asyncAssertSuccess(x -> async1.complete()));
async1.await();
dockerPullJson = new JsonObject().put("message", "some message");
dockerPullStatus = 200;
JsonObject conf = new JsonObject().put("dockerUrl", "tcp://localhost:" + MOCK_PORT);
assertThat(pullImage(context, vertx, conf)).isEqualTo("succeeded");
// zero registries, pull is disabled
conf.put("dockerRegistries", new JsonArray());
assertThat(pullImage(context, vertx, conf)).isEqualTo(DOCKER_REGISTRIES_EMPTY_LIST);
conf.put("dockerRegistries", new JsonArray().add(new JsonObject()));
assertThat(pullImage(context, vertx, conf)).isEqualTo("succeeded");
conf.put("dockerRegistries", new JsonArray().addNull().add(new JsonObject().put("username", "x").put("password", "y")));
assertThat(pullImage(context, vertx, conf)).contains("unauthorized");
conf.put("dockerRegistries", new JsonArray().add(new JsonObject().put("username", "x").put("password", "y")).add(new JsonObject().put("username", "x").put("password", "x")).add(new JsonObject().put("username", "x").put("password", "z")));
assertThat(pullImage(context, vertx, conf)).isEqualTo("succeeded");
context.assertEquals("folioci/mod-x", lastFromImage);
conf.put("dockerRegistries", new JsonArray().add(new JsonObject().put("registry", "localhost:5000")));
assertThat(pullImage(context, vertx, conf)).isEqualTo("succeeded");
context.assertEquals("localhost:5000/folioci/mod-x", lastFromImage);
conf.put("dockerRegistries", new JsonArray().add(new JsonObject().put("registry", "localhost:5000/")));
assertThat(pullImage(context, vertx, conf)).isEqualTo("succeeded");
context.assertEquals("localhost:5000/folioci/mod-x", lastFromImage);
listen.close(context.asyncAssertSuccess());
}
Aggregations