mirror of https://github.com/ansible/ansible.git
get_url: add support for BSD-style digest (#84485)
* Added support for BSD-style digest file to test checksum of downloaded file. Fixes: #84476 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>pull/84554/head
parent
f727d74fc2
commit
5b0d170496
@ -0,0 +1,3 @@
|
||||
---
|
||||
bugfixes:
|
||||
- get_url - add support for BSD-style checksum digest file (https://github.com/ansible/ansible/issues/84476).
|
||||
@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: Contributors to the Ansible project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible.modules.get_url import parse_digest_lines
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("lines", "expected"),
|
||||
[
|
||||
pytest.param(
|
||||
[
|
||||
"a97e6837f60cec6da4491bab387296bbcd72bdba",
|
||||
],
|
||||
[("a97e6837f60cec6da4491bab387296bbcd72bdba", "sample.txt")],
|
||||
id="single-line-digest",
|
||||
),
|
||||
pytest.param(
|
||||
[
|
||||
"a97e6837f60cec6da4491bab387296bbcd72bdba sample.txt",
|
||||
],
|
||||
[("a97e6837f60cec6da4491bab387296bbcd72bdba", "sample.txt")],
|
||||
id="GNU-style-digest",
|
||||
),
|
||||
pytest.param(
|
||||
[
|
||||
"SHA256 (sample.txt) = b1b6ce5073c8fac263a8fc5edfffdbd5dec1980c784e09c5bc69f8fb6056f006.",
|
||||
],
|
||||
[
|
||||
(
|
||||
"b1b6ce5073c8fac263a8fc5edfffdbd5dec1980c784e09c5bc69f8fb6056f006.",
|
||||
"sample.txt",
|
||||
)
|
||||
],
|
||||
id="BSD-style-digest",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_parse_digest_lines(lines, expected):
|
||||
filename = "sample.txt"
|
||||
assert parse_digest_lines(filename, lines) == expected
|
||||
Loading…
Reference in New Issue