From e804dbd48ee59566e9a7211ad20805847a075f43 Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 12 Nov 2024 15:30:07 -0600 Subject: [PATCH] PM-14851: Blank names should be considered null (#4292) --- .../auth/repository/AuthRepositoryImpl.kt | 2 +- .../auth/repository/AuthRepositoryTest.kt | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt index bc76f5131..5501bb0de 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt @@ -1302,7 +1302,7 @@ class AuthRepositoryImpl( .sendVerificationEmail( SendVerificationEmailRequestJson( email = email, - name = name, + name = name.takeUnless { it.isBlank() }, receiveMarketingEmails = receiveMarketingEmails, ), ) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt index 944138f6e..72b32e01f 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt @@ -6111,6 +6111,29 @@ class AuthRepositoryTest { ) } + @Test + fun `sendVerificationEmail with empty name should use null and return success`() = runTest { + coEvery { + identityService.sendVerificationEmail( + SendVerificationEmailRequestJson( + email = EMAIL, + name = null, + receiveMarketingEmails = true, + ), + ) + } returns EMAIL_VERIFICATION_TOKEN.asSuccess() + + val result = repository.sendVerificationEmail( + email = EMAIL, + name = "", + receiveMarketingEmails = true, + ) + assertEquals( + SendVerificationEmailResult.Success(EMAIL_VERIFICATION_TOKEN), + result, + ) + } + @Test fun `sendVerificationEmail failure should return error`() = runTest { coEvery {