Beispiel #1
0
def test_missingfiles():
    'Test a package with missing localization files.'

    l10n.LOCALE_CACHE = {}
    _do_test('tests/resources/l10n/l10n_missingfiles.xpi',
             l10n.test_xpi,
             set_type=PACKAGE_EXTENSION)
Beispiel #2
0
def test_missingfiles():
    "Test a package with missing localization files."

    l10n.LOCALE_CACHE = {}
    _do_test("tests/resources/l10n/l10n_missingfiles.xpi",
             l10n.test_xpi,
             set_type=PACKAGE_EXTENSION)
Beispiel #3
0
def test_missing():
    "Test a package with missing localization entities."

    l10n.LOCALE_CACHE = {}
    _do_test("tests/resources/l10n/l10n_incomplete.xpi",
             l10n.test_xpi,
             set_type=PACKAGE_EXTENSION)
def test_dup_targets():
    """Tests that there are no duplicate targetAppication elements."""

    _do_test("tests/resources/targetapplication/dup_targapp.xpi",
             targetapp.test_targetedapplications,
             True,
             True)
def test_extra_unimportant():
    """Tests the layout of a theme that contains an unimportant but
    extra directory."""
    
    _do_test("tests/resources/packagelayout/theme_extra_unimportant.jar",
             packagelayout.test_theme_layout,
             False)
def test_dup_targets():
    """Tests that there are no duplicate targetAppication elements."""
    
    _do_test("tests/resources/targetapplication/dup_targapp.xpi",
             targetapp.test_targetedapplications,
             True,
             True)
Beispiel #7
0
def test_missing():
    'Test a package with missing localization entities.'

    l10n.LOCALE_CACHE = {}
    _do_test('tests/resources/l10n/l10n_incomplete.xpi',
             l10n.test_xpi,
             set_type=PACKAGE_EXTENSION)
def test_white():
    """Test a non-Conduit addon against the library."""

    _do_test("tests/resources/conduit/pass.xpi",
             conduit.test_conduittoolbar,
             failure=False,
             require_install=True,
             set_type=PACKAGE_EXTENSION)
Beispiel #9
0
def test_unlocalizable():
    "Test a package without localization data."
    
    l10n.LOCALE_CACHE = {}
    _do_test("tests/resources/l10n/unlocalizable.xpi",
             l10n.test_xpi,
             failure=False,
             set_type=PACKAGE_EXTENSION)
def test_blacklisted_files():
    """Tests that the validator will throw warnings on extensions
    containing files that have extensions which are not considered
    safe."""
    
    _do_test("tests/resources/packagelayout/ext_blacklist.xpi",
             packagelayout.test_blacklisted_files,
             True)
def test_bad_order():
    """Tests that the min and max versions are ordered correctly such
    that the earlier version is the min and vice-versa."""

    _do_test("tests/resources/targetapplication/bad_order.xpi",
             targetapp.test_targetedapplications,
             True,
             True)
def test_bad_order():
    """Tests that the min and max versions are ordered correctly such
    that the earlier version is the min and vice-versa."""
    
    _do_test("tests/resources/targetapplication/bad_order.xpi",
             targetapp.test_targetedapplications,
             True,
             True)
def test_outright():
    """Test the Conduit detector against an outright toolbar."""

    _do_test("tests/resources/conduit/basta_bar.xpi",
             conduit.test_conduittoolbar,
             failure=True,
             require_install=True,
             set_type=PACKAGE_EXTENSION)
Beispiel #14
0
def test_unmodified():
    """Test a package containing localization entities that have been
    unmodified from the reference locale (en-US)"""
    
    l10n.LOCALE_CACHE = {}
    _do_test("tests/resources/l10n/l10n_unmodified.xpi",
             l10n.test_xpi,
             set_type=PACKAGE_EXTENSION)
Beispiel #15
0
def test_params():
    """Tests the Conduit detector against a toolbar with parameters in
    the install.rdf file that indiciate Conduit-ion."""
    
    _do_test("tests/resources/conduit/conduit_params.xpi",
             conduit.test_conduittoolbar,
             failure=True,
             require_install=True,
             set_type=PACKAGE_EXTENSION)
Beispiel #16
0
def test_structure():
    """Tests the Conduit detector against a toolbar with files and
    folders which resemble those of a Conduit toolbar."""
    
    _do_test("tests/resources/conduit/conduit_structure.xpi",
             conduit.test_conduittoolbar,
             failure=True,
             require_install=True,
             set_type=PACKAGE_EXTENSION)
Beispiel #17
0
def test_chrome():
    """Tests the Conduit detector against a toolbar with
    chrome.manifest entries that indicate a Conduit toolbar."""
    
    _do_test("tests/resources/conduit/conduit_chrome.xpi",
             conduit.test_conduittoolbar,
             failure=True,
             require_install=True,
             set_type=PACKAGE_EXTENSION)
def test_bad_min_max_webextension():
    """Tests that the lower/upper-bound version number is indeed a valid
    version number."""

    _do_test('tests/resources/targetapplication/webextension_bad_min.xpi',
             targetapp.test_targetedapplications, True, True)

    _do_test('tests/resources/targetapplication/webextension_bad_max.xpi',
             targetapp.test_targetedapplications, True, True)
Beispiel #19
0
def test_updateurl():
    """Tests the Conduit detector against a toolbar with its updateURL
    parameter set to that of a Conduit Toolbar's."""
    
    _do_test("tests/resources/conduit/conduit_updateurl.xpi",
             conduit.test_conduittoolbar,
             failure=True,
             require_install=True,
             set_type=PACKAGE_EXTENSION)
def test_bad_min_max():
    """Tests that the lower/upper-bound version number for a
    targetApplication entry is indeed a valid version number"""

    _do_test('tests/resources/targetapplication/bad_min.xpi',
             targetapp.test_targetedapplications, True, True)

    _do_test('tests/resources/targetapplication/bad_max.xpi',
             targetapp.test_targetedapplications, True, True)
def test_valid_targetapps():
    """Tests that the install.rdf contains only valid entries for
    target applications."""
    
    print targetapp.APPROVED_APPLICATIONS

    _do_test("tests/resources/targetapplication/pass.xpi",
             targetapp.test_targetedapplications,
             False,
             True)
def test_missing_min_max():
    """
    Test that the minVersion and maxVersion properties of each
    targetApplication are present.
    """

    _do_test('tests/resources/targetapplication/missing_min.xpi',
             targetapp.test_targetedapplications, True, True)

    _do_test('tests/resources/targetapplication/missing_max.xpi',
             targetapp.test_targetedapplications, True, True)
Beispiel #23
0
def test_multiple_packages():
    """
    Test that the manifest parser recognizes when there are multiple
    packages of the same type.
    """

    l10n.LOCALE_CACHE = {}
    _do_test('tests/resources/l10n/l10n_multpreds.xpi',
             l10n.test_xpi,
             failure=False,
             set_type=PACKAGE_EXTENSION)
def test_bad_min_max():
    """Tests that the lower/upper-bound version number for a
    targetApplication entry is indeed a valid version number"""
    
    _do_test("tests/resources/targetapplication/bad_min.xpi",
             targetapp.test_targetedapplications,
             True,
             True)
             
    _do_test("tests/resources/targetapplication/bad_max.xpi",
             targetapp.test_targetedapplications,
             True,
             True)
Beispiel #25
0
def test_blacklisted_magic_numbers():
    "Tests that blacklisted magic numbers are banned"

    err = _do_test("tests/resources/packagelayout/magic_number.xpi",
                   packagelayout.test_blacklisted_files, True)
    assert err.metadata["contains_binary_content"]

    # Same logic as above.
    err = _do_test("tests/resources/packagelayout/magic_number.xpi",
                   packagelayout.test_compatibility_binary, False)
    print err.compat_summary
    assert not err.compat_summary["errors"]
    assert "binary_components" not in err.metadata
def test_blacklisted_magic_numbers():
    "Tests that blacklisted magic numbers are banned"

    err = _do_test("tests/resources/packagelayout/magic_number.xpi",
                   packagelayout.test_blacklisted_files, True)
    assert err.metadata["contains_binary_content"]

    # Same logic as above.
    err = _do_test("tests/resources/packagelayout/magic_number.xpi",
                   packagelayout.test_compatibility_binary, False)
    print err.compat_summary
    assert not err.compat_summary["errors"]
    assert "binary_components" not in err.metadata
