Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Commit 7686b2a

Browse files
Make tests test static text
1 parent a1ed8a0 commit 7686b2a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/test/java/com/cascadebot/shared/HmacTests.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88
import static org.junit.jupiter.api.Assertions.*;
99

1010
class HmacTests {
11+
12+
// Used https://www.freeformatter.com/hmac-generator.html to generate HMacs
13+
1114
@Test
1215
void hmacValidateTest() {
1316
try {
14-
Auth auth = new Auth("key1234"); //Not out actual key
15-
String hmacText = auth.hmacEncrypt("Test");
16-
assertTrue(auth.verifyEncrypt("Test", hmacText));
17-
assertFalse(auth.verifyEncrypt("Test2", hmacText));
17+
Auth auth = new Auth("key1234");
18+
19+
String hmacText = auth.hmacEncrypt("Test", 1L);
20+
assertEquals(hmacText, "e60313610635674f2961c017ce6aae1aaa48e291061788addcac7b5ed428cc3ba6c5907b10a64d4a115a12a1ed168cb5eb68ee42b512e5c40b7fb1fb49a9a0a1");
21+
22+
hmacText = auth.hmacEncrypt("Test", Long.MAX_VALUE);
23+
assertEquals(hmacText, "3341b6ada4be6744d3fb7658ddc229050dee320ec04dd546708a82f3e34679a3f2da10fc3644316d2807296668c45fd81881bb00d32453f30b07b2c515c1629f");
24+
25+
assertTrue(auth.verifyEncrypt("Test", "e60313610635674f2961c017ce6aae1aaa48e291061788addcac7b5ed428cc3ba6c5907b10a64d4a115a12a1ed168cb5eb68ee42b512e5c40b7fb1fb49a9a0a1", 1L));
1826
} catch (NoSuchAlgorithmException | InvalidKeyException ignored) {
1927
}
2028
}

0 commit comments

Comments
 (0)