Skip to content

Commit

Permalink
Add check based on text
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <[email protected]>
  • Loading branch information
gaiksaya committed Aug 17, 2023
1 parent 67238cb commit aaeaa69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/sign_workflow/signer_jar.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ def sign(self, artifact: str, basepath: Path, signature_type: str) -> None:

def verify(self, filename: str) -> None:
verify_cmd = ["jarsigner", "-verify", filename, "-verbose", "-certs", "-strict"]
self.git_repo.execute(" ".join(verify_cmd))
signature = self.git_repo.output(" ".join(verify_cmd))
if signature.find('jar verified') == -1:
raise ValueError(f"Cannot verify the signature for {filename}")


6 changes: 3 additions & 3 deletions tests/tests_sign_workflow/test_signer_jar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import unittest
from pathlib import Path
from unittest.mock import MagicMock, Mock, call, patch

from git.git_repository import GitRepository
from sign_workflow.signer_jar import SignerJar


Expand Down Expand Up @@ -57,5 +57,5 @@ def test_sign_command_for_overwrite(self, mock_repo: Mock) -> None:
@patch("sign_workflow.signer.GitRepository")
def test_signer_verify(self, mock_repo: Mock) -> None:
signer = SignerJar(True)
signer.verify("/path/the-jar.jar")
mock_repo.assert_has_calls([call().execute("jarsigner -verify /path/the-jar.jar -verbose -certs -strict")])
signer.verify('/path/the-jar.jar')
mock_repo.assert_has_calls([call().output("jarsigner -verify /path/the-jar.jar -verbose -certs -strict")])

0 comments on commit aaeaa69

Please sign in to comment.