From f46eef7df9e350d40f616acb855fbd6e8c76db02 Mon Sep 17 00:00:00 2001 From: soksanichenko Date: Tue, 21 Jun 2022 09:59:43 +0300 Subject: [PATCH] ALBS-443: Integrate CodeNotary with git updater tool - Additional metadata for notarizing --- cas_wrapper.py | 53 ++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/cas_wrapper.py b/cas_wrapper.py index 8cb648b..f58f303 100644 --- a/cas_wrapper.py +++ b/cas_wrapper.py @@ -30,38 +30,20 @@ class CasWrapper: self._cas = local['cas'] self._cas['login']() - def notarize(self, local_git_repo_path: str) -> str: + def notarize( + self, + local_path: str, + metadata: Dict = None, + ) -> str: """ Wrapper around `cas notarize` - :param local_git_repo_path: path to a local Git repo + :param local_path: path to a local Git repo + :param metadata: additional metadata :return: hash of notarized commit :rtype: str """ command = self._cas[ 'notarize', - local_git_repo_path, - '-o', - 'json', - ] - result_of_execution = command() - return json.loads(result_of_execution)['hash'] - - def authenticate( - self, - local_path: str, - metadata: Dict = None, - ): - """ - Wrapper around `cas authenticate` - :param local_path: path to a local Git repo - (should be started from `git://`) - or to a single local file - :param metadata: additional metadata - :return: true if a commit is trusted, vice versa - false - :rtype: bool - """ - command = self._cas[ - 'authenticate', local_path, '-o', 'json', @@ -72,6 +54,27 @@ class CasWrapper: '-a', f'{key}={value}', ] + result_of_execution = command() + return json.loads(result_of_execution)['hash'] + + def authenticate( + self, + local_path: str, + ): + """ + Wrapper around `cas authenticate` + :param local_path: path to a local Git repo + (should be started from `git://`) + or to a single local file + :return: true if a commit is trusted, vice versa - false + :rtype: bool + """ + command = self._cas[ + 'authenticate', + local_path, + '-o', + 'json', + ] try: result_of_execution = command() except ProcessExecutionError: