Fixing tests and tokenService #184
@ -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);
|
||||
}
|
||||
|
@ -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 ?
|
||||
|
@ -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++){
|
||||
|
Loading…
Reference in New Issue
Block a user