Skip to content

test(node): add unit tests for change password and delete user - #4851

Merged
hubcio merged 4 commits into
apache:masterfrom
Yasas-Sri:test/node-change-password-delete-user
Nov 15, 2026
Merged

hubcio merged 4 commits into
apache:masterfrom
Yasas-Sri:test/node-change-password-delete-user

Conversation

@Yasas-Sri

@Yasas-Sri Yasas-Sri commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR address?

Closes #4796

Rationale

CHANGE_PASSWORD.serialize and DELETE_USER.serialize had no unit tests. client.socket.test.ts calls them through a mock server but never checks the bytes they produce.

What changed?

There was no test that checked the wire bytes or the 1-255 byte password limit for these two commands.

Added change-password.command.test.ts and delete-user.command.test.ts, following create-user.command.test.ts. They check the exact bytes for a numeric user id and both passwords, a 255-byte password being accepted, empty and 256-byte passwords being refused, and a multi-byte password (132 characters, 264 bytes) being refused. For delete user, they check the exact bytes for a numeric and a string identifier. Expected buffers are built by hand. The throw tests match the length check's error message, because a plain assert.throws would also pass on the RangeError that uint8ToBuf throws for a length above 255, even if the length check itself were broken.

Local Execution

  • Passed: npm run test:unit and npm run lint in foreign/node
  • Pre-commit hooks ran / not ran

AI Usage

  1. Claude opus 5.5.
  2. I wrote the tests. I used Claude to review them. also used to draft the pr description
  3. I ran npm run test:unit and npm run lint.
  4. Can you explain every line of the code if asked? Yes.

Team review

Ran /team-review 4851 at 07f093b. Verdict: APPROVE.

  • [nit] change-password.command.test.ts:86 - UTF-8 limit was tested only for newPassword. Fixed in b160209: added the same case for currentPassword.
  • [nit] change-password.command.test.ts:59 - 255-byte case sets both passwords at once. Kept, as the review suggests: the full-buffer deepEqual checks both.
  • [warning, pre-existing] change-password.command.ts:30 - userId accepts only a number, while other user commands accept Id. Not changed here, because it is outside this PR's scope.
  • [nit, pre-existing] delete-user.command.test.ts:26 - identifier error path not tested here. Not changed, because identifier.utils.test.ts already covers it.

@github-actions

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

If AI assistance was used to create this PR, you are required to run the team-review skill before opening it.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer
  • /pin - exempt the PR from the stale bot, /unpin to undo

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Nov 11, 2026
@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.29%. Comparing base (c1fc441) to head (07f093b).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #4851   +/-   ##
=========================================
  Coverage     91.29%   91.29%           
  Complexity     4204     4204           
=========================================
  Files          1458     1458           
  Lines        340825   340825           
  Branches     272619   272618    -1     
=========================================
+ Hits         311170   311173    +3     
+ Misses        23439    23436    -3     
  Partials       6216     6216           
Components Coverage Δ
Rust Core 93.06% <ø> (ø)
Java SDK 80.54% <ø> (ø)
C# SDK 80.06% <ø> (ø)
Python SDK 86.63% <ø> (ø)
PHP SDK 92.26% <ø> (ø)
Node SDK 97.08% <ø> (+0.01%) ⬆️
Go SDK 73.38% <ø> (ø)
C++ SDK 86.77% <ø> (ø)
see 2 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@justinmclean

Copy link
Copy Markdown
Member

Thanks @Yasas-Sri, and welcome. The multi-byte password test is a good catch, since it fails if the check counts characters instead of bytes. As the bot notes, PRs that used AI need a team-review run, so could you add its result to the description?

@Yasas-Sri

Yasas-Sri commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

sorry for that late reply. i ran team-review (verdict: APPROVE), added the result to the description, and added the missing UTF-8 test for the current password.

@hubcio

hubcio commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

/skill team-review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary: The two new Node unit test files for change-password and delete-user assert wire bytes that match the command serializers, the identifier helper, and the Rust binary protocol. The UTF-8 rejection cases reach the byte-length checks, CI reports 25 checks as success and Node is not among the skipped checks, and the pre-existing ChangePassword.userId type narrowing stays outside this test-only diff.


This review was generated by Claude Code 2.1.310 on deepseek-flash[1m]. Review the output before you act on it.

@hubcio
hubcio merged commit 3a88a17 into apache:master Nov 15, 2026
39 checks passed
@github-actions github-actions Bot removed the S-waiting-on-review PR is waiting on a reviewer label Nov 15, 2026
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.

Node SDK: add unit tests for the change password and delete user commands

4 participants