From 2bc593e990e2915d63503df8d4be72d10fa77e9d Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 3 Sep 2022 16:00:53 +0200 Subject: Second commit --- tests/__init__.py | 0 tests/test_android.py | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/testsdata/example.apk | Bin 0 -> 25931 bytes 3 files changed, 43 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_android.py create mode 100644 tests/testsdata/example.apk (limited to 'tests') diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_android.py b/tests/test_android.py new file mode 100644 index 0000000..a72f8d8 --- /dev/null +++ b/tests/test_android.py @@ -0,0 +1,43 @@ +import os + +from karton.android import Android + +from karton.core import Task +from karton.core.test import KartonTestCase, TestResource + + +class AndroidMagicTestCase(KartonTestCase): + karton_class = Android + + def test_android(self): + testcase = os.path.join(os.path.dirname(__file__), "testsdata", "example.apk") + with self.subTest(testcase): + with open(testcase, "rb") as f: + content = f.read() + sample = TestResource(testcase, content) + expected = Task( + { + "type": "sample", + "stage": "analyzed", + "origin": "karton.android", + }, + payload={ + 'attributes': { + "certificate": ["61ED377E85D386A8DFEE6B864BD85B0BFAA5AF81"], + "main_activity": ["com.example.android.contactmanager..ContactManager"], + "package": ["com.example.android.contactmanager"], + "activities": ["com.example.android.contactmanager..ContactManager", "com.example.android.contactmanager.ContactAdder"], + "permissions": ["android.permission.GET_ACCOUNTS", "android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS"], + } + }, + ) + task = Task( + { + "type": "sample", + "extension": "apk", + }, + payload={"sample": sample}, + ) + results = self.run_task(task) + + self.assertTasksEqual(results, [expected]) diff --git a/tests/testsdata/example.apk b/tests/testsdata/example.apk new file mode 100644 index 0000000..418f504 Binary files /dev/null and b/tests/testsdata/example.apk differ -- cgit v1.3