Added check for admin user and test it
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
parent
165dee5bd2
commit
da46582fc0
@ -85,4 +85,8 @@ public class UserService {
|
||||
return this.repo.getByRefreshToken(refreshToken);
|
||||
}
|
||||
|
||||
public boolean adminExists(){
|
||||
return this.repo.getAllByRole(UserRoles.ADMIN).size() > 0;
|
||||
}
|
||||
|
||||
}
|
@ -100,4 +100,21 @@ public class UserServiceTest {
|
||||
|
||||
assertTrue(user.getName() != "Tom");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnAdminExists() {
|
||||
final String email = "shouldReturnAdminExists@UserService.test";
|
||||
this.userService.save(new User("AdminTom", "Smieszny", email, UserRoles.ADMIN));
|
||||
assertTrue(userService.adminExists());
|
||||
}
|
||||
|
||||
@Test
|
||||
/**
|
||||
* In future can fail the test due to create a admin user in the another tests.
|
||||
*/
|
||||
public void shouldReturnNotAdminExists() {
|
||||
final String email = "shouldReturnNotAdminExists@UserService.test";
|
||||
this.userService.save(new User("StudentTom", "Smieszny", email, UserRoles.STUDENT));
|
||||
assertTrue(userService.adminExists() == false);
|
||||
}
|
||||
}
|
||||
|
@ -63,4 +63,9 @@ public class ConfigController {
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseEntity<String> initAdmin(@RequestParam("ticket") String ticket){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user