Skip to content

Commit

Permalink
Support authentication using Token #26
Browse files Browse the repository at this point in the history
  • Loading branch information
gabryelreyes committed Oct 10, 2024
1 parent 79d1890 commit 7f9b3e1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/pyPolarionCli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ def add_parser() -> argparse.ArgumentParser:
'--password',
type=str,
metavar='<password>',
required=True,
help="The password to authenticate with the Polarion server.")
required=False,
help="The password to authenticate with the Polarion server. Is ignored if a token is defined using -t option.")

required_arguments.add_argument('-t',
'--token',
type=str,
metavar='<token>',
required=False,
help="The token to authenticate with the Polarion server.")

required_arguments.add_argument('-s',
'--server',
Expand Down Expand Up @@ -145,6 +152,9 @@ def main() -> Ret:
if args is None:
ret_status = Ret.ERROR_ARGPARSE
parser.print_help()
elif (args.password is None) and (args.token is None):
ret_status = Ret.ERROR_INVALID_ARGUMENTS
LOG.error("Missing password or token!")
else:
# If the verbose flag is set, change the default logging level.
if args.verbose:
Expand All @@ -159,6 +169,7 @@ def main() -> Ret:
client = Polarion(polarion_url=args.server,
user=args.user,
password=args.password,
token=args.token,
verify_certificate=False,
static_service_list=True)
except Exception as e: # pylint: disable=broad-exception-caught
Expand Down

0 comments on commit 7f9b3e1

Please sign in to comment.