diff --git a/pom.xml b/pom.xml index b652d06..02d5a31 100644 --- a/pom.xml +++ b/pom.xml @@ -12,26 +12,43 @@ 11 11 - 5.1.0-rc.1 + 5.1.0 https://raw.githubusercontent.com/nuts-foundation/nuts-node/v${nuts.version}/docs/_static ${project.build.outputDirectory}/spec - ${project.basedir}/generated + ${project.basedir}/ 1.0-SNAPSHOT - - nl.reinkrul.nuts - java-client - 1.0-SNAPSHOT - org.junit.jupiter junit-jupiter-engine 5.9.1 test + + + + javax.annotation + javax.annotation-api + 1.3.2 + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + io.swagger + swagger-annotations + 1.6.9 + + + com.google.code.gson + gson + 2.10.1 + @@ -41,7 +58,7 @@ - generated + src/generated @@ -103,12 +120,18 @@ 6.2.1 java + true + false + false + false + false - src/main/java + src/generated/java nl.reinkrul.nuts java-client - https://github.com/reinkrul/java-nuts-client.git + https://github.com/reinkrul/java-nuts-client.git + https://github.com/reinkrul/java-nuts-client.git https://github.com/reinkrul/java-nuts-client @@ -252,26 +275,23 @@ - com.google.code.maven-replacer-plugin - replacer - 1.5.3 + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + add-source generate-sources - replace + add-source + + + src/generated/java + + - - generated/pom.xml - - - https://github.com/openapitools/openapi-generator - https://github.com/reinkrul/java-nuts-client - - - maven-compiler-plugin diff --git a/src/test/java/nl/reinkrul/nuts/ApiClientTest.java b/src/test/java/nl/reinkrul/nuts/ApiClientTest.java deleted file mode 100644 index e2ec634..0000000 --- a/src/test/java/nl/reinkrul/nuts/ApiClientTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package nl.reinkrul.nuts; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpServer; -import nl.reinkrul.nuts.common.DIDDocument; -import nl.reinkrul.nuts.vdr.DIDCreateRequest; -import nl.reinkrul.nuts.vdr.DidApi; -import org.junit.jupiter.api.*; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.ServerSocket; - -public class ApiClientTest { - - private static final String PATH = "/internal/vdr/v1/did"; - private static final String BEARER_TOKEN = "some-token"; - private static HttpServer server; - - @BeforeAll - static void startServer() throws IOException { - server = HttpServer.create(new InetSocketAddress("localhost", freePort()), 0); - server.start(); - } - - @AfterAll - static void stopServer() { - server.stop(5); - } - - @AfterEach - void unregisterContext() { - server.removeContext(PATH); - } - - @Test - public void noAuthTest() throws ApiException { - server.createContext(PATH, ApiClientTest::sendOKResponse); - - ApiClient apiClient = new ApiClient(); - apiClient.setBasePath("http://" + server.getAddress().toString()); - - var didApi = new DidApi(apiClient); - didApi.createDID(new DIDCreateRequest()); - } - - @Test - public void bearerAuthTest() throws ApiException { - server.createContext(PATH, exchange -> { - var header = exchange.getRequestHeaders().get("Authorization").get(0); - if (header.equals("Bearer " + BEARER_TOKEN)) { - sendOKResponse(exchange); - } else { - // Fails test - exchange.sendResponseHeaders(401, 0); - exchange.close(); - } - }); - - ApiClient apiClient = new ApiClient(); - apiClient.setBearerToken(BEARER_TOKEN); - apiClient.setBasePath("http://" + server.getAddress().toString()); - - var didApi = new DidApi(apiClient); - didApi.createDID(new DIDCreateRequest()); - } - - private static void sendOKResponse(HttpExchange exchange) throws IOException { - exchange.sendResponseHeaders(200, 0); - exchange.getResponseHeaders().add("Content-Type", "application/json"); - exchange.getResponseBody().write(new ObjectMapper().writeValueAsBytes(new DIDDocument())); - exchange.close(); - } - - private static int freePort() { - try (ServerSocket s = new ServerSocket(0)) { - return s.getLocalPort(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -}