Skip to content

feat: Add clearAll() API to credentials manager#951

Open
pmathew92 wants to merge 3 commits intov4_developmentfrom
SDK-8576
Open

feat: Add clearAll() API to credentials manager#951
pmathew92 wants to merge 3 commits intov4_developmentfrom
SDK-8576

Conversation

@pmathew92
Copy link
Copy Markdown
Contributor

Changes

Adds a new clearAll() method to BaseCredentialsManager , CredentialsManager, and SecureCredentialsManager that performs a complete cleanup of all stored credentials and cryptographic key pairs.

Testing

Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. Since this library has unit testing, tests should be added for new functionality and existing tests should complete without errors.

  • This change adds unit test coverage

  • This change adds integration test coverage

  • This change has been tested on the latest version of the platform/language or why not

Checklist

@pmathew92 pmathew92 requested a review from a team as a code owner April 15, 2026 06:32
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the test name says "AndDPoPKeyPair" but we're only verifying storage.removeAll() here. If someone accidentally removes the DPoP.clearKeyPair() call from the implementation, this test would still pass. Can we add a verify for the DPoP cleanup too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The name is misleading. We can't directly verify the DPoP.clearKeyPair() as Mockito can't validate the call for Kotlin static calls. Hence didn't add that check

}

@Test
public fun shouldClearAllCredentialsKeyPairsAndDPoPKeyPair() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the test name mentions "AndDPoPKeyPair" but we're not verifying DPoP.clearKeyPair() was called. Also missing a verify for clearBiometricSession(). Would be good to cover both so the test actually validates everything the method does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The name is misleading. We can't directly verify the DPoP.clearKeyPair() as Mockito can't validate the call for Kotlin static calls. Hence didn't add that check

*/
override fun clearAll() {
storage.removeAll()
crypto.deleteAllKeys()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small thought — if crypto.deleteAllKeys() throws something unexpected, then clearBiometricSession() and DPoP.clearKeyPair() get skipped. Since this is a "clean up everything" method,can we wrap each step independently so one failure doesn't prevent the others from running?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

CryptoUtils , deleteAllKeys internally calls the existing deleteRSAKeys and deleteAESKeys method which internally handles if any exception being thrown. So any failure here wouldn't affect the other APIs

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.

3 participants