Skip to content

BUGFIX/update-profile-option-checking #390

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

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/userguides/profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ time you run a command.

Once you've generated an API Client in your Code42 console, use the following command to create your profile with API client authentication:
```bash
code42 profile create-api-client --name MY_API_CLIENT_PROFILE --server example.authority.com --api-client-id "key-42" --secret "code42%api%client%secret"
code42 profile create-api-client --name MY_API_CLIENT_PROFILE --server example.authority.com --api-client-id 'key-42' --secret 'code42%api%client%secret'
```

```{eval-rst}
Expand Down
42 changes: 20 additions & 22 deletions src/code42cli/cmds/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,31 @@ def update(
"""Update an existing profile."""
c42profile = cliprofile.get_profile(name)

if c42profile.api_client_auth == "True":
if not any(
[
server,
api_client_id,
secret,
disable_ssl_errors is not None,
use_v2_file_events is not None,
]
):
if not any(
[
server,
api_client_id,
secret,
username,
password,
disable_ssl_errors is not None,
use_v2_file_events is not None,
]
):
if c42profile.api_client_auth == "True":
raise click.UsageError(
"Must provide at least one of `--server`, `--api-client-id`, `--secret`, `--use-v2-file-events` or "
"`--disable-ssl-errors` when updating an API client profile. "
"Provide both `--username` and `--password` options to switch this profile to username/password authentication."
)
else:
raise click.UsageError(
"Must provide at least one of `--server`, `--username`, `--password`, `--use-v2-file-events` or "
"`--disable-ssl-errors` when updating a username/password authenticated profile. "
"Provide both `--api-client-id` and `--secret` options to switch this profile to Code42 API client authentication."
)

if c42profile.api_client_auth == "True":
if (username and not password) or (password and not username):
raise click.UsageError(
"This profile currently uses API client authentication. "
Expand Down Expand Up @@ -277,18 +287,6 @@ def update(
_set_pw(c42profile.name, secret, debug, api_client=True)

else:
if (
not server
and not username
and not password
and disable_ssl_errors is None
and use_v2_file_events is None
):
raise click.UsageError(
"Must provide at least one of `--server`, `--username`, `--password`, `--use-v2-file-events` or "
"`--disable-ssl-errors` when updating a username/password authenticated profile. "
"Provide both `--api-client-id` and `--secret` options to switch this profile to Code42 API client authentication."
)
if (api_client_id and not secret) or (api_client_id and not secret):
raise click.UsageError(
"This profile currently uses username/password authentication. "
Expand Down