-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokensTest.java
More file actions
36 lines (29 loc) · 1.02 KB
/
Copy pathTokensTest.java
File metadata and controls
36 lines (29 loc) · 1.02 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
package com.marketdata.sdk;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
class TokensTest {
@Test
void redactsLongTokenKeepingLastFourChars() {
String redacted = Tokens.redact("0123456789abcdefghijklmnopqrstuvwxyzYKT0");
assertThat(redacted).endsWith("YKT0");
assertThat(redacted).matches("\\*+YKT0");
assertThat(redacted).hasSize(40);
}
@Test
void padsShortTokensToMinimumMaskLength() {
// 10-char token: 4 visible, 6 hidden — but mask floor is 32.
String redacted = Tokens.redact("ABCDEF1234");
assertThat(redacted).endsWith("1234");
assertThat(redacted).hasSize(36); // 32 asterisks + 4 visible
}
@Test
void tokenShorterThanFourCharsIsFullyMasked() {
assertThat(Tokens.redact("abc")).isEqualTo("***");
}
@Test
void blankOrNullTokenRendersAsNone() {
assertThat(Tokens.redact(null)).isEqualTo("(none)");
assertThat(Tokens.redact("")).isEqualTo("(none)");
assertThat(Tokens.redact(" ")).isEqualTo("(none)");
}
}