forked from FRC-7525/Java-Basics-Training-Assignment-2025
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordCheckerTest.java
More file actions
47 lines (39 loc) · 1.41 KB
/
PasswordCheckerTest.java
File metadata and controls
47 lines (39 loc) · 1.41 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
41
42
43
44
45
46
47
package challenges;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class PasswordCheckerTest {
@Test
public void testWeakPasswordShort() {
assertEquals("Weak", PasswordChecker.checkPasswordStrength("abc"));
}
@Test
public void testWeakPasswordMissingTypes() {
// Only lowercase, length >= 8
assertEquals("Weak", PasswordChecker.checkPasswordStrength("abcdefgh"));
// Only digits, length >= 8
assertEquals("Weak", PasswordChecker.checkPasswordStrength("12345678"));
}
@Test
public void testModeratePassword() {
// Missing symbol
assertEquals("Moderate", PasswordChecker.checkPasswordStrength("Abcdefg1"));
// Missing digit
assertEquals("Moderate", PasswordChecker.checkPasswordStrength("Abcdefg!"));
// Missing uppercase
assertEquals("Moderate", PasswordChecker.checkPasswordStrength("abcdef1!"));
// Missing lowercase
assertEquals("Moderate", PasswordChecker.checkPasswordStrength("ABCDEF1!"));
}
@Test
public void testStrongPassword() {
assertEquals("Strong", PasswordChecker.checkPasswordStrength("Abcdef1!"));
assertEquals("Strong", PasswordChecker.checkPasswordStrength("A1b2c3d4!"));
}
@Test
public void testEdgeCases() {
// Exactly 8 chars, all types
assertEquals("Strong", PasswordChecker.checkPasswordStrength("A1b2c3!d"));
// 8 chars, missing 2 types
assertEquals("Weak", PasswordChecker.checkPasswordStrength("Abcdefgh"));
}
}