Fix le truc de max et ajoute le test du delete
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m44s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 24s

This commit is contained in:
LeoMoulin 2024-03-18 15:55:38 +01:00
parent 9744bd973f
commit c7f37b0854
2 changed files with 14 additions and 2 deletions

View File

@ -11,6 +11,4 @@ import java.util.ArrayList;
public interface FileRepository extends CrudRepository<StorageFile,Long> { public interface FileRepository extends CrudRepository<StorageFile,Long> {
public StorageFile getStorageFileByName(String name); public StorageFile getStorageFileByName(String name);
@Query("select s from StorageFile s")
public ArrayList<StorageFile> findAll();
} }

View File

@ -132,4 +132,18 @@ public class UserControllerTest {
//Teste que la donnée a bien été altérée //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")); 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);
}
} }