diff --git a/newsfragments/1484.change.rst b/newsfragments/1484.change.rst new file mode 100644 index 00000000..53c3074a --- /dev/null +++ b/newsfragments/1484.change.rst @@ -0,0 +1,2 @@ +Add a ``delete-model-target-web-api-credentials`` command, which deletes +one Model Target Web API OAuth2 client credential by its client ID. diff --git a/spelling_private_dict.txt b/spelling_private_dict.txt index efa04480..2359f4ea 100644 --- a/spelling_private_dict.txt +++ b/spelling_private_dict.txt @@ -2,6 +2,7 @@ DOM OAuth SVG XPath +api beartype changelog cli diff --git a/src/vws_web_tools/__init__.py b/src/vws_web_tools/__init__.py index 6c9e88c7..63563601 100644 --- a/src/vws_web_tools/__init__.py +++ b/src/vws_web_tools/__init__.py @@ -1706,6 +1706,33 @@ def show_vumark_database_details( click.echo(message=yaml.dump(data=details), nl=False) +@click.command(name="delete-model-target-web-api-credentials") +@click.option("--client-id", required=True) +@click.option("--email-address", envvar="VWS_EMAIL_ADDRESS", required=True) +@click.option("--password", envvar="VWS_PASSWORD", required=True) +@beartype +def delete_model_target_web_api_credentials( + *, + client_id: str, + email_address: str, + password: str, +) -> None: + """Delete one Model Target Web API client credential.""" + driver = create_chrome_driver() + try: + log_in( + driver=driver, + email_address=email_address, + password=password, + ) + delete_model_target_web_api_client_credentials( + driver=driver, + client_id=client_id, + ) + finally: + driver.quit() + + @click.command() @click.option("--license-name", required=True) @click.option("--email-address", envvar="VWS_EMAIL_ADDRESS", required=True) @@ -1747,6 +1774,7 @@ def show_license_details( vws_web_tools_group.add_command(cmd=create_vws_cloud_database) vws_web_tools_group.add_command(cmd=create_vws_license) vws_web_tools_group.add_command(cmd=create_vws_vumark_database) +vws_web_tools_group.add_command(cmd=delete_model_target_web_api_credentials) vws_web_tools_group.add_command(cmd=delete_vws_license) vws_web_tools_group.add_command(cmd=get_vumark_instance_id) vws_web_tools_group.add_command(cmd=show_database_details) diff --git a/tests/test_create_database.py b/tests/test_create_database.py index 3c95f5e4..22e75daf 100644 --- a/tests/test_create_database.py +++ b/tests/test_create_database.py @@ -546,6 +546,34 @@ def test_get_model_target_web_api_details_library( ) +def test_delete_model_target_web_api_credentials_cli( + *, + vws_credentials: VWSCredentials, + logged_in_chrome_driver: WebDriver, +) -> None: + """Test deleting Model Target Web API credentials via the CLI.""" + details = vws_web_tools.get_model_target_web_api_details( + driver=logged_in_chrome_driver, + ) + + runner = CliRunner() + result = runner.invoke( + cli=vws_web_tools_group, + args=[ + "delete-model-target-web-api-credentials", + "--client-id", + details["client_id"], + "--email-address", + vws_credentials.email_address, + "--password", + vws_credentials.password, + ], + catch_exceptions=False, + ) + + assert result.exit_code == 0 + + def test_show_license_details_cli( *, vws_credentials: VWSCredentials, diff --git a/tests/test_help/test_vws_command_help____.txt b/tests/test_help/test_vws_command_help____.txt index b0a28438..e67ff653 100644 --- a/tests/test_help/test_vws_command_help____.txt +++ b/tests/test_help/test_vws_command_help____.txt @@ -6,13 +6,15 @@ Options: --help Show this message and exit. Commands: - create-vws-cloud-database Create a cloud database. - create-vws-license Create a license. - create-vws-vumark-database Create a VuMark database. - delete-vws-license Delete a license. - get-vumark-instance-id Get the VuMark instance ID for a target. - show-database-details Show the details of a database. - show-license-details Show the details of a license. - show-vumark-database-details Show the details of a VuMark database. - upload-vumark-template Upload a VuMark SVG template to a VuMark... - wait-for-vumark-instance-id Wait for and get the VuMark instance ID for... + create-vws-cloud-database Create a cloud database. + create-vws-license Create a license. + create-vws-vumark-database Create a VuMark database. + delete-model-target-web-api-credentials + Delete one Model Target Web API... + delete-vws-license Delete a license. + get-vumark-instance-id Get the VuMark instance ID for a... + show-database-details Show the details of a database. + show-license-details Show the details of a license. + show-vumark-database-details Show the details of a VuMark... + upload-vumark-template Upload a VuMark SVG template to... + wait-for-vumark-instance-id Wait for and get the VuMark... diff --git a/tests/test_help/test_vws_command_help___delete_model_target_web_api_credentials___.txt b/tests/test_help/test_vws_command_help___delete_model_target_web_api_credentials___.txt new file mode 100644 index 00000000..d08736fc --- /dev/null +++ b/tests/test_help/test_vws_command_help___delete_model_target_web_api_credentials___.txt @@ -0,0 +1,9 @@ +Usage: vws-web delete-model-target-web-api-credentials [OPTIONS] + + Delete one Model Target Web API client credential. + +Options: + --client-id TEXT [required] + --email-address TEXT [required] + --password TEXT [required] + --help Show this message and exit.