Compare commits

...

3 Commits

Author SHA1 Message Date
1ed61c8c7b Merge pull request 'Fixing tests and tokenService' (#184) from f into master
Some checks failed
Build and test backend / Build-backend (push) Successful in 1m25s
deploy to production / deploy-frontend (push) Successful in 34s
deploy to production / deploy-backend (push) Failing after 44s
Build and test FrontEnd / Build-frontend (push) Successful in 31s
Reviewed-on: #184
2024-04-22 20:44:53 +02:00
59c82d7482 Merge branch 'master' into f
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m22s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 32s
2024-04-22 20:37:59 +02:00
772fa09e28 Fixing tests and tokenService
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 1m25s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 31s
2024-04-22 20:35:30 +02:00
3 changed files with 8 additions and 5 deletions

View File

@ -51,8 +51,8 @@ public class TokenService {
ArrayList<Token> tokenList = tokenRepo.getByUserOrderByExpirationDate(token.getUser());
while(tokenList.size() >= 5){
tokenRepo.delete(tokenList.getFirst());
tokenList.remove(tokenList.getFirst());
tokenRepo.delete(tokenList.get(0));
tokenList.remove(tokenList.get(0));
}
tokenRepo.save(token);
}

View File

@ -23,6 +23,7 @@ import ovh.herisson.Clyde.Repositories.TokenRepository;
import ovh.herisson.Clyde.Repositories.UserRepository;
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
import ovh.herisson.Clyde.Services.TokenService;
import ovh.herisson.Clyde.Services.UserService;
import ovh.herisson.Clyde.Tables.Role;
import ovh.herisson.Clyde.Tables.Token;
import ovh.herisson.Clyde.Tables.User;
@ -46,7 +47,8 @@ public class UserControllerTest {
@Autowired
private TokenService tokenService;
@Autowired
private UserService userService;
@Autowired
private UserRepository userRepository;
@Autowired
@ -72,6 +74,7 @@ public class UserControllerTest {
@BeforeEach
void setup(){
RestAssured.baseURI = "http://localhost:" + port;
userRepository.deleteAll();
}
@AfterEach
@ -84,7 +87,7 @@ public class UserControllerTest {
public void userPostTest(){
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);
userService.save(god);
tokenService.saveToken(godToken);
//Can god post herobrine himself ?

View File

@ -70,7 +70,7 @@ class TokenServiceTest {
ArrayList<Token> tokenList = new ArrayList<>();
GregorianCalendar gc = new GregorianCalendar();
User malveillant = new User("Cargo", "John", "CargoJ@mail.com", "secret", "secret", null, null, null, "secret");
User malveillant = new User("Cargo", "John", "CargoJ@mail.com", "secret", "secret", new Date(), null, "secret", null);
userRepository.save(malveillant);
for (int i = 0; i < 20; i++){