Repository navigation
Expand file tree
/
Copy pathEncoderConstantsTest.java
More file actions
54 lines (46 loc) · 2.11 KB
/
Copy pathEncoderConstantsTest.java
File metadata and controls
54 lines (46 loc) · 2.11 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
48
49
50
51
52
53
54
/**
* OWASP Enterprise Security API (ESAPI)
*
* This file is part of the Open Web Application Security Project (OWASP)
* Enterprise Security API (ESAPI) project. For details, please see
* <a href="http://www.owasp.org/index.php/ESAPI">http://www.owasp.org/index.php/ESAPI</a>.
*
* Copyright (c) 2026 - The OWASP Foundation
*
* The ESAPI is published by OWASP under the BSD license. You should read and accept the
* LICENSE before you use, modify, and/or redistribute this software.
*/
package org.owasp.esapi;
import static org.junit.Assert.assertEquals;
import java.util.Set;
import org.junit.Test;
import org.owasp.esapi.util.CollectionsUtil;
/**
* Each {@code Set<Character>} in {@link EncoderConstants} should hold exactly
* the characters of its matching {@code CHAR_*} array.
*/
public class EncoderConstantsTest {
private static void assertSameChars(char[] expected, Set<Character> actual) {
assertEquals(CollectionsUtil.arrayToSet(expected), actual);
}
@Test
public void testLowers() {
assertSameChars(EncoderConstants.CHAR_LOWERS, EncoderConstants.LOWERS);
}
@Test
public void testPasswordLowers() {
assertSameChars(EncoderConstants.CHAR_PASSWORD_LOWERS, EncoderConstants.PASSWORD_LOWERS);
}
@Test
public void testOtherSetsMatchTheirArrays() {
assertSameChars(EncoderConstants.CHAR_PASSWORD_SPECIALS, EncoderConstants.PASSWORD_SPECIALS);
assertSameChars(EncoderConstants.CHAR_UPPERS, EncoderConstants.UPPERS);
assertSameChars(EncoderConstants.CHAR_DIGITS, EncoderConstants.DIGITS);
assertSameChars(EncoderConstants.CHAR_SPECIALS, EncoderConstants.SPECIALS);
assertSameChars(EncoderConstants.CHAR_LETTERS, EncoderConstants.LETTERS);
assertSameChars(EncoderConstants.CHAR_ALPHANUMERICS, EncoderConstants.ALPHANUMERICS);
assertSameChars(EncoderConstants.CHAR_PASSWORD_UPPERS, EncoderConstants.PASSWORD_UPPERS);
assertSameChars(EncoderConstants.CHAR_PASSWORD_DIGITS, EncoderConstants.PASSWORD_DIGITS);
assertSameChars(EncoderConstants.CHAR_PASSWORD_LETTERS, EncoderConstants.PASSWORD_LETTERS);
}
}