LifeMate — Personal, Family & Learning Companion
docs/offline-data-rescue-options
chore/phase1-repository-cleanup
deploy/stable-web-apk
deployment-static
design/mobile-accessibility-v2
design/mobile-navigation-review
docs/child-education-access-decision
docs/offline-data-rescue-options
docs/owner-guide-and-delivery-plan
docs/phase1-policy-options
docs/public-review-live-2026-10-15
feat/aparat-learning-library
feat/child-device-safety
feat/child-identity-schema
feat/flutter-mobile-navigation
feat/learning-content-operations
feat/local-signing-preflight
feat/online-family-stage0
feat/personal-encrypted-recovery
feat/private-planner-series-api
feat/public-review-page
feat/standalone-weekly-planner
feat/weekly-planner-android
final-feature-1/iran-family-school
fix/auth-abuse-expiry-safety
fix/auth-expiry-after-lock
fix/backend-request-safety
fix/lifeguide-bootstrap-naming-ci
fix/lifeguide-pages-qa-base-preflight
fix/lifeguide-qa-pages-env-deployment
fix/local-task-persistence
fix/managed-child-session-boundary
fix/personal-jalali-dates
fix/personal-notification-controls
fix/personal-upgrade-delivery-guard
fix/sms-approval-gates
fix/study-duration-display
infra/cloudflare-neon-migration
infra/lifeguide-cloudflare-qa
infra/lifeguide-github-pages-qa
infra/lifeguide-supabase-qa
main
phase-1/foundation-completion
phase-2/product-foundation-identity
phase-3/planner-school-family-core
phase-4/ai-learning-wellbeing
phase-5/hardening-observability-release
test/android-reminder-acceptance
test/personal-notification-settings
test/personal-recovery-acceptance
test/role-entry-apk
| 1 | """Packaging gates; test manifests are synthetic, not an APK build.""" |
| 2 | import tempfile |
| 3 | import unittest |
| 4 | from pathlib import Path |
| 5 | from unittest.mock import patch |
| 6 | from zipfile import ZipFile |
| 7 | |
| 8 | import check_standalone_apk as subject |
| 9 | |
| 10 | |
| 11 | class StandaloneManifestTest(unittest.TestCase): |
| 12 | def setUp(self): |
| 13 | self.directory = tempfile.TemporaryDirectory() |
| 14 | self.addCleanup(self.directory.cleanup) |
| 15 | self.apk = Path(self.directory.name) / 'LifeGuide.apk' |
| 16 | with ZipFile(self.apk, 'w') as archive: |
| 17 | archive.writestr('AndroidManifest.xml', b'synthetic parser fixture') |
| 18 | self.tags = [ |
| 19 | ('manifest', {'package': 'ir.lifeguide.app.device', |
| 20 | 'versionName': '0.7.2-personal.1', 'versionCode': 9}), |
| 21 | ('uses-sdk', {'minSdkVersion': 24, 'targetSdkVersion': 36}), |
| 22 | ('application', {'label': 'لایفگاید شخصی', 'debuggable': True, |
| 23 | 'allowBackup': False, 'usesCleartextTraffic': False}), |
| 24 | ('activity', {'name': 'ir.lifeguide.app.MainActivity', 'exported': True}), |
| 25 | ('receiver', {'name': 'ir.lifeguide.app.LocalReminderReceiver', 'exported': False}), |
| 26 | ('uses-permission', {'name': 'android.permission.POST_NOTIFICATIONS'}), |
| 27 | ('uses-permission', {'name': 'android.permission.RECEIVE_BOOT_COMPLETED'}), |
| 28 | ('uses-permission', {'name': 'android.permission.SCHEDULE_EXACT_ALARM'}), |
| 29 | ] |
| 30 | |
| 31 | def check(self): |
| 32 | with patch.object(subject, 'manifest_tags', return_value=self.tags): |
| 33 | return subject.check(self.apk) |
| 34 | |
| 35 | def test_separate_debug_device_edition_has_no_internet(self): |
| 36 | result = self.check() |
| 37 | self.assertEqual(result['result'], 'PASS') |
| 38 | self.assertEqual(result['package'], 'ir.lifeguide.app.device') |
| 39 | self.assertIs(result['internetPermission'], False) |
| 40 | self.assertEqual(len(result['sha256']), 64) |
| 41 | |
| 42 | def test_online_identity_and_wrong_main_activity_are_rejected(self): |
| 43 | self.tags[0][1]['package'] = 'ir.lifeguide.app' |
| 44 | with self.assertRaises(ValueError): |
| 45 | self.check() |
| 46 | self.tags[0][1]['package'] = 'ir.lifeguide.app.device' |
| 47 | self.tags[3][1]['name'] = 'ir.lifeguide.app.device.MainActivity' |
| 48 | with self.assertRaises(ValueError): |
| 49 | self.check() |
| 50 | |
| 51 | def test_internet_and_unexpected_permissions_are_rejected(self): |
| 52 | for permission in ('android.permission.INTERNET', 'android.permission.READ_CONTACTS'): |
| 53 | with self.subTest(permission=permission): |
| 54 | self.tags.append(('uses-permission', {'name': permission})) |
| 55 | with self.assertRaises(ValueError): |
| 56 | self.check() |
| 57 | self.tags.pop() |
| 58 | |
| 59 | def test_backup_cleartext_exported_receiver_or_wrong_version_are_rejected(self): |
| 60 | for index, key, value in ((2, 'allowBackup', True), |
| 61 | (2, 'usesCleartextTraffic', True), |
| 62 | (2, 'debuggable', False), |
| 63 | (4, 'exported', True), (0, 'versionCode', 8)): |
| 64 | old = self.tags[index][1][key] |
| 65 | with self.subTest(key=key): |
| 66 | self.tags[index][1][key] = value |
| 67 | with self.assertRaises(ValueError): |
| 68 | self.check() |
| 69 | self.tags[index][1][key] = old |
| 70 | |
| 71 | |
| 72 | if __name__ == '__main__': |
| 73 | unittest.main() |