Beispiel #1
0
async def async_main(context):
    logging.getLogger('oauth2client').setLevel(logging.WARNING)
    _log_warning_forewords(context)

    log.info('Verifying upstream artifacts...')
    artifacts_per_task_id, failed_artifacts_per_task_id = 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')
    ]

    log.info('Verifying APKs\' signatures...')
    [jarsigner.verify(context, apk_path) for apk_path in all_apks_paths]

    log.info('Finding whether Google Play strings can be updated...')
    google_play_strings_path = googleplay.get_google_play_strings_path(
        artifacts_per_task_id, failed_artifacts_per_task_id
    )

    log.info('Delegating publication to mozapkpublisher...')
    googleplay.publish_to_googleplay(
        context, all_apks_paths, google_play_strings_path,
    )

    log.info('Done!')
Beispiel #2
0
    def test_publish_config(self, mock_push_apk):
        android_products = ('aurora', 'beta', 'release')
        for android_product in android_products:
            publish_to_googleplay(self.task_payload, self.products[android_product], self.apks, contact_google_play=True)

            mock_push_apk.assert_called_with(
                apks=[MockFile('/path/to/x86.apk'), MockFile('/path/to/arm_v15.apk')],
                service_account='{}_account'.format(android_product),
                google_play_credentials_file=MockFile('/path/to/{}.p12'.format(android_product)),
                track='alpha',
                package_names_check=ANY,
                rollout_percentage=None,
                google_play_strings=ANY,
                commit=False,
                contact_google_play=True,
                skip_check_multiple_locales=False,
                skip_check_ordered_version_codes=False,
                skip_check_same_locales=False,
                skip_checks_fennec=False,
            )
            _, args = mock_push_apk.call_args
            package_names_check = args['package_names_check']
            google_play_strings = args['google_play_strings']
            assert isinstance(package_names_check, AnyPackageNamesCheck)
            assert isinstance(google_play_strings, NoGooglePlayStrings)
Beispiel #3
0
 def test_publish_updates_google_strings_from_file(self, mock_push_apk):
     publish_to_googleplay(self.task_payload, self.products['release'], self.apks, contact_google_play=True,
                           google_play_strings_file=MockFile('/path/to/google_play_strings.json'))
     _, args = mock_push_apk.call_args
     google_play_strings = args['google_play_strings']
     assert isinstance(google_play_strings, FileGooglePlayStrings)
     assert google_play_strings.file.name == '/path/to/google_play_strings.json'
Beispiel #4
0
 def test_craft_push_config_allows_committing_apks(self, mock_push_apk):
     task_payload = {
         'google_play_track': 'production',
         'commit': True
     }
     publish_to_googleplay(task_payload, self.products['release'], self.apks, contact_google_play=True)
     _, args = mock_push_apk.call_args
     assert args['commit'] is True
Beispiel #5
0
    def test_craft_push_config_allows_to_contact_google_play_or_not(self, mock_push_apk):
        publish_to_googleplay(self.task_payload, self.products['aurora'], self.apks, contact_google_play=True)
        _, args = mock_push_apk.call_args
        assert args['contact_google_play'] is True

        publish_to_googleplay(self.task_payload, self.products['aurora'], self.apks, False)
        _, args = mock_push_apk.call_args
        assert args['contact_google_play'] is False
Beispiel #6
0
def test_package_name_validation():
    task_payload = {
        'google_play_track': 'production'
    }
    product_config = {
        'has_nightly_track': False
    }
    with pytest.raises(ConfigValidationError):
        publish_to_googleplay(task_payload, product_config, [], contact_google_play=True)
Beispiel #7
0
 def test_publish_allows_rollout_percentage(self, mock_push_apk):
     task_payload = {
         'google_play_track': 'rollout',
         'rollout_percentage': 10
     }
     publish_to_googleplay(task_payload, self.products['release'], self.apks, contact_google_play=True)
     _, args = mock_push_apk.call_args
     assert args['track'] == 'rollout'
     assert args['rollout_percentage'] == 10
