Compare commits
3 Commits
672fcd099f
...
1ed61c8c7b
Author | SHA1 | Date | |
---|---|---|---|
1ed61c8c7b | |||
59c82d7482 | |||
772fa09e28 |
@ -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.getFirst());
|
tokenRepo.delete(tokenList.get(0));
|
||||||
tokenList.remove(tokenList.getFirst());
|
tokenList.remove(tokenList.get(0));
|
||||||
}
|
}
|
||||||
tokenRepo.save(token);
|
tokenRepo.save(token);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ 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;
|
||||||
@ -46,7 +47,8 @@ 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
|
||||||
@ -72,6 +74,7 @@ public class UserControllerTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setup(){
|
void setup(){
|
||||||
RestAssured.baseURI = "http://localhost:" + port;
|
RestAssured.baseURI = "http://localhost:" + port;
|
||||||
|
userRepository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
@ -84,7 +87,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());
|
||||||
userRepository.save(god);
|
userService.save(god);
|
||||||
tokenService.saveToken(godToken);
|
tokenService.saveToken(godToken);
|
||||||
|
|
||||||
//Can god post herobrine himself ?
|
//Can god post herobrine himself ?
|
||||||
|
@ -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", null, null, null, "secret");
|
User malveillant = new User("Cargo", "John", "CargoJ@mail.com", "secret", "secret", new Date(), null, "secret", null);
|
||||||
userRepository.save(malveillant);
|
userRepository.save(malveillant);
|
||||||
|
|
||||||
for (int i = 0; i < 20; i++){
|
for (int i = 0; i < 20; i++){
|
||||||
|
Loading…
Reference in New Issue
Block a user