Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support authentication using Token #26 #27

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/pyPolarionCli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,16 @@ 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 +153,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 +170,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