From f087dcc908d06c8e65edad6cb5a91a81e46ac05b Mon Sep 17 00:00:00 2001 From: Matthias Van Eyck <78146504+Matthias-VE@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:48:53 +0100 Subject: [PATCH 1/3] Update Dockerfile Dockerfile update to select the correct .jar file --- backend/app/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/Dockerfile b/backend/app/Dockerfile index 0ad25ced..65cb465b 100644 --- a/backend/app/Dockerfile +++ b/backend/app/Dockerfile @@ -9,5 +9,5 @@ EXPOSE 8080 RUN mkdir /app -COPY --from=build /home/gradle/src/build/libs/*.jar /app/spring-boot-application.jar -ENTRYPOINT ["java", "-jar","/app/spring-boot-application.jar"] \ No newline at end of file +COPY --from=build /home/gradle/src/build/libs/*T.jar /app/spring-boot-application.jar +ENTRYPOINT ["java", "-jar","/app/spring-boot-application.jar"] From bdc56739a475c80180eec396787c40c0cda93537 Mon Sep 17 00:00:00 2001 From: Arne Dierick Date: Mon, 4 Mar 2024 19:08:07 +0100 Subject: [PATCH 2/3] added tests commented out until testconfig works --- .../controllers/HttpAuthControllerTest.java | 33 ++++++++++++ .../controllers/StaticAuthControllerTest.java | 52 +++++++++++++++++++ .../com/ugent/pidgeon/model/AuthTest.java | 39 ++++++++++++++ .../com/ugent/pidgeon/model/UserTest.java | 20 +++++++ 4 files changed, 144 insertions(+) create mode 100644 backend/app/src/test/java/com/ugent/pidgeon/controllers/HttpAuthControllerTest.java create mode 100644 backend/app/src/test/java/com/ugent/pidgeon/controllers/StaticAuthControllerTest.java create mode 100644 backend/app/src/test/java/com/ugent/pidgeon/model/AuthTest.java create mode 100644 backend/app/src/test/java/com/ugent/pidgeon/model/UserTest.java diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/HttpAuthControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/HttpAuthControllerTest.java new file mode 100644 index 00000000..0b4db0f8 --- /dev/null +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/HttpAuthControllerTest.java @@ -0,0 +1,33 @@ +package com.ugent.pidgeon.controllers; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalServerPort; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +class HttpAuthControllerTest { +// +// @LocalServerPort +// private int port; +// +// @Autowired +// private TestRestTemplate restTemplate; +// +// @Test +// void indexHttpTest() throws Exception { +// assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/", +// String.class)).contains("Running..."); +// } +// +// @Test +// void pingponghttpTest() throws Exception { +// assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/ping", +// String.class)).contains("Pong"); +// } +} diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/StaticAuthControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/StaticAuthControllerTest.java new file mode 100644 index 00000000..8e2df052 --- /dev/null +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/StaticAuthControllerTest.java @@ -0,0 +1,52 @@ +package com.ugent.pidgeon.controllers; + +import com.ugent.pidgeon.model.User; +import com.ugent.pidgeon.model.Auth; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.core.authority.SimpleGrantedAuthority; + +import java.util.List; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +// Test de AuthTestController klasse direct door zijn methodes te laden +@SpringBootTest +public class StaticAuthControllerTest { +// private final List groepLijst = List.of("Groep 1"); +// +// +// private final User user = new User("Tester De Test", "Tester", "De Test", +// "test.testing@gtest.test", groepLijst, "123456"); +// private final List authLijst = List.of(new SimpleGrantedAuthority("READ_AUTHORITY")); +// private final Auth auth = new Auth(user, authLijst); +// +// @Autowired +// private AuthTestController authTestController; +// +// +// @Test +// void contextLoads() throws Exception { +// assertThat(authTestController).isNotNull(); +// } +// +// @Test +// void pingPong() throws Exception { +// assertEquals(authTestController.ping(), "Pong"); +// } +// +// @Test +// void indexTest() throws Exception { +// assertEquals(authTestController.index(), "Running..."); + } + +// Werkt voorlopig nog niet +// @Test +// void apiTest() throws Exception { +// assertEquals(authTestController.testApi(auth), user); +// assertEquals(authTestController.testApi(auth).groups, groepLijst); +// assertEquals(authTestController.testApi(auth).name, "Tester De Test"); +// } +} \ No newline at end of file diff --git a/backend/app/src/test/java/com/ugent/pidgeon/model/AuthTest.java b/backend/app/src/test/java/com/ugent/pidgeon/model/AuthTest.java new file mode 100644 index 00000000..eb54bd2c --- /dev/null +++ b/backend/app/src/test/java/com/ugent/pidgeon/model/AuthTest.java @@ -0,0 +1,39 @@ +package com.ugent.pidgeon.model; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.core.authority.SimpleGrantedAuthority; + +import java.util.List; + +@SpringBootTest +public class AuthTest { + +// private final List groeplijst = List.of("testgroep1", "testgroep2"); +// private final User testUser = new User("John Doe", "John", "Doe", "john.doe@gmail.com", groeplijst, "123456"); +// +// private final List authLijst = List.of(new SimpleGrantedAuthority("READ_AUTHORITY")); +// private final Auth auth = new Auth(testUser, authLijst); +// +// @Test +// public void nameTest(){ +// Assertions.assertEquals(auth.getName(), "John Doe"); +// } +// +// @Test +// public void emailTest(){ +// Assertions.assertEquals(auth.getEmail(), "john.doe@gmail.com"); +// } +// +// @Test +// public void oidTest(){ +// Assertions.assertEquals(auth.getCredentials(), "123456"); +// } +// +// @Test +// public void userTest(){ +// Assertions.assertEquals(auth.getUser(), testUser); +// } + +} diff --git a/backend/app/src/test/java/com/ugent/pidgeon/model/UserTest.java b/backend/app/src/test/java/com/ugent/pidgeon/model/UserTest.java new file mode 100644 index 00000000..4ded1c62 --- /dev/null +++ b/backend/app/src/test/java/com/ugent/pidgeon/model/UserTest.java @@ -0,0 +1,20 @@ +package com.ugent.pidgeon.model; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest +public class UserTest { + +// private final List groeplijst = List.of("testgroep1", "testgroep2"); +// private final User testUser = new User("John Doe", "John", "Doe", "john.doe@gmail.com", groeplijst, "123456"); +// +// @Test +// public void isNotNull(){ +// Assertions.assertNotNull(testUser); +// } + +} From 4c3cdd6b273dfb6da0dacebf4657c9b95b7bcba0 Mon Sep 17 00:00:00 2001 From: Arne Dierick Date: Mon, 4 Mar 2024 19:12:05 +0100 Subject: [PATCH 3/3] small bugfix --- .../com/ugent/pidgeon/controllers/StaticAuthControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/StaticAuthControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/StaticAuthControllerTest.java index 8e2df052..8b97d2a0 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/StaticAuthControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/StaticAuthControllerTest.java @@ -40,7 +40,7 @@ public class StaticAuthControllerTest { // @Test // void indexTest() throws Exception { // assertEquals(authTestController.index(), "Running..."); - } +// } // Werkt voorlopig nog niet // @Test