def test_bad_min_max_webextension():
    """Tests that the lower/upper-bound version number is indeed a valid
    version number."""

    _do_test('tests/resources/targetapplication/webextension_bad_min.xpi',
             targetapp.test_targetedapplications,
             True,
             True)

    _do_test('tests/resources/targetapplication/webextension_bad_max.xpi',
             targetapp.test_targetedapplications,
             True,
             True)
def test_missing_min_max():
    """
    Test that the minVersion and maxVersion properties of each
    targetApplication are present.
    """

    _do_test("tests/resources/targetapplication/missing_min.xpi",
             targetapp.test_targetedapplications,
             True,
             True)

    _do_test("tests/resources/targetapplication/missing_max.xpi",
             targetapp.test_targetedapplications,
             True,
             True)
Beispiel #29
0
def test_blacklisted_files():
    """Tests that the validator will throw warnings on extensions
    containing files that have extensions which are not considered
    safe."""

    err = _do_test("tests/resources/packagelayout/ext_blacklist.xpi",
                   packagelayout.test_blacklisted_files, True)
    assert err.metadata["contains_binary_extension"]
    assert not any(count for (key, count) in err.compat_summary.items())

    # Run the compatibility test on this, but it shouldn't fail or produce
    # errors because the bianry content isn't in the appropriate directories.
    err = _do_test("tests/resources/packagelayout/ext_blacklist.xpi",
                   packagelayout.test_compatibility_binary, False)
    print err.compat_summary
    assert not err.compat_summary["errors"]
def test_blacklisted_files():
    """Tests that the validator will throw warnings on extensions
    containing files that have extensions which are not considered
    safe."""

    err = _do_test("tests/resources/packagelayout/ext_blacklist.xpi",
                   packagelayout.test_blacklisted_files, True)
    assert err.metadata["contains_binary_extension"]
    assert not any(count for (key, count) in err.compat_summary.items())

    # Run the compatibility test on this, but it shouldn't fail or produce
    # errors because the bianry content isn't in the appropriate directories.
    err = _do_test("tests/resources/packagelayout/ext_blacklist.xpi",
                   packagelayout.test_compatibility_binary, False)
    print err.compat_summary
    assert not err.compat_summary["errors"]
Beispiel #31
0
def test_blacklisted_magic_numbers():
    "Tests that blacklisted magic numbers are banned"

    err = _do_test("tests/resources/packagelayout/magic_number.xpi",
                   packagelayout.test_blacklisted_files, True)
    assert err.metadata["contains_binary_content"]
    assert "binary_components" not in err.metadata
Beispiel #32
0
def test_blacklisted_files():
    """Tests that the validator will throw warnings on extensions
    containing files that have extensions which are not considered
    safe."""

    err = _do_test("tests/resources/packagelayout/ext_blacklist.xpi",
                   packagelayout.test_blacklisted_files, True)
    assert err.metadata["contains_binary_extension"]
def test_blacklisted_magic_numbers():
    "Tests that blacklisted magic numbers are banned"

    err = _do_test("tests/resources/packagelayout/magic_number.xpi",
                   packagelayout.test_blacklisted_files,
                   True)
    assert err.metadata["contains_binary_content"]
    assert "binary_components" not in err.metadata
Beispiel #34
0
def test_dup_targets():
    """Tests that there are no duplicate targetAppication elements."""

    results = _do_test('tests/resources/targetapplication/dup_targapp.xpi',
                       targetapp.test_targetedapplications, True, True)
    assert results.errors[0]['id'] == ('testcases_targetapplication',
                                       'test_targetedapplications',
                                       'duplicate_targetapps')
Beispiel #35
0
def test_unlocalizable():
    'Test a package without localization data.'

    l10n.LOCALE_CACHE = {}
    output = _do_test('tests/resources/l10n/unlocalizable.xpi',
                      l10n.test_xpi,
                      failure=False,
                      set_type=PACKAGE_EXTENSION)
    assert output.notices  # Should alert about lack of locales
