diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2023-08-03 22:59:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-03 22:59:59 +0200 |
commit | 95fdd555b38f4fa885f46454675b293e8021cd85 (patch) | |
tree | 9c5d1d375b52e075d7e1cf2a27c214ebf25ebbee /test/units/galaxy | |
parent | Overhaul package-data sanity test (#81427) (diff) | |
download | ansible-95fdd555b38f4fa885f46454675b293e8021cd85.tar.xz ansible-95fdd555b38f4fa885f46454675b293e8021cd85.zip |
galaxy: Cross check the collection type (#81423)
* User-provided collection type might differ from collection
source. Cross-check the type before proceeding
Fixes: #79463
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Diffstat (limited to 'test/units/galaxy')
-rw-r--r-- | test/units/galaxy/test_collection_install.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/units/galaxy/test_collection_install.py b/test/units/galaxy/test_collection_install.py index 9f599f7d9b..a61ae40683 100644 --- a/test/units/galaxy/test_collection_install.py +++ b/test/units/galaxy/test_collection_install.py @@ -298,6 +298,27 @@ def test_build_requirement_from_tar(collection_artifact): assert actual.ver == u'0.1.0' +def test_build_requirement_from_tar_url(tmp_path_factory): + test_dir = to_bytes(tmp_path_factory.mktemp('test-ÅÑŚÌβŁÈ Collections Input')) + concrete_artifact_cm = collection.concrete_artifact_manager.ConcreteArtifactsManager(test_dir, validate_certs=False) + test_url = 'https://example.com/org/repo/sample.tar.gz' + expected = fr"^Failed to download collection tar from '{to_text(test_url)}'" + + with pytest.raises(AnsibleError, match=expected): + Requirement.from_requirement_dict({'name': test_url, 'type': 'url'}, concrete_artifact_cm) + + +def test_build_requirement_from_tar_url_wrong_type(tmp_path_factory): + test_dir = to_bytes(tmp_path_factory.mktemp('test-ÅÑŚÌβŁÈ Collections Input')) + concrete_artifact_cm = collection.concrete_artifact_manager.ConcreteArtifactsManager(test_dir, validate_certs=False) + test_url = 'https://example.com/org/repo/sample.tar.gz' + expected = fr"^Unable to find collection artifact file at '{to_text(test_url)}'\.$" + + with pytest.raises(AnsibleError, match=expected): + # Specified wrong collection type for http URL + Requirement.from_requirement_dict({'name': test_url, 'type': 'file'}, concrete_artifact_cm) + + def test_build_requirement_from_tar_fail_not_tar(tmp_path_factory): test_dir = to_bytes(tmp_path_factory.mktemp('test-ÅÑŚÌβŁÈ Collections Input')) test_file = os.path.join(test_dir, b'fake.tar.gz') |