From c7f37b0854e21e593aad5b243412cb5889b52b15 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Mon, 18 Mar 2024 15:55:38 +0100 Subject: [PATCH] Fix le truc de max et ajoute le test du delete --- .../Clyde/Repositories/FileRepository.java | 2 -- .../Clyde/Endpoints/UserControllerTest.java | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/FileRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/FileRepository.java index 4ba7d0b..e31e04d 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/FileRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/FileRepository.java @@ -11,6 +11,4 @@ import java.util.ArrayList; public interface FileRepository extends CrudRepository { public StorageFile getStorageFileByName(String name); - @Query("select s from StorageFile s") - public ArrayList findAll(); } diff --git a/backend/src/test/java/ovh/herisson/Clyde/Endpoints/UserControllerTest.java b/backend/src/test/java/ovh/herisson/Clyde/Endpoints/UserControllerTest.java index e0b6736..8349a74 100644 --- a/backend/src/test/java/ovh/herisson/Clyde/Endpoints/UserControllerTest.java +++ b/backend/src/test/java/ovh/herisson/Clyde/Endpoints/UserControllerTest.java @@ -132,4 +132,18 @@ public class UserControllerTest { //Teste que la donnée a bien été altérée with().header("Authorization", t.getToken()).when().request("GET", "/user").then().body("firstName",equalTo("test")); } + + @Test + public void UserDeleteTest(){ + User god = new User("god","god","admin@admin.com","everywhere","every",new Date(0), null, Role.Admin,"goddoesntneedpassword"); + Token godToken = new Token(god, tokenService.generateNewToken(), new Date()); + userRepository.save(god); + tokenService.saveToken(godToken); + + User herobrine = new User("brine","hero","herobrine@admin.com","in your WalLs","ShadowsLand",new Date(0), null,Role.Student,"test"); + userRepository.save(herobrine); + + with().header("Authorization", godToken.getToken()).pathParam("id", herobrine.getRegNo()).when().request("DELETE", "/user/{id}").then().statusCode(200); + Assert.assertEquals(userRepository.existsById(herobrine.getRegNo()), false); + } }