diff mbox series

tests/functional: Fix hash validation

Message ID 20241004130225.217441-1-thuth@redhat.com (mailing list archive)
State New, archived
Headers show
Series tests/functional: Fix hash validation | expand

Commit Message

Thomas Huth Oct. 4, 2024, 1:02 p.m. UTC
The _check() function is supposed to check whether the hash of the
downloaded file matches the expected one. Unfortunately, during the
last rework of this function, the check was accidentally turned into
returning the hash value itself instead of a True/False value,
effectively accepting each hash as valid. Let's do a proper check
again now.

Fixes:05e303210d ("tests/functional/qemu_test: Use Python hashlib ...")
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/qemu_test/asset.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Manos Pitsidianakis Oct. 4, 2024, 5:53 p.m. UTC | #1
On Fri, 04 Oct 2024 16:02, Thomas Huth <thuth@redhat.com> wrote:
>The _check() function is supposed to check whether the hash of the
>downloaded file matches the expected one. Unfortunately, during the
>last rework of this function, the check was accidentally turned into
>returning the hash value itself instead of a True/False value,
>effectively accepting each hash as valid. Let's do a proper check
>again now.
>
>Fixes:05e303210d ("tests/functional/qemu_test: Use Python hashlib ...")
>Signed-off-by: Thomas Huth <thuth@redhat.com>
>---
> tests/functional/qemu_test/asset.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
>index 3ec429217e..e47bfac035 100644
>--- a/tests/functional/qemu_test/asset.py
>+++ b/tests/functional/qemu_test/asset.py
>@@ -57,7 +57,7 @@ def _check(self, cache_file):
>                     break
>                 hl.update(chunk)
> 
>-        return  hl.hexdigest()
>+        return self.hash == hl.hexdigest()
> 
>     def valid(self):
>         return self.cache_file.exists() and self._check(self.cache_file)
>-- 
>2.46.1
>
>

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
diff mbox series

Patch

diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index 3ec429217e..e47bfac035 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -57,7 +57,7 @@  def _check(self, cache_file):
                     break
                 hl.update(chunk)
 
-        return  hl.hexdigest()
+        return self.hash == hl.hexdigest()
 
     def valid(self):
         return self.cache_file.exists() and self._check(self.cache_file)