Skip to content

Update smartcam credential handling and tests#1664

Open
ZeliardM wants to merge 5 commits intopython-kasa:masterfrom
ZeliardM:feature/smartcam-update-credentials
Open

Update smartcam credential handling and tests#1664
ZeliardM wants to merge 5 commits intopython-kasa:masterfrom
ZeliardM:feature/smartcam-update-credentials

Conversation

@ZeliardM
Copy link
Contributor

@ZeliardM ZeliardM commented Mar 1, 2026

This PR adds update_admin_password in the library and CLI for SMARTCAM devices. It also updates the update_credentials function to correctly handle the local_account for local device authentication. It updates all of the required tests and code coverage as well.

Copilot AI review requested due to automatic review settings March 1, 2026 03:44
@ZeliardM
Copy link
Contributor Author

ZeliardM commented Mar 1, 2026

This should replace PR #1661, working with the user on this PR before they created their own.

@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

❌ Patch coverage is 94.87179% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.22%. Comparing base (be5ce08) to head (7296975).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
kasa/smartcam/smartcamdevice.py 94.87% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1664   +/-   ##
=======================================
  Coverage   93.22%   93.22%           
=======================================
  Files         157      157           
  Lines        9815     9847   +32     
  Branches     1003     1009    +6     
=======================================
+ Hits         9150     9180   +30     
- Misses        472      473    +1     
- Partials      193      194    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for updating SMARTCAM admin password (library + CLI) and corrects SMARTCAM local credential updates to target the proper local account identity, with expanded test coverage to validate request payloads and fallback behavior.

Changes:

  • Add SmartCamDevice.update_admin_password() plus shared password encryption/hash helpers.
  • Update SmartCamDevice.update_credentials() to use secname="local_account" and improved old-password fallback handling.
  • Add CLI update_admin_password command and extend smartcam/CLI tests for new/updated behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
kasa/smartcam/smartcamdevice.py Adds admin password update API, refactors RSA encryption into _encrypt_password, and updates credential update request construction/fallbacks.
kasa/cli/device.py Adds device update-admin-password command (implemented as update_admin_password).
kasa/cli/main.py Exposes update_admin_password as a top-level runnable device command via lazy subcommand mapping.
tests/test_cli.py Adds CLI test covering confirmation prompt + invocation of update_admin_password.
tests/smartcam/test_smartcamdevice.py Adds extensive unit tests validating request payloads for LV2/LV3 and fallback behavior for both admin password and credentials updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants