def test_ReadApexKeysInfo_missingPayloadPublicKey(self): # Invalid lines will be skipped. apex_keys = self.APEX_KEYS_TXT + ( 'name="apex.apexd_test_different_app2.apex" ' 'private_key="system/apex/apexd/apexd_testdata/com.android.apex.test_package_2.pem" ' 'container_certificate="build/make/target/product/security/testkey.x509.pem" ' 'container_private_key="build/make/target/product/security/testkey.pk8"' ) target_files = common.MakeTempFile(suffix='.zip') with zipfile.ZipFile(target_files, 'w', allowZip64=True) as target_files_zip: target_files_zip.writestr('META/apexkeys.txt', apex_keys) with zipfile.ZipFile(target_files, allowZip64=True) as target_files_zip: keys_info = ReadApexKeysInfo(target_files_zip) self.assertEqual( { 'apex.apexd_test.apex': ('system/apex/apexd/apexd_testdata/com.android.apex.test_package.pem', 'build/make/target/product/security/testkey'), 'apex.apexd_test_different_app.apex': ('system/apex/apexd/apexd_testdata/com.android.apex.test_package_2.pem', 'build/make/target/product/security/testkey'), }, keys_info)
def test_ReadApexKeysInfo_presignedKeys(self): apex_keys = self.APEX_KEYS_TXT + ( 'name="apex.apexd_test_different_app2.apex" ' 'private_key="PRESIGNED" ' 'public_key="PRESIGNED" ' 'container_certificate="PRESIGNED" ' 'container_private_key="PRESIGNED"') target_files = common.MakeTempFile(suffix='.zip') with zipfile.ZipFile(target_files, 'w', allowZip64=True) as target_files_zip: target_files_zip.writestr('META/apexkeys.txt', apex_keys) with zipfile.ZipFile(target_files, allowZip64=True) as target_files_zip: keys_info = ReadApexKeysInfo(target_files_zip) self.assertEqual( { 'apex.apexd_test.apex': ('system/apex/apexd/apexd_testdata/com.android.apex.test_package.pem', 'build/make/target/product/security/testkey'), 'apex.apexd_test_different_app.apex': ('system/apex/apexd/apexd_testdata/com.android.apex.test_package_2.pem', 'build/make/target/product/security/testkey'), }, keys_info)
def test_ReadApexKeysInfo(self): target_files = common.MakeTempFile(suffix='.zip') with zipfile.ZipFile(target_files, 'w') as target_files_zip: target_files_zip.writestr('META/apexkeys.txt', self.APEX_KEYS_TXT) with zipfile.ZipFile(target_files) as target_files_zip: keys_info = ReadApexKeysInfo(target_files_zip) self.assertEqual({ 'apex.apexd_test.apex': ( 'system/apex/apexd/apexd_testdata/com.android.apex.test_package.pem', 'build/make/target/product/security/testkey'), 'apex.apexd_test_different_app.apex': ( 'system/apex/apexd/apexd_testdata/com.android.apex.test_package_2.pem', 'build/make/target/product/security/testkey'), }, keys_info)