Repository: cekit/cekit (python)

Issue:
support source-url and source-md5 keys for artifacts definition
**Describe the solution you'd like**

Given an artifacts section such as

```
artifacts:
- name: jolokia-jvm
  target: jolokia-jvm-1.6.2.redhat-00002-agent.jar
  md5: 760f2fbaf6b142192f3cee2c99bfcbf8
```

which (for the specific build types I am using) is translated into an OSBS `fetch-artifacts-url.yaml` file

```
- md5: 8b3af39995b113baf35e53468bad7aae
  target: jmx_prometheus_javaagent-0.3.2.redhat-00003.jar
  url: (redacted)
```

I wish to have additional keys in the destination file `source-url` and `source-md5`, as described in the OSBS docs (linked below).

At the moment, I can't put these in the cekit YAML as they are unrecognised keys, and I can't put them in the destination file as Cekit will over-write it.

Ideal solution is to extend the Cekit schema to copy those keys over from the artifact stanza from the descriptor YAML. But a next-best thing would be to ignore and preserve the keys in the target file when they are present.

**Additional context**

This is a necessary change to our images as part of a licence compliance issue, see https://issues.redhat.com/browse/OPENJDK-1065 (if you are a red hatter)

https://osbs.readthedocs.io/en/latest/users.html#fetch-artifacts-url-yaml

Pull request description:
Add support for source-url/hash to Plain and URL artifacts
Fixes #810 

Needs #811 merged first.

Patch:
diff --git a/cekit/crypto.py b/cekit/crypto.py
index 23feab5..4d7f8c7 100644
--- a/cekit/crypto.py
+++ b/cekit/crypto.py
@@ -1,9 +1,15 @@
 import hashlib
 import logging
+from typing import List
 
 logger = logging.getLogger("cekit")
 
-SUPPORTED_HASH_ALGORITHMS = ["sha512", "sha256", "sha1", "md5"]
+SUPPORTED_HASH_ALGORITHMS: List[str] = ["sha512", "sha256", "sha1", "md5"]
+SUPPORTED_SOURCE_HASH_ALGORITHMS: List[str] = [
+    "source-sha1",
+    "source-sha256",
+    "source-md5",
+]
 
 
 def get_sum(target, algorithm):
@@ -17,14 +23,12 @@ def get_sum(target, algorithm):
     return hash_function.hexdigest()
 
 
-def check_sum(target, algorithm, expected, name=None):
+def check_sum(target, algorithm, expected):
     """Check that file checksum is correct
     Args:
-      alg - algorithm which will be used for diget
-      expected_chksum - checksum which artifact must match
+      alg - algorithm which will be used for digest
+      expected_checksum - checksum which artifact must match
     """
-    if not name:
-        name = target
     logger.debug("Checking '{}' {} hash...".format(target, algorithm))
 
     checksum = get_sum(target, algorithm)
diff --git a/cekit/descriptor/resource.py b/cekit/descriptor/resource.py
index 9984adc..fc4cdea 100644
--- a/cekit/descriptor/resource.py
+++ b/cekit/descriptor/resource.py
@@ -266,7 +266,7 @@ class Resource(Descriptor):
             return True
         for algorithm in SUPPORTED_HASH_ALGORITHMS:
             if algorithm in self and self[algorithm]:
-                if not check_sum(target, algorithm, self[algorithm], self["name"]):
+                if not check_sum(target, algorithm, self[algorithm]):
                     return False
         return True
 
@@ -402,6 +402,19 @@ class _UrlResource(Resource):
             "sha1": {"type": "str", "desc": "The sha1 checksum of the resource"},
             "sha256": {"type": "str", "desc": "The sha256 checksum of the resource"},
             "sha512": {"type": "str", "desc": "The sha512 checksum of the resource"},
+            "source-url": {"type": "str", "desc": "The source of the resource"},
+            "source-md5": {
+                "type": "str",
+                "desc": "The md5 checksum of the source resource",
+            },
+            "source-sha1": {
+                "type": "str",
+                "desc": "The sha1 checksum of the source resource",
+            },
+            "source-sha256": {
+                "type": "str",
+                "desc": "The sha256 checksum of the source resource",
+            },
         }
     }
 
@@ -503,6 +516,19 @@ class _PlainResource(Resource):
             "sha1": {"type": "str", "desc": "The sha1 checksum of the resource"},
             "sha256": {"type": "str", "desc": "The sha256 checksum of the resource"},
             "sha512": {"type": "str", "desc": "The sha512 checksum of the resource"},
