forked from ramseygc/AssignmentRepoDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthentication.java
More file actions
40 lines (32 loc) · 1.01 KB
/
Authentication.java
File metadata and controls
40 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
public class Authentication {
private UserService userService;
@Before
public void setup() {
userService = new UserService();
userService.register("alice", "Secret123");
}
@Test
public void testSuccessfulAuthentication() {
assertTrue(userService.authenticate("alice", "Secret123"));
}
@Test
public void testAuthenticationWithInvalidUsername() {
assertFalse(userService.authenticate("bob", "Secret123"));
}
@Test
public void testAuthenticationWithWrongPassword() {
assertFalse(userService.authenticate("alice", "WrongPass"));
}
@Test
public void testAuthenticationWithEmptyFields() {
assertFalse(userService.authenticate("", ""));
}
@Test
public void testAuthenticationAfterRegistration() {
userService.register("newuser", "NewPass456");
assertTrue(userService.authenticate("newuser", "NewPass456"));
}
}