Compare commits

..

No commits in common. "1ed61c8c7ba4d5fca6abfe05f2a0bd3d4994c394" and "672fcd099f53e088a98334b0b05dbfece5b46218" have entirely different histories.

3 changed files with 5 additions and 8 deletions

View File

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

View File

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

View File

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