diff --git a/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/LoaderIT.java b/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/LoaderIT.java index 20c50a1..9454902 100644 --- a/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/LoaderIT.java +++ b/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/LoaderIT.java @@ -32,6 +32,7 @@ import static org.fcrepo.apix.model.Ontologies.Service.PROP_IS_SERVICE_INSTANCE_OF; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.ops4j.pax.exam.CoreOptions.maven; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; @@ -42,6 +43,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -95,6 +97,8 @@ public class LoaderIT extends ServiceBasedTest { final AtomicReference serviceResponse = new AtomicReference<>(); + final AtomicBoolean auth = new AtomicBoolean(false); + @Rule public TestName name = new TestName(); @@ -149,6 +153,7 @@ public void setUp() { ex.setOut(ex.getIn()); if ("OPTIONS".equals(ex.getIn().getHeader(Exchange.HTTP_METHOD))) { ex.getOut().setBody(optionsResponse.get()); + auth.set(ex.getIn().getHeader("Authorization") != null); } else if ("GET".equals(ex.getIn().getHeader(Exchange.HTTP_METHOD))) { ex.getOut().setBody(serviceResponse.get()); } else { @@ -157,6 +162,22 @@ public void setUp() { }); } + @Test + public void authTest() throws Exception { + + final String SERVICE_CANONICAL = "test:" + name.getMethodName(); + final String EXPOSED_AT = SERVICE_CANONICAL; + + optionsResponse.set(triple("", RDF_TYPE, CLASS_EXTENSION) + + ltriple("", PROP_EXPOSES_SERVICE_AT, EXPOSED_AT) + + triple("", PROP_EXPOSES_SERVICE, SERVICE_CANONICAL)); + + attempt(60, () -> textPost(LOADER_URI, serviceEndpoint)).getHeaderValue("Location"); + + assertTrue(auth.get()); + + } + @Test public void htmlMinimalTest() throws Exception { diff --git a/fcrepo-api-x-integration/src/test/resources/cfg/org.fcrepo.apix.test.cfg b/fcrepo-api-x-integration/src/test/resources/cfg/org.fcrepo.apix.test.cfg index a75cf04..b453ce2 100644 --- a/fcrepo-api-x-integration/src/test/resources/cfg/org.fcrepo.apix.test.cfg +++ b/fcrepo-api-x-integration/src/test/resources/cfg/org.fcrepo.apix.test.cfg @@ -1,4 +1,6 @@ auth.http.${fcrepo.dynamic.test.port}.localhost.username = fedoraAdmin auth.http.${fcrepo.dynamic.test.port}.localhost.password = secret3 auth.http.${apix.dynamic.test.port}.localhost.username = fedoraAdmin -auth.http.${apix.dynamic.test.port}.localhost.password = secret3 \ No newline at end of file +auth.http.${apix.dynamic.test.port}.localhost.password = secret3 +auth.http.${services.dynamic.test.port}.127.0.0.1.username = fedoraAdmin +auth.http.${services.dynamic.test.port}.127.0.0.1.password = secret3 \ No newline at end of file diff --git a/fcrepo-api-x-loader/src/main/java/org/fcrepo/apix/loader/impl/LoaderRoutes.java b/fcrepo-api-x-loader/src/main/java/org/fcrepo/apix/loader/impl/LoaderRoutes.java index 39ee130..bf29b75 100644 --- a/fcrepo-api-x-loader/src/main/java/org/fcrepo/apix/loader/impl/LoaderRoutes.java +++ b/fcrepo-api-x-loader/src/main/java/org/fcrepo/apix/loader/impl/LoaderRoutes.java @@ -125,7 +125,7 @@ public void configure() throws Exception { .setHeader(Exchange.HTTP_URI, header(HEADER_SERVICE_URI)) .setHeader("Accept", constant("text/turtle")) .process(e -> LOG.info("Execution OPTIONS to service URI {}", e.getIn().getHeader(Exchange.HTTP_URI))) - .to("jetty:http://localhost") + .to("http://localhost?httpClient=#httpClient") .process(DEPOSIT_OBJECTS) .setHeader(HTTP_RESPONSE_CODE, constant(303)); diff --git a/fcrepo-api-x-loader/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/fcrepo-api-x-loader/src/main/resources/OSGI-INF/blueprint/blueprint.xml index dc8f4d0..af388f1 100644 --- a/fcrepo-api-x-loader/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ b/fcrepo-api-x-loader/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -22,6 +22,15 @@ + + + + + + + @@ -31,7 +40,8 @@ - +