+            "source-url": {"type": "str", "desc": "The source of the resource"},
+            "source-md5": {
+                "type": "str",
+                "desc": "The md5 checksum of the source resource",
+            },
+            "source-sha1": {
+                "type": "str",
+                "desc": "The sha1 checksum of the source resource",
+            },
+            "source-sha256": {
+                "type": "str",
+                "desc": "The sha256 checksum of the source resource",
+            },
         }
     }
 
diff --git a/cekit/generator/osbs.py b/cekit/generator/osbs.py
index 8e5ff9a..33a48f9 100644
--- a/cekit/generator/osbs.py
+++ b/cekit/generator/osbs.py
@@ -5,13 +5,19 @@ import sys
 import tempfile
 from collections import OrderedDict
 from contextlib import closing
+from typing import Dict, List
 from urllib.parse import urlparse
 
 import yaml
 
 from cekit import crypto, version
 from cekit.config import Config
-from cekit.descriptor.resource import _PlainResource, _PncResource, _UrlResource
+from cekit.descriptor.resource import (
+    Resource,
+    _PlainResource,
+    _PncResource,
+    _UrlResource,
+)
 from cekit.errors import CekitError
 from cekit.generator.base import Generator
 from cekit.tools import copy_recursively, get_brew_url
@@ -99,9 +105,9 @@ class OSBSGenerator(Generator):
 
         logger.info("Handling artifacts for OSBS...")
         target_dir = os.path.join(self.target, "image")
-        fetch_artifacts_url = []
+        fetch_artifacts_url: List[Dict[str, str]] = []
         fetch_artifacts_pnc = OrderedDict()
-        file_comments = {}
+        file_comments: Dict[str, str] = {}
 
         fetch_domains = config.get("common", "fetch_artifact_domains")
 
@@ -170,6 +176,7 @@ class OSBSGenerator(Generator):
                         fetch_artifacts_url[len(fetch_artifacts_url) - 1].update(
                             {c: artifact[c]}
                         )
+                    patch_source_url(artifact, fetch_artifacts_url)
                     if "description" in artifact:
                         file_comments[artifact["url"]] = artifact["description"]
                     logger.debug(
@@ -198,6 +205,8 @@ class OSBSGenerator(Generator):
                                 "target": os.path.join(artifact["target"]),
                             }
                         )
+                        patch_source_url(artifact, fetch_artifacts_url)
+
                         logger.debug(
                             "Artifact '{}' (as plain) added to fetch-artifacts-url.yaml".format(
                                 artifact["target"]
@@ -273,9 +282,9 @@ class OSBSGenerator(Generator):
 
 
 # Used to modify either the fetch-artifact or fetch-pnc files to add extra human readable information.
-def patch_file(file_comments, file):
+def patch_file(file_comments: Dict[str, str], file: str) -> None:
     # Can't use it as a context manager with plain with as that is >= 3.2
-    with closing(fileinput.input(file, inplace=1)) as input_list:
+    with closing(fileinput.input(file, inplace=True)) as input_list:
         for line in input_list:
             r = [
                 line.replace("\n", " # " + value + "\n")
@@ -286,3 +295,24 @@ def patch_file(file_comments, file):
                 sys.stdout.write(r[0])
             else:
                 sys.stdout.write(line)
+
+
+def patch_source_url(
+    artifact: Resource, fetch_artifacts_url: List[Dict[str, str]]
+) -> None:
+    if "source-url" in artifact:
+        intersected_source_hash = [
+            x for x in crypto.SUPPORTED_SOURCE_HASH_ALGORITHMS if x in artifact
+        ]
+        if not intersected_source_hash:
+            raise CekitError(
+                f"Unable to add source-url for artifact {artifact} as no checksum defined"
+            )
+        logger.debug(
+            f"Found source-url {artifact['source-url']} and checksum markers of {intersected_source_hash}"
+        )
+        fetch_artifacts_url[len(fetch_artifacts_url) - 1].update(
+            {"source-url": artifact["source-url"]}
+        )
+        for c in intersected_source_hash:
+            fetch_artifacts_url[len(fetch_artifacts_url) - 1].update({c: artifact[c]})
diff --git a/docs/descriptor/includes/artifacts.rst b/docs/descriptor/includes/artifacts.rst
index 6edca06..20eb218 100644
--- a/docs/descriptor/includes/artifacts.rst
+++ b/docs/descriptor/includes/artifacts.rst
@@ -168,9 +168,20 @@ provided by some (internal) systems.
           md5: 75e5b5ba0b804cd9def9f20a70af649f
           target: jolokia.tar.gz
 
+    artifacts:
+        - name: jolokia
+          md5: 75e5b5ba0b804cd9def9f20a70af649f
+          target: jolokia.tar.gz
+          source-url: https://www.foo.com/jolokia-source.jar
+          source-md5: 123456789
+
+
 As you can see, the definition does not define from where the artifact should be fetched.
 This approach relies on :doc:`/handbook/caching` to provide the artifact.
 
+The ``source-url`` and source checksum (which may be ``source-md5``, ``source-sha1`` or
+``source-sha256`` are optional and denote where the sources may be found.
+
 .. note::
 
    See :doc:`/handbook/redhat` for description how plain artifacts are used in the
@@ -205,6 +216,15 @@ artifact should be fetched from.
           md5: "75e5b5ba0b804cd9def9f20a70af649f"
           # Final name of the downloaded artifact
           target: "jolokia.tar.gz"
+          source-url: https://www.foo.com/jolokia-source.jar
+          source-md5: 123456789
+
+
+As you can see, the definition does not define from where the artifact should be fetched.
+This approach relies on :doc:`/handbook/caching` to provide the artifact.
+
+The ``source-url`` and source checksum (which may be ``source-md5``, ``source-sha1`` or
+``source-sha256`` are optional and denote where the sources may be found.
 
 Path artifacts
 ******************


Test patch:
diff --git a/tests/test_integ_builder_osbs.py b/tests/test_integ_builder_osbs.py
index 789b4a7..6d3e793 100644
--- a/tests/test_integ_builder_osbs.py
+++ b/tests/test_integ_builder_osbs.py
@@ -1221,11 +1221,6 @@ def test_osbs_builder_with_fetch_artifacts_url_file_creation_1(
 
     tmpdir.mkdir("osbs").mkdir("repo")
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
@@ -1270,19 +1265,14 @@ def test_osbs_builder_with_fetch_artifacts_url_file_creation_2(tmpdir, mocker, c
     mocker.patch("cekit.tools.urlopen")
     mocker.patch("cekit.builders.osbs.DistGit.push")
 
-    tmpdir.mkdir("osbs").mkdir("repo")
-
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
         {"name": "artifact_name", "sha1": "123456", "url": "https://foo/bar.jar"}
     ]
 
+    tmpdir.mkdir("osbs").mkdir("repo")
+
     run_osbs(descriptor, str(tmpdir), mocker)
 
     with open(
@@ -1316,11 +1306,6 @@ def test_osbs_builder_with_fetch_artifacts_url_file_creation_3(tmpdir, mocker, c
 
     tmpdir.mkdir("osbs").mkdir("repo")
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
@@ -1365,11 +1350,6 @@ def test_osbs_builder_with_fetch_artifacts_url_file_creation_4(tmpdir, mocker, c
 
     tmpdir.mkdir("osbs").mkdir("repo")
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [{"url": "https://foo/bar.jar"}]
@@ -1422,11 +1402,6 @@ ssl_verify = False
     with open(cfgfile, "w") as _file:
         _file.write(cfgcontents)
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
@@ -1496,11 +1471,6 @@ def test_osbs_builder_with_fetch_artifacts_url_file_creation_multiple_hash(
 
     tmpdir.mkdir("osbs").mkdir("repo")
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
@@ -1546,11 +1516,6 @@ def test_osbs_builder_with_fetch_artifacts_url_file_creation_naming(
 
     tmpdir.mkdir("osbs").mkdir("repo")
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
@@ -1596,11 +1561,6 @@ def test_osbs_builder_with_fetch_artifacts_url_file_creation_naming_with_target(
 
     tmpdir.mkdir("osbs").mkdir("repo")
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
@@ -1651,11 +1611,6 @@ def test_osbs_builder_with_fetch_artifacts_url_validate_dockerfile(
 
     tmpdir.mkdir("osbs").mkdir("repo")
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
@@ -1714,11 +1669,6 @@ def test_osbs_builder_with_fetch_artifacts_url_file_removal(tmpdir, mocker, capl
         "Some content", "utf-8"
     )
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     run_osbs(image_descriptor, str(tmpdir), mocker, flag=OSBSTestFlags.RM_FETCH_FILE)
 
     assert not os.path.exists(
@@ -1727,6 +1677,202 @@ def test_osbs_builder_with_fetch_artifacts_url_file_removal(tmpdir, mocker, capl
     assert "Removing old 'fetch-artifacts-url.yaml' file" in caplog.text
 
 
+def test_osbs_builder_with_fetch_artifacts_url_file_source_fail(tmpdir, mocker, caplog):
+    """
+    Checks whether the process fails if the source-url is missing checksums.
+    """
+    mocker.patch("cekit.tools.decision", return_value=True)
+    mocker.patch("cekit.tools.urlopen")
+    mocker.patch("cekit.builders.osbs.DistGit.push")
+
+    tmpdir.mkdir("osbs").mkdir("repo")
+
+    res = mocker.Mock()
+    res.getcode.return_value = 200
+    res.read.side_effect = [b"test", None]
+    res.getheader.return_value = 0
+
+    mocker.patch("cekit.tools.urlopen", return_value=res)
+
+    cfgcontents = """
+[common]
+fetch_artifact_domains = https://foo.domain, http://another.domain/path/name
+ssl_verify = False
+    """
+    cfgfile = os.path.join(str(tmpdir), "config")
+    with open(cfgfile, "w") as _file:
+        _file.write(cfgcontents)
+
+    descriptor = copy.deepcopy(image_descriptor)
+
+    descriptor["artifacts"] = [
+        {
+            "name": "artifact_name",
+            "sha256": "123456",
+            "url": "https://foo.domain/bar.jar",
+            "source-url": "https://foo.domain/bar-source.jar",
+        },
+    ]
+
+    run_osbs(descriptor, str(tmpdir), mocker, return_code=1)
+
+    assert "Unable to add source-url for artifact" in caplog.text
+
+
+def test_osbs_builder_with_fetch_artifacts_url_file_source_1(tmpdir, mocker, caplog):
+    """
+    Checks whether the fetch-artifacts-url.yaml file is generated with source-url.
+    """
+
+    caplog.set_level(logging.DEBUG, logger="cekit")
+
+    mocker.patch("cekit.tools.decision", return_value=True)
+    mocker.patch("cekit.tools.urlopen")
+    mocker.patch("cekit.builders.osbs.DistGit.push")
+
+    tmpdir.mkdir("osbs").mkdir("repo")
+
+    res = mocker.Mock()
+    res.getcode.return_value = 200
+    res.read.side_effect = [b"test", None]
+    res.getheader.return_value = 0
+
+    mocker.patch("cekit.tools.urlopen", return_value=res)
+
+    cfgcontents = """
+[common]
+ssl_verify = False
+    """
+    cfgfile = os.path.join(str(tmpdir), "config")
+    with open(cfgfile, "w") as _file:
+        _file.write(cfgcontents)
+
+    descriptor = copy.deepcopy(image_descriptor)
+
+    descriptor["artifacts"] = [
+        {
+            "name": "artifact_name",
+            "sha256": "123456",
+            "url": "https://foo.domain/bar.jar",
+            "source-url": "https://foo.domain/bar-source.jar",
+            "source-sha256": "123",
+        },
+        {
+            "name": "another_artifact_name",
+            "sha256": "654321",
+            "url": "http://another.domain/path/name/bar.jar",
+        },
+    ]
+
+    run_osbs(descriptor, str(tmpdir), mocker)
+
+    with open(
+        os.path.join(str(tmpdir), "target", "image", "fetch-artifacts-url.yaml"), "r"
+    ) as _file:
+        fetch_artifacts = yaml.safe_load(_file)
+
+    assert len(fetch_artifacts) == 2
+    assert fetch_artifacts[0] == {
+        "sha256": "123456",
+        "target": "artifact_name",
+        "url": "https://foo.domain/bar.jar",
+        "source-url": "https://foo.domain/bar-source.jar",
+        "source-sha256": "123",
+    }
+    assert fetch_artifacts[1] == {
+        "sha256": "654321",
+        "target": "another_artifact_name",
+        "url": "http://another.domain/path/name/bar.jar",
+    }
+
+    assert (
+        "Artifact 'artifact_name' (as URL) added to fetch-artifacts-url.yaml"
+        in caplog.text
+    )
+    assert (
+        "Found source-url https://foo.domain/bar-source.jar and checksum markers of ['source-sha256']"
+        in caplog.text
+    )
+
+
+def test_osbs_builder_with_fetch_artifacts_url_file_source_2(tmpdir, mocker, caplog):
+    """
+    Checks whether the fetch-artifacts-url.yaml file is generated with source-url and multiple checksums.
+    """
+
+    caplog.set_level(logging.DEBUG, logger="cekit")
+
+    mocker.patch("cekit.tools.decision", return_value=True)
+    mocker.patch("cekit.tools.urlopen")
+    mocker.patch("cekit.builders.osbs.DistGit.push")
+
+    tmpdir.mkdir("osbs").mkdir("repo")
+
+    res = mocker.Mock()
+    res.getcode.return_value = 200
+    res.read.side_effect = [b"test", None]
+    res.getheader.return_value = 0
+
+    mocker.patch("cekit.tools.urlopen", return_value=res)
+
+    cfgcontents = """
+[common]
+ssl_verify = False
+    """
+    cfgfile = os.path.join(str(tmpdir), "config")
+    with open(cfgfile, "w") as _file:
+        _file.write(cfgcontents)
+
+    descriptor = copy.deepcopy(image_descriptor)
+
+    descriptor["artifacts"] = [
+        {
+            "name": "artifact_name",
+            "sha256": "123456",
+            "url": "https://foo.domain/bar.jar",
+            "source-url": "https://foo.domain/bar-source.jar",
+            "source-sha256": "123",
+            "source-md5": "456",
+        },
+        {
+            "name": "another_artifact_name",
+            "sha256": "654321",
+            "url": "http://another.domain/path/name/bar.jar",
+        },
+    ]
+
+    run_osbs(descriptor, str(tmpdir), mocker)
+
+    with open(
+        os.path.join(str(tmpdir), "target", "image", "fetch-artifacts-url.yaml"), "r"
+    ) as _file:
+        fetch_artifacts = yaml.safe_load(_file)
+
+    assert len(fetch_artifacts) == 2
+    assert fetch_artifacts[0] == {
+        "sha256": "123456",
+        "target": "artifact_name",
+        "url": "https://foo.domain/bar.jar",
+        "source-url": "https://foo.domain/bar-source.jar",
+        "source-sha256": "123",
+        "source-md5": "456",
+    }
+    assert fetch_artifacts[1] == {
+        "sha256": "654321",
+        "target": "another_artifact_name",
+        "url": "http://another.domain/path/name/bar.jar",
+    }
+
+    assert (
+        "Artifact 'artifact_name' (as URL) added to fetch-artifacts-url.yaml"
+        in caplog.text
+    )
+    assert (
+        "Found source-url https://foo.domain/bar-source.jar and checksum markers of ['source-sha256', 'source-md5']"
+        in caplog.text
+    )
+
+
 def test_osbs_builder_with_fetch_artifacts_pnc_file_removal(tmpdir, mocker, caplog):
     """
     Checks whether the fetch-artifacts-pnc.yaml file is removed if exists
@@ -1748,11 +1894,6 @@ def test_osbs_builder_with_fetch_artifacts_pnc_file_removal(tmpdir, mocker, capl
         "Some content", "utf-8"
     )
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-pnc.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     run_osbs(image_descriptor, str(tmpdir), mocker, flag=OSBSTestFlags.RM_FETCH_FILE)
 
     assert not os.path.exists(
@@ -2259,11 +2400,6 @@ def test_osbs_builder_with_fetch_artifacts_pnc_file_creation_1(tmpdir, mocker, c
 
     tmpdir.mkdir("osbs").mkdir("repo")
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-pnc.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
@@ -2296,11 +2432,6 @@ def test_osbs_builder_with_fetch_artifacts_pnc_file_creation_2(tmpdir, mocker, c
 
     tmpdir.mkdir("osbs").mkdir("repo")
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-pnc.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [
@@ -2399,11 +2530,6 @@ def test_osbs_builder_with_brew_and_lookaside(tmpdir, mocker, caplog):
         "Some content", "utf-8"
     )
 
-    with Chdir(os.path.join(str(tmpdir), "osbs", "repo")):
-        subprocess.run(["git", "init"])
-        subprocess.run(["git", "add", "fetch-artifacts-url.yaml"])
-        subprocess.run(["git", "commit", "-m", "Dummy"])
-
     descriptor = copy.deepcopy(image_descriptor)
 
     descriptor["artifacts"] = [{"name": "artifact_name", "sha256": "123456"}]
diff --git a/tests/test_unit_resource.py b/tests/test_unit_resource.py
index ad9aa63..eb26122 100644
--- a/tests/test_unit_resource.py
+++ b/tests/test_unit_resource.py
@@ -230,7 +230,7 @@ def test_resource_verify(mocker):
     mock = mocker.patch("cekit.descriptor.resource.check_sum")
     res = create_resource({"url": "dummy", "sha256": "justamocksum"})
     res._Resource__verify("dummy")
-    mock.assert_called_with("dummy", "sha256", "justamocksum", "dummy")
+    mock.assert_called_with("dummy", "sha256", "justamocksum")
 
 
 def test_generated_url_with_cacher():