Beispiel #36
0
def test_localizable():
    'Tests a package with minimal localization data.'

    l10n.LOCALE_CACHE = {}
    output = _do_test('tests/resources/l10n/localizable.xpi',
                      l10n.test_xpi,
                      failure=False,
                      set_type=PACKAGE_EXTENSION)
    assert not output.notices
Beispiel #37
0
def test_pass():
    'Test a package with localization that should pass validation.'

    l10n.LOCALE_CACHE = {}
    output = _do_test('tests/resources/l10n/pass.xpi',
                      l10n.test_xpi,
                      failure=False,
                      set_type=PACKAGE_EXTENSION)
    assert not output.errors
Beispiel #38
0
def test_pass():
    "Test a package with localization that should pass validation."

    l10n.LOCALE_CACHE = {}
    output = _do_test("tests/resources/l10n/pass.xpi",
                      l10n.test_xpi,
                      failure=False,
                      set_type=PACKAGE_EXTENSION)
    assert not output.errors
Beispiel #39
0
def test_localizable():
    "Tests a package with minimal localization data."

    l10n.LOCALE_CACHE = {}
    output = _do_test("tests/resources/l10n/localizable.xpi",
                      l10n.test_xpi,
                      failure=False,
                      set_type=PACKAGE_EXTENSION)
    assert not output.notices
Beispiel #40
0
def test_unlocalizable():
    "Test a package without localization data."

    l10n.LOCALE_CACHE = {}
    output = _do_test("tests/resources/l10n/unlocalizable.xpi",
                      l10n.test_xpi,
                      failure=False,
                      set_type=PACKAGE_EXTENSION)
    assert output.notices # Should alert about lack of locales
Beispiel #41
0
def test_unmodified():
    """Test a package containing localization entities that have been
    unmodified from the reference locale (en-US)"""

    l10n.LOCALE_CACHE = {}
    err = _do_test('tests/resources/l10n/l10n_unmodified.xpi',
                   l10n.test_xpi,
                   set_type=PACKAGE_EXTENSION,
                   failure=False)
    assert err.notices
def test_missing_min_max():
    """
    Test that the minVersion and maxVersion properties of each
    targetApplication are mandatory.
    """

    results = _do_test('tests/resources/targetapplication/missing_min.xpi',
                       targetapp.test_targetedapplications, True, True)
    # _do_test() checks for .failed(), but by default this includes warnings.
    # We want to make sure it's a hard error and not just a warning.
    assert results.errors[0]['id'] == ('testcases_targetapplication',
                                       'test_targetedapplications',
                                       'missing_minversion')

    results = _do_test('tests/resources/targetapplication/missing_max.xpi',
                       targetapp.test_targetedapplications, True, True)
    assert results.errors[0]['id'] == ('testcases_targetapplication',
                                       'test_targetedapplications',
                                       'missing_maxversion')
def test_is_ff4():
    """Tests a passing install.rdf package for whether it's built for
    Firefox 4. This doesn't pass or fail a package, but it is used for
    other tests in other modules in higher tiers."""

    results = _do_test('tests/resources/targetapplication/ff4.xpi',
                       targetapp.test_targetedapplications, False, True)

    assert results.get_resource('ff4')
    assert results.get_resource('supports')
    assert 'firefox' in results.get_resource('supports')
def test_dup_targets():
    """Tests that there are no duplicate targetAppication elements."""

    results = _do_test(
        'tests/resources/targetapplication/dup_targapp.xpi',
        targetapp.test_targetedapplications,
        True,
        True)
    assert results.errors[0]['id'] == ('testcases_targetapplication',
                                       'test_targetedapplications',
                                       'duplicate_targetapps')
def test_is_ff4():
    """Tests a passing install.rdf package for whether it's built for
    Firefox 4. This doesn't pass or fail a package, but it is used for
    other tests in other modules in higher tiers."""
    
    results = _do_test("tests/resources/targetapplication/ff4.xpi",
                       targetapp.test_targetedapplications,
                       False,
                       True)
    
    assert results.get_resource("ff4")
