-
-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathConvertorTests.java
More file actions
598 lines (508 loc) · 22.8 KB
/
ConvertorTests.java
File metadata and controls
598 lines (508 loc) · 22.8 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
package burp;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class ConvertorTests extends BaseHackvertorTest {
@Test
void convertSpaceInTag() {
String spaceInContent = "<@base64> </@base64>";
String converted = hackvertor.convert(spaceInContent, hackvertor);
assertEquals("IA==", converted);
}
@Test
void testBase64Encoding() {
String input = "<@base64>test</@base64>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("dGVzdA==", converted);
}
@Test
void testSimpleUppercase() {
String input = "<@uppercase>hello</@uppercase>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("HELLO", converted);
}
@Test
void testSpaceInAttribute(){
String plaintext = "<@ascii2hex('')>abcd</@ascii2hex>";
assertEquals("61626364", hackvertor.convert(plaintext, hackvertor));
plaintext = "<@ascii2hex(' ')>abcd</@ascii2hex>";
assertEquals("61 62 63 64", hackvertor.convert(plaintext, hackvertor));
plaintext = "<@ascii2hex(' ')>abcd</@ascii2hex>";
assertEquals("61 62 63 64", hackvertor.convert(plaintext, hackvertor));
}
// Encode Category Tests
@Test
void testBase32Encoding() {
String input = "<@base32>Hello</@base32>";
String converted = hackvertor.convert(input, hackvertor);
assertNotNull(converted, "Conversion returned null");
if (converted.startsWith("Error:")) {
fail("Conversion failed with error: " + converted);
}
assertEquals("JBSWY3DP", converted);
}
@Test
void testBase58Encoding() {
String input = "<@base58>Hello</@base58>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("9Ajdvzr", converted);
}
@Test
void testBase64UrlEncoding() {
String input = "<@base64url>Hello World!</@base64url>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("SGVsbG8gV29ybGQh", converted);
}
@Test
void testHtmlEntities() {
String input = "<@html_entities><script>alert('XSS')</script></@html_entities>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("<script>alert('XSS')</script>", converted);
}
@Test
void testHexEncoding() {
String input = "<@hex>ABC</@hex>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("414243", converted);
}
@Test
void testHexEntities() {
String input = "<@hex_entities>ABC</@hex_entities>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("ABC", converted);
}
@Test
void testDecEntities() {
String input = "<@dec_entities>ABC</@dec_entities>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("ABC", converted);
}
@Test
void testUrlEncode() {
String input = "<@urlencode>Hello World!</@urlencode>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello+World%21", converted);
}
@Test
void testUrlEncodeAll() {
String input = "<@urlencode_all>ABC</@urlencode_all>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("%41%42%43", converted);
}
@Test
void testJsString() {
String input = "<@js_string>Hello\"World'</@js_string>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello\\\"World'", converted);
}
// Decode Category Tests
@Test
void testBase32Decoding() {
String input = "<@d_base32>JBSWY3DP</@d_base32>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello", converted);
}
@Test
void testBase58Decoding() {
String input = "<@d_base58>9Ajdvzr</@d_base58>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello", converted);
}
@Test
void testBase64Decoding() {
String input = "<@d_base64>SGVsbG8gV29ybGQ=</@d_base64>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello World", converted);
}
@Test
void testBase64UrlDecoding() {
String input = "<@d_base64url>SGVsbG8gV29ybGQh</@d_base64url>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello World!", converted);
}
@Test
void testHtmlEntitiesDecoding() {
String input = "<@d_html_entities><script></@d_html_entities>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("<script>", converted);
}
@Test
void testUrlDecoding() {
String input = "<@d_url>Hello+World%21</@d_url>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello World!", converted);
}
@Test
void testUtf7Decoding() {
// Basic text
assertEquals("Hello", hackvertor.convert("<@d_utf7>Hello</@d_utf7>", hackvertor));
// Special characters
assertEquals("£", hackvertor.convert("<@d_utf7>+AKM-</@d_utf7>", hackvertor));
assertEquals("€", hackvertor.convert("<@d_utf7>+IKw-</@d_utf7>", hackvertor));
assertEquals("Hi Mom ☺", hackvertor.convert("<@d_utf7>Hi Mom +Jjo-</@d_utf7>", hackvertor));
assertEquals("日本語", hackvertor.convert("<@d_utf7>+ZeVnLIqe-</@d_utf7>", hackvertor));
// Plus sign handling
assertEquals("1+1=2", hackvertor.convert("<@d_utf7>1+-1=2</@d_utf7>", hackvertor));
// Unicode characters
assertEquals("A≢Α", hackvertor.convert("<@d_utf7>A+ImI-+A5E-</@d_utf7>", hackvertor));
// ASCII special characters
assertEquals("!", hackvertor.convert("<@d_utf7>+ACE-</@d_utf7>", hackvertor));
assertEquals("@", hackvertor.convert("<@d_utf7>+AEA-</@d_utf7>", hackvertor));
// Test case from the original: foo bar
assertEquals("foo bar", hackvertor.convert("<@d_utf7>+AGY-+AG8-+AG8-+ACA-+AGI-+AGE-+AHI-</@d_utf7>", hackvertor));
}
@Test
void testUtf7Encoding() {
// Test with default exclusion pattern (alphanumeric and common ASCII)
// Note: backslashes need to be double-escaped in Java strings for the regex pattern
String defaultPattern = "[\\\\s\\\\t\\\\r\\'(),-./:?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789=+!]";
// Test case from user - abc<> with default pattern
// Note: <> are grouped together in encoding
String input = "<@utf7('" + defaultPattern + "')>abc<></@utf7>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("abc+ADwAPg-", converted);
// Test special characters that should be encoded (grouped)
input = "<@utf7('" + defaultPattern + "')><>&\"</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("+ADwAPgAmACI-", converted);
// Test mixed content with excluded and encoded characters
input = "<@utf7('" + defaultPattern + "')>Hello <script></@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello +ADw-script+AD4-", converted);
// Test with only alphanumeric exclusion (grouped)
String alphaNumPattern = "[A-Za-z0-9]";
input = "<@utf7('" + alphaNumPattern + "')>abc !@#</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("abc+ACAAIQBAACM-", converted);
// Test empty exclusion pattern (encode everything as group)
input = "<@utf7('')>abc</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("+AGEAYgBj-", converted);
// Test with spaces and special chars excluded
String spacesPattern = "[\\\\s]";
input = "<@utf7('" + spacesPattern + "')>a b c</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("+AGE- +AGI- +AGM-", converted);
// Test unicode characters (should always be encoded as group)
input = "<@utf7('" + defaultPattern + "')>Hello 世界</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello +ThZ1TA-", converted);
// Test HTML entities mixed with text
input = "<@utf7('" + defaultPattern + "')><div></@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("+ACY-lt+ADs-div+ACY-gt+ADs-", converted);
// Test punctuation marks (grouped)
input = "<@utf7('[A-Za-z0-9]')>Hello, World!</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello+ACwAIA-World+ACE-", converted);
// Test consecutive special characters (grouped)
input = "<@utf7('" + defaultPattern + "')><<<>>></@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("+ADwAPAA8AD4APgA+-", converted);
}
@Test
void testUtf7EncodingRoundTrip() {
// Test that encoding and then decoding produces the original text
String[] testStrings = {
"Hello World",
"<script>alert('XSS')</script>",
"Special chars: & < > \" '",
"Unicode: 日本語 émojis 😀",
"Mixed: abc<>123",
"Symbols: !@#$%^&*()",
"HTML: <div class=\"test\"> </div>"
};
String defaultPattern = "[\\\\s\\\\t\\\\r\\'(),-./:?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789=+!]";
for (String original : testStrings) {
// Encode
String encoded = hackvertor.convert("<@utf7('" + defaultPattern + "')>" + original + "</@utf7>", hackvertor);
// Decode
String decoded = hackvertor.convert("<@d_utf7>" + encoded + "</@d_utf7>", hackvertor);
assertEquals(original, decoded, "Round-trip failed for: " + original);
}
}
@Test
void testUtf7EncodingEdgeCases() {
String defaultPattern = "[\\\\s\\\\t\\\\r\\'(),-./:?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789=+!]";
// Test empty string
String input = "<@utf7('" + defaultPattern + "')></@utf7>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("", converted);
// Test single special character
input = "<@utf7('" + defaultPattern + "')><</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("+ADw-", converted);
// Test plus sign handling (plus is special in UTF-7)
input = "<@utf7('[A-Za-z0-9]')>a+b</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("a+ACs-b", converted);
// Test already UTF-7 encoded content (should pass through)
input = "<@utf7('" + defaultPattern + "')>+ADw-</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("+-ADw-", converted); // '+' becomes '+-', rest are excluded
// Test newlines and tabs
input = "<@utf7('[A-Za-z0-9]')>line1\nline2\ttab</@utf7>";
converted = hackvertor.convert(input, hackvertor);
assertEquals("line1+AAo-line2+AAk-tab", converted);
}
// Hash Category Tests
@Test
void testMd5Hash() {
String input = "<@md5>test</@md5>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("098f6bcd4621d373cade4e832627b4f6", converted);
}
@Test
void testSha1Hash() {
String input = "<@sha1>test</@sha1>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", converted);
}
@Test
void testSha256Hash() {
String input = "<@sha256>test</@sha256>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", converted);
}
@Test
void testSha512Hash() {
String input = "<@sha512>test</@sha512>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff", converted);
}
// String Category Tests
@Test
void testUppercase() {
String input = "<@uppercase>hello world</@uppercase>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("HELLO WORLD", converted);
}
@Test
void testLowercase() {
String input = "<@lowercase>HELLO WORLD</@lowercase>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("hello world", converted);
}
@Test
void testCapitalise() {
String input = "<@capitalise>hello world</@capitalise>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello world", converted);
}
@Test
void testReverse() {
String input = "<@reverse>Hello</@reverse>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("olleH", converted);
}
@Test
void testLength() {
String input = "<@length>Hello World</@length>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("11", converted);
}
@Test
void testSubstring() {
String input = "<@substring(0,5)>Hello World</@substring>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello", converted);
}
@Test
void testReplace() {
String input = "<@replace('World','Universe')>Hello World</@replace>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Hello Universe", converted);
}
@Test
void testRepeat() {
String input = "<@repeat(3)>A</@repeat>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("AAA", converted);
}
// Convert Category Tests
@Test
void testDec2Hex() {
String input = "<@dec2hex('(\\\\d+)')>255</@dec2hex>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("ff", converted);
}
@Test
void testHex2Dec() {
String input = "<@hex2dec('((?:0x)?[a-f0-9]+)')>ff</@hex2dec>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("255", converted);
}
@Test
void testDec2Bin() {
String input = "<@dec2bin('(\\\\d+)')>10</@dec2bin>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("1010", converted);
}
@Test
void testBin2Dec() {
String input = "<@bin2dec('([0-1]+)')>1010</@bin2dec>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("10", converted);
}
@Test
void testAscii2Hex() {
String input = "<@ascii2hex>ABC</@ascii2hex>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("414243", converted);
}
@Test
void testHex2Ascii() {
String input = "<@hex2ascii>414243</@hex2ascii>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("ABC", converted);
}
// Encryption/Decryption Tests
@Test
void testXorEncryption() {
String input = "<@xor('key')>Hello</@xor>";
String converted = hackvertor.convert(input, hackvertor);
// XOR is reversible, so we'll test round-trip
String decrypted = hackvertor.convert("<@xor('key')>" + converted + "</@xor>", hackvertor);
assertEquals("Hello", decrypted);
}
@Test
void testRotN() {
String input = "<@rotN(13)>Hello</@rotN>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Uryyb", converted);
}
@Test
void testAtbashEncrypt() {
String input = "<@atbash_encrypt>Hello</@atbash_encrypt>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("Svool", converted);
}
@Test
void testGzipCompress() {
String input = "Hello World! This is a test string for compression.";
String compressed = hackvertor.convert("<@gzip_compress>" + input + "</@gzip_compress>", hackvertor);
String decompressed = hackvertor.convert("<@gzip_decompress>"+compressed+"</@gzip_decompress>", hackvertor);
assertNotNull(compressed);
assertNotEquals(input, compressed);
// Compressed output should not be empty
assertFalse(compressed.isEmpty(), "Compressed output should not be empty");
assertEquals(input, decompressed);
}
// HMAC Tests
@Test
void testHmacSha256() {
String input = "<@hmac_sha256('secret')>message</@hmac_sha256>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("8b5f48702995c1598c573db1e21866a9b825d4a794d169d7060a03605796360b", converted);
}
// Math Category Tests
@Test
void testRange() {
String input = "<@range(1,5,1)></@range>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("1,2,3,4,5", converted);
}
@Test
void testArithmetic() {
String input = "<@arithmetic(10,'+',',')>10</@arithmetic>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("20", converted);
}
@Test
void testZeropad() {
String input = "<@zeropad(',',5)>42</@zeropad>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("00042", converted);
}
// Nested Tags Test
@Test
void testNestedTags() {
String input = "<@uppercase><@base64>test</@base64></@uppercase>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("DGVZDA==", converted);
}
// Multiple Same Tags Test
@Test
void testMultipleSameTags() {
String input = "<@base64>Hello</@base64> <@base64>World</@base64>";
String converted = hackvertor.convert(input, hackvertor);
assertEquals("SGVsbG8= V29ybGQ=", converted);
}
@Test
void testAutoDecodeGzipBase64() {
String encoded = hackvertor.convert("<@gzip_compress><@base64>foobar</@base64></@gzip_compress>", hackvertor);
String decoded = hackvertor.convert("<@auto_decode_no_decrypt>" + encoded + "</@auto_decode_no_decrypt>", hackvertor);
assertEquals("<@gzip_compress><@base64>foobar</@base64></@gzip_compress>", decoded);
}
@Test
void testAutoDecodeDeflateBase32() {
String encoded = hackvertor.convert("<@deflate_compress><@base32>foobar</@base32></@deflate_compress>", hackvertor);
String decoded = hackvertor.convert("<@auto_decode_no_decrypt>" + encoded + "</@auto_decode_no_decrypt>", hackvertor);
assertEquals("<@deflate_compress><@base32>foobar</@base32></@deflate_compress>", decoded);
}
@Test
void testAutoDecodeBase32ThenDeflate() {
String decoded = hackvertor.convert("<@auto_decode_no_decrypt>PCOALAFBBEAAAAGCN3KWAHPYP4MIHZQCBCVQE6Q=</@auto_decode_no_decrypt>", hackvertor);
assertEquals("<@base32><@deflate_compress>foobar</@deflate_compress></@base32>", decoded);
}
@Test
void testAutoDecodeBase32NotMisidentifiedAsBase64() {
String base32Encoded = hackvertor.convert("<@base32>test</@base32>", hackvertor);
assertEquals("ORSXG5A=", base32Encoded);
String decoded = hackvertor.convert("<@auto_decode_no_decrypt>" + base32Encoded + "</@auto_decode_no_decrypt>", hackvertor);
assertEquals("<@base32>test</@base32>", decoded);
}
@Test
void testAutoDecodeBase64() {
String base64Encoded = hackvertor.convert("<@base64>foobar</@base64>", hackvertor);
assertEquals("Zm9vYmFy", base64Encoded);
String decoded = hackvertor.convert("<@auto_decode_no_decrypt>" + base64Encoded + "</@auto_decode_no_decrypt>", hackvertor);
assertEquals("<@base64>foobar</@base64>", decoded);
}
@Test
void testDeflateCompressDecompressDynamic() {
String input = "foobar";
String compressed = hackvertor.convert("<@deflate_compress('dynamic')>" + input + "</@deflate_compress>", hackvertor);
String decompressed = hackvertor.convert("<@deflate_decompress>" + compressed + "</@deflate_decompress>", hackvertor);
assertEquals(input, decompressed);
}
@Test
void testDeflateCompressDecompressFixed() {
String input = "foobar";
String compressed = hackvertor.convert("<@deflate_compress('fixed')>" + input + "</@deflate_compress>", hackvertor);
String decompressed = hackvertor.convert("<@deflate_decompress>" + compressed + "</@deflate_decompress>", hackvertor);
assertEquals(input, decompressed);
}
@Test
void testDeflateCompressDecompressStore() {
String input = "foobar";
String compressed = hackvertor.convert("<@deflate_compress('store')>" + input + "</@deflate_compress>", hackvertor);
String decompressed = hackvertor.convert("<@deflate_decompress>" + compressed + "</@deflate_decompress>", hackvertor);
assertEquals(input, decompressed);
}
@Test
void testDeflateCompressDynamicBase32Output() {
String encoded = hackvertor.convert("<@base32><@deflate_compress('dynamic')>foobar</@deflate_compress></@base32>", hackvertor);
assertEquals("PDNEXS6PJ5FCYAQABCVQE6Q=", encoded);
}
@Test
void testDeflateCompressFixedBase32Output() {
String encoded = hackvertor.convert("<@base32><@deflate_compress('fixed')>foobar</@deflate_compress></@base32>", hackvertor);
assertEquals("PAAUXS6PJ5FCYAQABCVQE6Q=", encoded);
}
@Test
void testDeflateCompressStoreBase32Output() {
String encoded = hackvertor.convert("<@base32><@deflate_compress('store')>foobar</@deflate_compress></@base32>", hackvertor);
assertEquals("PAAQCBQA7H7WM33PMJQXECFLAJ5A====", encoded);
}
@Test
void testBase64urlGzipOutput() {
String encoded = hackvertor.convert("<@base64url><@gzip_compress>foobar</@gzip_compress></@base64url>", hackvertor);
assertTrue(encoded.matches("^[A-Za-z0-9_-]+$"), "base64url output should only contain base64url characters, got: " + encoded);
}
@Test
void testAutoDecodeBase64urlGzip() {
String encoded = hackvertor.convert("<@base64url><@gzip_compress>foobar</@gzip_compress></@base64url>", hackvertor);
String decoded = hackvertor.convert("<@auto_decode_no_decrypt>" + encoded + "</@auto_decode_no_decrypt>", hackvertor);
assertEquals("<@base64url><@gzip_compress>foobar</@gzip_compress></@base64url>", decoded);
}
}