From 7b53f485211eb60415184b710676685b7f5cebe2 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 28 Dec 2022 19:16:13 +0100 Subject: [PATCH] remove class useless --- src/main/java/com/covas/Json/Hello.java | 17 ------ .../com/covas/Resources/GreetingResource.java | 4 +- .../com/covas/Resources/HelloRessource.java | 56 ------------------- src/main/resources/publicKey.pem | 2 +- .../java/com/covas/GreetingResourceTest.java | 4 +- 5 files changed, 5 insertions(+), 78 deletions(-) delete mode 100644 src/main/java/com/covas/Json/Hello.java delete mode 100644 src/main/java/com/covas/Resources/HelloRessource.java diff --git a/src/main/java/com/covas/Json/Hello.java b/src/main/java/com/covas/Json/Hello.java deleted file mode 100644 index 6a5a749..0000000 --- a/src/main/java/com/covas/Json/Hello.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.covas.Json; - -import io.quarkus.runtime.annotations.RegisterForReflection; - -@RegisterForReflection -public class Hello { - - public String msg; - - public Hello(){ - this.msg = "Hello World"; - } - - public Hello(String msg){ - this.msg = msg; - } -} diff --git a/src/main/java/com/covas/Resources/GreetingResource.java b/src/main/java/com/covas/Resources/GreetingResource.java index 312ddc1..719ee0d 100644 --- a/src/main/java/com/covas/Resources/GreetingResource.java +++ b/src/main/java/com/covas/Resources/GreetingResource.java @@ -7,12 +7,12 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -@Path("/hello") +@Path("/healthcheck") public class GreetingResource { @GET @Produces(MediaType.TEXT_PLAIN) public String hello() { - return "Hello RESTEasy"; + return "OK"; } } \ No newline at end of file diff --git a/src/main/java/com/covas/Resources/HelloRessource.java b/src/main/java/com/covas/Resources/HelloRessource.java deleted file mode 100644 index fe4bc5d..0000000 --- a/src/main/java/com/covas/Resources/HelloRessource.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.covas.Resources; - -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import com.covas.Json.Hello; - -import org.eclipse.microprofile.jwt.JsonWebToken; - -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@Path("/json") -public class HelloRessource { - @Inject - JsonWebToken jwt; - - Set hello = Collections.synchronizedSet(new LinkedHashSet<>()); - - public HelloRessource(){ - hello.add(new Hello("toto")); - } - - @GET - @PermitAll - @Produces(MediaType.APPLICATION_JSON) - public Response hello_json(){ - return Response.ok(this.hello).build(); - } - - @GET - @Path("/user") - @RolesAllowed({"User"}) - @Produces(MediaType.APPLICATION_JSON) - public Response hello_user(){ - return Response.ok(new Hello(String.format("Hello %s", jwt.getName()))).build(); - } - - @GET - @Path("/admin") - @RolesAllowed({"Admin"}) - @Produces(MediaType.APPLICATION_JSON) - public Response hello_admin(){ - return Response.ok(new Hello(String.format("Hello admin %s", jwt.getName()))).build(); - } -} diff --git a/src/main/resources/publicKey.pem b/src/main/resources/publicKey.pem index 8c159c7..5f5ef51 100644 --- a/src/main/resources/publicKey.pem +++ b/src/main/resources/publicKey.pem @@ -1,7 +1,7 @@ -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6Y7YVAFp8+ZenWOVE41v M18eCBsFNASthze6D3mbNS0wOlA2x0LTSt6wZSP8nMRXJmxlptL+X6JWp60aApKW -Y275XXcgE3NablV5/L7SlAbl3yTUC9vK4ksyKd4n35ShFZMLQr8nix01jV0wEygK +Y275XqXcgE3NablV5/L7SlAbl3yTUC9vK4ksyKd4n35ShFZMLQr8nix01jV0wEygK 5kIVhAcEKM8KiEzISsR3AXyiTgb9x8HdEvHpZxy8kc81XetLpQwLVdBpb9PQd/49 Q1fuTUFPYgauyPfe0V+LlXpJJN745P+9XoKOVoUYTEwelk2d88kgp3ZFGOjTcoD3 C9YtAlSrPJy6YK3k2MXjm2P8lw+0pSUBzNIzttFDbejt9dwc2oyPxP29LFIlxGiV diff --git a/src/test/java/com/covas/GreetingResourceTest.java b/src/test/java/com/covas/GreetingResourceTest.java index 6ee0982..d8cc1d8 100644 --- a/src/test/java/com/covas/GreetingResourceTest.java +++ b/src/test/java/com/covas/GreetingResourceTest.java @@ -12,10 +12,10 @@ public class GreetingResourceTest { @Test public void testHelloEndpoint() { given() - .when().get("/api/hello") + .when().get("/api/healthcheck") .then() .statusCode(200) - .body(is("Hello RESTEasy")); + .body(is("OK")); } } \ No newline at end of file