コード例 #1
0
ファイル: test_l10n.py プロジェクト: kmaglione/amo-validator
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)
コード例 #2
0
ファイル: test_l10n.py プロジェクト: andymckay/amo-validator
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)
コード例 #3
0
ファイル: test_l10n.py プロジェクト: andymckay/amo-validator
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)
コード例 #4
0
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)
コード例 #5
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)
コード例 #6
0
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)
コード例 #7
0
ファイル: test_l10n.py プロジェクト: kmaglione/amo-validator
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)
コード例 #8
0
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)
コード例 #9
0
ファイル: test_l10n.py プロジェクト: nmaier/amo-validator
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)
コード例 #10
0
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)
コード例 #11
0
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)
コード例 #12
0
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)
コード例 #13
0
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)
コード例 #14
0
ファイル: test_l10n.py プロジェクト: nmaier/amo-validator
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)
コード例 #15
0
ファイル: test_conduit.py プロジェクト: nmaier/amo-validator
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)
コード例 #16
0
ファイル: test_conduit.py プロジェクト: nmaier/amo-validator
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)
コード例 #17
0
ファイル: test_conduit.py プロジェクト: nmaier/amo-validator
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)
コード例 #18
0
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)
コード例 #19
0
ファイル: test_conduit.py プロジェクト: nmaier/amo-validator
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)
コード例 #20
0
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)
コード例 #21
0
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)
コード例 #22
0
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)
コード例 #23
0
ファイル: test_l10n.py プロジェクト: kmaglione/amo-validator
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)
コード例 #24
0
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)
コード例 #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
コード例 #26
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
コード例 #27
0
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)
コード例 #28
0
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)
コード例 #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"]
コード例 #30
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"]
コード例 #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
コード例 #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"]
コード例 #33
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
コード例 #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')
コード例 #35
0
ファイル: test_l10n.py プロジェクト: kmaglione/amo-validator
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
コード例 #36
0
ファイル: test_l10n.py プロジェクト: kmaglione/amo-validator
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
コード例 #37
0
ファイル: test_l10n.py プロジェクト: kmaglione/amo-validator
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
コード例 #38
0
ファイル: test_l10n.py プロジェクト: andymckay/amo-validator
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
コード例 #39
0
ファイル: test_l10n.py プロジェクト: andymckay/amo-validator
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
コード例 #40
0
ファイル: test_l10n.py プロジェクト: andymckay/amo-validator
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
コード例 #41
0
ファイル: test_l10n.py プロジェクト: kmaglione/amo-validator
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
コード例 #42
0
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')
コード例 #43
0
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')
コード例 #44
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')
コード例 #45
0
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")
コード例 #46
0
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"]
コード例 #47
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"]
コード例 #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"]
コード例 #49
0
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.
コード例 #50
0
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.*'
    ])
コード例 #51
0
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)
コード例 #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)
コード例 #53
0
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)
コード例 #54
0
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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #58
0
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)