@@ -15,14 +15,74 @@ class JadxStringDecoderPluginTest {
1515
1616 @ Test
1717 public void integrationTest () throws Exception {
18+ String code = decompileSmali ("b64/hello.smali" );
19+ System .out .println (code );
20+ assertThat (code ).contains ("b64: Hello, World!" );
21+ }
22+
23+ @ Test
24+ public void notB64Test () throws Exception {
25+ // "Hello, World!" contains non-Base64 chars — no comment expected
26+ String code = decompileSmali ("b64/not_b64.smali" );
27+ System .out .println (code );
28+ assertThat (code ).doesNotContain ("b64:" );
29+ }
30+
31+ @ Test
32+ public void looksLikeB64Test () throws Exception {
33+ // "AQIDBAUG" matches the Base64 charset but decodes to binary [1,2,3,4,5,6] — not printable UTF-8, no comment expected
34+ String code = decompileSmali ("b64/looks_like_b64.smali" );
35+ System .out .println (code );
36+ assertThat (code ).doesNotContain ("b64:" );
37+ }
38+
39+ @ Test
40+ public void b64DecodableNotEncodedTest () throws Exception {
41+ // "aGVsbG8=" is not intentionally Base64-encoded but decodes to "hello" — plugin adds a comment (known false positive)
42+ String code = decompileSmali ("b64/b64_decodable.smali" );
43+ System .out .println (code );
44+ assertThat (code ).contains ("b64: hello" );
45+ }
46+
47+ @ Test
48+ public void fieldB64Test () throws Exception {
49+ // Base64 string assigned to a static field in <clinit>
50+ String code = decompileSmali ("b64/field_b64.smali" );
51+ System .out .println (code );
52+ assertThat (code ).contains ("b64: Hello, World!" );
53+ }
54+
55+ @ Test
56+ public void varAssignB64Test () throws Exception {
57+ // Base64 string used twice — may be kept as an explicit local variable in decompiled output
58+ String code = decompileSmali ("b64/var_assign_b64.smali" );
59+ System .out .println (code );
60+ assertThat (code ).contains ("b64: Hello, World!" );
61+ }
62+
63+ @ Test
64+ public void longDecodedStringTest () throws Exception {
65+ // Decoded string is 650 'A' chars — truncated to 100 chars + "..." in the comment
66+ String code = decompileSmali ("b64/long_b64.smali" );
67+ System .out .println (code );
68+ assertThat (code ).contains ("b64: " + "A" .repeat (100 ) + "..." );
69+ }
70+
71+ @ Test
72+ public void multilineDecodedStringTest () throws Exception {
73+ // Decoded string contains newlines — they should be escaped as \n in the comment
74+ String code = decompileSmali ("b64/multiline_b64.smali" );
75+ System .out .println (code );
76+ assertThat (code ).contains ("b64: Line 1\\ nLine 2\\ nLine 3" );
77+ }
78+
79+ private String decompileSmali (String fileName ) throws Exception {
1880 JadxArgs args = new JadxArgs ();
19- args .getInputFiles ().add (getSampleFile ("hello.smali" ));
81+ args .getInputFiles ().add (getSampleFile (fileName ));
2082 try (JadxDecompiler jadx = new JadxDecompiler (args )) {
2183 jadx .load ();
2284 JavaClass cls = jadx .getClasses ().get (0 );
23- String clsCode = cls .getCode ();
24- System .out .println (clsCode );
25- assertThat (clsCode ).contains ("b64: Hello, World!" );
85+ return cls .getCode ();
2686 }
2787 }
2888
0 commit comments