Beispiel #8
0
 def test_craft_push_config_skip_checking_same_locales(self, mock_push_apk):
     product_config = {
         'has_nightly_track': False,
         'service_account': 'product',
         'certificate': '/path/to/product.p12',
         'skip_check_package_names': True,
         'skip_check_same_locales': True,
     }
     publish_to_googleplay(self.task_payload, product_config, self.apks, contact_google_play=True)
     _, args = mock_push_apk.call_args
     assert args['skip_check_same_locales'] is True
Beispiel #9
0
 def test_craft_push_config_expect_package_names(self, mock_push_apk):
     product_config = {
         'has_nightly_track': False,
         'service_account': 'product',
         'certificate': '/path/to/product.p12',
         'expected_package_names': ['org.mozilla.focus', 'org.mozilla.klar']
     }
     publish_to_googleplay(self.task_payload, product_config, self.apks, contact_google_play=True)
     _, args = mock_push_apk.call_args
     package_names_check = args['package_names_check']
     assert isinstance(package_names_check, ExpectedPackageNamesCheck)
     assert package_names_check.expected_product_types == ['org.mozilla.focus', 'org.mozilla.klar']
Beispiel #10
0
async def async_main(context):
    android_product = task.extract_android_product_from_scopes(context)
    product_config = _get_product_config(context, android_product)
    contact_google_play = not bool(
        context.config.get('do_not_contact_google_play'))

    logging.getLogger('oauth2client').setLevel(logging.WARNING)
    _log_warning_forewords(contact_google_play, context.task['payload'])

    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')
    ]

    log.info('Verifying APKs\' signatures...')
    for apk_path in all_apks_paths:
        jarsigner.verify(context, apk_path)
        manifest.verify(product_config, apk_path)

    if product_config['update_google_play_strings']:
        log.info('Finding whether Google Play strings can be updated...')
        strings_path = googleplay.get_google_play_strings_path(
            artifacts_per_task_id, failed_artifacts_per_task_id)
    else:
        log.warning(
            'This product does not upload strings automatically. Skipping Google Play strings search.'
        )
        strings_path = None

    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
        ]
        strings_file = stack.enter_context(
            open(strings_path)) if strings_path is not None else None
        googleplay.publish_to_googleplay(context.task['payload'],
                                         product_config, files,
                                         contact_google_play, strings_file)

    log.info('Done!')
Beispiel #11
0
async def async_main(context):
    logging.getLogger('oauth2client').setLevel(logging.WARNING)
    _log_warning_forewords(context)

    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')
    ]

    log.info('Verifying APKs\' signatures...')
    for apk_path in all_apks_paths:
        jarsigner.verify(context, apk_path)
        manifest.verify(context, apk_path)

    if task.extract_android_product_from_scopes(context) in [
            'focus', 'reference-browser'
    ]:
        log.warning(
            'This product does not upload strings automatically. Skipping Google Play strings search.'
        )
        google_play_strings_path = None
    else:
        log.info('Finding whether Google Play strings can be updated...')
        google_play_strings_path = googleplay.get_google_play_strings_path(
            artifacts_per_task_id, failed_artifacts_per_task_id)

    log.info('Delegating publication to mozapkpublisher...')
    googleplay.publish_to_googleplay(
        context,
        all_apks_paths,
        google_play_strings_path,
    )

    log.info('Done!')
Beispiel #12
0
    def test_craft_push_config_validates_track(self, mock_push_apk):
        task_payload_fake_track = {
            'google_play_track': 'fake'
        }

        with pytest.raises(TaskVerificationError):
            publish_to_googleplay(task_payload_fake_track, self.products['release'], self.apks, contact_google_play=True)

        task_payload_nightly_track = {
            'google_play_track': 'nightly'
        }
        with pytest.raises(TaskVerificationError):
            publish_to_googleplay(task_payload_nightly_track, self.products['release'], self.apks, contact_google_play=True)

        nightly_product_config = {
            'has_nightly_track': True,
            'service_account': 'release_account',
            'certificate': '/path/to/release.p12',
            'skip_check_package_names': True,
        }
        publish_to_googleplay(task_payload_nightly_track, nightly_product_config, self.apks, contact_google_play=True)
        mock_push_apk.assert_called_once()
        _, args = mock_push_apk.call_args
        assert args['track'] == 'nightly'