Skip to content

Commit

Permalink
update6test[UserService]: add test to check return of correct user
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrik Marjoni committed Mar 19, 2026
1 parent 28eb0a1 commit c650c5c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/java/edu/group5/app/model/user/UserServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ void loginValidPassword() {
assertTrue(result.verifyPassword(plainPassword.toCharArray()));
}

@Test
void loginReturnsCorrectUser() {
String password = "1234";
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();

User user = new Customer(
99, "Alice", "Smith", "alice@test.com",
encoder.encode(password)
);

repo.addContent(user);

User result = service.login("alice@test.com", password.toCharArray());

assertNotNull(result);
assertEquals(99, result.getUserId());
assertEquals("Alice", result.getFirstName());
}

@Test
void loginInvalidPassword() {
String plainPassword = "password123";
Expand Down

0 comments on commit c650c5c

Please sign in to comment.