def test_compat_binary_magic_numbers():
    """
    Test that the validator will throw compatibility errors for files that
    have executable magic numbers (not including interpreted or Java files)
    such that the developer is alerted about needing to manually update the
    maxVersion.
    """

    # Same logic as above.
    err = _do_test("tests/resources/packagelayout/magic_number_compat.xpi",
                   packagelayout.test_compatibility_binary,
                   False)
    print err.compat_summary
    assert err.compat_summary["errors"]
def test_compat_binary_extensions():
    """
    Test that the validator will throw compatibility errors for files that
    would otherwise require the add-on to be manually updated.
    """

    # This time when the compatibility checks are run, they should fire off
    # compatibility errors because the files are the /components/ directory
    # of the package.
    err = _do_test("tests/resources/packagelayout/ext_blacklist_compat.xpi",
                   packagelayout.test_compatibility_binary,
                   False)
    print err.compat_summary
    assert err.compat_summary["errors"]
Beispiel #48
0
def test_compat_binary_extensions():
    """
    Test that the validator will throw compatibility errors for files that
    would otherwise require the add-on to be manually updated.
    """

    # This time when the compatibility checks are run, they should fire off
    # compatibility errors because the files are the /components/ directory
    # of the package.
    err = _do_test("tests/resources/packagelayout/ext_blacklist_compat.xpi",
                   packagelayout.test_compatibility_binary, False)
    print err.compat_summary
    assert err.compat_summary["errors"]
    assert err.metadata["binary_components"]
def test_valid_targetapps_webextension_missing_min_max():
    """
    Test that min/max version are *not* mandatory for web extensions.
    """
    results = _do_test('tests/resources/targetapplication/webextension.xpi',
                       targetapp.test_targetedapplications, False, True)
    supports = results.get_resource('supports')
    assert 'firefox' in supports
    assert len(supports) == 1

    supported_versions = results.supported_versions
    supported_firefox_versions = supported_versions[
        '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}']
    assert '42.0' in supported_firefox_versions  # Automatic min version.
    assert '*' in supported_firefox_versions  # Automatic max version.
def test_valid_targetapps():
    """
    Tests that the install.rdf contains only valid entries for target
    applications.
    """

    results = _do_test('tests/resources/targetapplication/pass.xpi',
                       targetapp.test_targetedapplications, False, True)
    supports = results.get_resource('supports')
    assert 'firefox' in supports and 'mozilla' in supports
    assert len(supports) == 2

    supported_versions = results.supported_versions
    assert (supported_versions['{ec8030f7-c20a-464f-9b0e-13a3a9e97384}'] == [
        '3.6', '3.6.4', '3.6.*'
    ])
def test_langpack_bad_uri_obj():
    """Tests that a language pack has an invalid URI specified for its
    'override' objects."""

    _do_test('tests/resources/langpack/fail_uri_obj.xpi',
             langpack.test_langpack_manifest)
Beispiel #52
0
def test_extra_unimportant():
    """Tests the layout of a theme that contains an unimportant but
    extra directory."""

    _do_test("tests/resources/packagelayout/theme_extra_unimportant.jar",
             packagelayout.test_theme_layout, False)
def test_langpack_valid():
    'Tests that a language pack has a valid chrome manifest file.'

    _do_test('tests/resources/langpack/pass.xpi',
             langpack.test_langpack_manifest, False)
def test_langpack_bad_nested_subject():
    """
    Test that when a subject in a sub-manifest is not valid, it gets reported.
    """
    _do_test('tests/resources/langpack/nested.xpi',
             langpack.test_langpack_manifest)
Beispiel #55
0
def test_theme_chrome_manifest():
    'Tests that a theme has a valid chrome manifest file.'

    _do_test('tests/resources/themes/pass.jar', themes.test_theme_manifest,
             False)
Beispiel #56
0
def test_theme_bad_chrome_manifest():
    'Tests that a theme has an invalid chrome manifest file.'

    _do_test('tests/resources/themes/fail.jar', themes.test_theme_manifest)
Beispiel #57
0
def test_theme_passing():
    "Tests the layout of a proper theme"

    _do_test("tests/resources/packagelayout/theme.jar",
             packagelayout.test_theme_layout, False)
def test_langpack_bad_subject():
    """Tests that a language pack has an invalid subject in the
    chrome.manifest file."""

    _do_test('tests/resources/langpack/fail.xpi',
             langpack.test_langpack_manifest)