def test_incorrect_target(): google_only_config = { "apps": { "production": { "package_names": ["org.mozilla.google"], "certificate_alias": "google", "google": { "default_track": "internal", "service_account": "*****@*****.**", "credentials_file": "google.p12" }, } } } payload = {"channel": "production", "target_store": "amazon"} with pytest.raises(ValueError): get_publish_config(google_only_config, payload, "google") amazon_only_config = { "apps": { "production": { "package_names": ["org.mozilla.amazon"], "certificate_alias": "amazon", "amazon": { "client_id": "amazon_client", "client_secret": "amazon_secret" }, } } } payload = {"channel": "production", "target_store": "google"} with pytest.raises(ValueError): get_publish_config(amazon_only_config, payload, "amazon")
async def async_main(context): android_product = task.extract_android_product_from_scopes(context) product_config = _get_product_config(context, android_product) publish_config = get_publish_config(product_config, context.task['payload'], android_product) contact_server = not bool(context.config.get('do_not_contact_server')) logging.getLogger('oauth2client').setLevel(logging.WARNING) _log_warning_forewords(contact_server, publish_config['dry_run'], publish_config['target_store']) log.info('Verifying upstream artifacts...') artifacts_per_task_id, failed_artifacts_per_task_id = artifacts.get_upstream_artifacts_full_paths_per_task_id(context) all_apks_paths = [ artifact for artifacts_list in artifacts_per_task_id.values() for artifact in artifacts_list if artifact.endswith('.apk') ] if not publish_config.get('skip_check_signature', True): log.info('Verifying APKs\' signatures...') for apk_path in all_apks_paths: jarsigner.verify(context, publish_config, apk_path) manifest.verify(product_config, apk_path) else: log.info('This product is configured with "skip_check_signature", so the signing of the ' 'APK will not be verified.') log.info('Delegating publication to mozapkpublisher...') with contextlib.ExitStack() as stack: files = [stack.enter_context(open(apk_file_name)) for apk_file_name in all_apks_paths] publish.publish(product_config, publish_config, files, contact_server) log.info('Done!')
def test_google_params_for_amazon(): payload = { 'channel': 'production', 'target_store': 'amazon', 'rollout_percentage': 10, } with pytest.raises(ValueError): assert get_publish_config(ANY_STORE_CONFIG, payload, 'flex')
def test_google_params_for_amazon(): payload = { "channel": "production", "target_store": "amazon", "rollout_percentage": 10 } with pytest.raises(ValueError): assert get_publish_config(ANY_STORE_CONFIG, payload, "flex")
def test_target_amazon(): payload = {"channel": "production", "target_store": "amazon"} assert get_publish_config(ANY_STORE_CONFIG, payload, "flex") == { "target_store": "amazon", "dry_run": False, "certificate_alias": "flex", "username": "******", "secret": "flex_secret", "package_names": ["org.mozilla.flex"], }
def test_get_publish_config_fennec(): assert get_publish_config(AURORA_CONFIG, {}, 'aurora') == { 'target_store': 'google', 'dry_run': True, 'certificate_alias': 'aurora', 'google_track': 'beta', 'google_rollout_percentage': None, 'username': '******', 'secret': 'aurora.p12', 'package_names': ['org.mozilla.fennec_aurora'], }
def test_get_publish_config_fennec(): assert get_publish_config(AURORA_CONFIG, {}, "aurora") == { "target_store": "google", "dry_run": True, "certificate_alias": "aurora", "google_track": "beta", "google_rollout_percentage": None, "username": "******", "secret": "aurora.p12", "package_names": ["org.mozilla.fennec_aurora"], }
def test_get_publish_config_fenix(): payload = {'channel': 'production'} assert get_publish_config(FENIX_CONFIG, payload, 'fenix') == { 'target_store': 'google', 'dry_run': True, 'certificate_alias': 'fenix', 'google_track': 'internal', 'google_rollout_percentage': None, 'username': '******', 'secret': 'fenix.p12', 'package_names': ['org.mozilla.fenix'], }
def test_get_publish_config_focus_rollout(): payload = {'channel': 'production', 'rollout_percentage': 10} assert get_publish_config(FOCUS_CONFIG, payload, 'focus') == { 'target_store': 'google', 'dry_run': True, 'certificate_alias': 'focus', 'google_track': 'production', 'google_rollout_percentage': 10, 'username': '******', 'secret': 'focus.p12', 'package_names': ['org.mozilla.focus'], }
def test_target_google(): payload = {"channel": "production", "target_store": "google"} assert get_publish_config(ANY_STORE_CONFIG, payload, "flex") == { "target_store": "google", "dry_run": True, "certificate_alias": "flex", "google_track": "internal", "google_rollout_percentage": None, "username": "******", "secret": "flex.p12", "package_names": ["org.mozilla.flex"], }
def test_get_publish_config_fenix_rollout(): payload = {"channel": "production", "rollout_percentage": 10} assert get_publish_config(FENIX_CONFIG, payload, "fenix") == { "target_store": "google", "dry_run": True, "certificate_alias": "fenix", "google_track": "internal", "google_rollout_percentage": 10, "username": "******", "secret": "fenix.p12", "package_names": ["org.mozilla.fenix"], }
def test_get_publish_config_focus(): payload = {"channel": "beta"} assert get_publish_config(FOCUS_CONFIG, payload, "focus") == { "target_store": "google", "dry_run": True, "certificate_alias": "focus", "google_track": "beta", "google_rollout_percentage": None, "username": "******", "secret": "focus.p12", "package_names": ["org.mozilla.focus"], }
def test_incorrect_target(): google_only_config = { 'apps': { 'production': { 'package_names': ['org.mozilla.google'], 'certificate_alias': 'google', 'google': { 'default_track': 'internal', 'service_account': '*****@*****.**', 'credentials_file': 'google.p12', } } } } payload = { 'channel': 'production', 'target_store': 'amazon', } with pytest.raises(ValueError): get_publish_config(google_only_config, payload, 'google') amazon_only_config = { 'apps': { 'production': { 'package_names': ['org.mozilla.amazon'], 'certificate_alias': 'amazon', 'amazon': { 'client_id': 'amazon_client', 'client_secret': 'amazon_secret', } } } } payload = { 'channel': 'production', 'target_store': 'google', } with pytest.raises(ValueError): get_publish_config(amazon_only_config, payload, 'amazon')
def test_target_amazon(): payload = { 'channel': 'production', 'target_store': 'amazon', } assert get_publish_config(ANY_STORE_CONFIG, payload, 'flex') == { 'target_store': 'amazon', 'dry_run': False, 'certificate_alias': 'flex', 'username': '******', 'secret': 'flex_secret', 'package_names': ['org.mozilla.flex'] }
def test_ambiguous_target(): payload = { 'channel': 'production', } with pytest.raises(ValueError): get_publish_config(ANY_STORE_CONFIG, payload, 'flex')
def test_ambiguous_target(): payload = {"channel": "production"} with pytest.raises(ValueError): get_publish_config(ANY_STORE_CONFIG, payload, "flex")