From adebb6058d45305cd71f74e22412028bbd26d9fa Mon Sep 17 00:00:00 2001 From: Jordan Haven Date: Wed, 17 Apr 2024 11:08:18 -0400 Subject: [PATCH 1/6] Add some more keep annotations --- .../java/com/stytch/sdk/b2b/network/models/B2BResponseData.kt | 1 + .../stytch/sdk/common/network/models/CommonResponseData.kt | 3 +++ .../com/stytch/sdk/consumer/network/models/ResponseData.kt | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/sdk/src/main/java/com/stytch/sdk/b2b/network/models/B2BResponseData.kt b/sdk/src/main/java/com/stytch/sdk/b2b/network/models/B2BResponseData.kt index ebc7e2a09..fc7356a60 100644 --- a/sdk/src/main/java/com/stytch/sdk/b2b/network/models/B2BResponseData.kt +++ b/sdk/src/main/java/com/stytch/sdk/b2b/network/models/B2BResponseData.kt @@ -9,6 +9,7 @@ import com.stytch.sdk.common.network.models.CommonAuthenticationData import kotlinx.parcelize.Parcelize import kotlinx.parcelize.RawValue +@Keep public interface IB2BAuthData : CommonAuthenticationData { public val memberSession: B2BSessionData public override val sessionJwt: String diff --git a/sdk/src/main/java/com/stytch/sdk/common/network/models/CommonResponseData.kt b/sdk/src/main/java/com/stytch/sdk/common/network/models/CommonResponseData.kt index d893dbd57..9ac3e907d 100644 --- a/sdk/src/main/java/com/stytch/sdk/common/network/models/CommonResponseData.kt +++ b/sdk/src/main/java/com/stytch/sdk/common/network/models/CommonResponseData.kt @@ -336,6 +336,7 @@ public data class AuthenticationFactor( ) : Parcelable } +@Keep public interface CommonAuthenticationData { public val sessionJwt: String public val sessionToken: String @@ -383,6 +384,8 @@ public data class PasswordConfig( val ludsMinimumCount: Int, ) : Parcelable +@Keep +@JsonClass(generateAdapter = false) public enum class DFPProtectedAuthMode { OBSERVATION, DECISIONING, diff --git a/sdk/src/main/java/com/stytch/sdk/consumer/network/models/ResponseData.kt b/sdk/src/main/java/com/stytch/sdk/consumer/network/models/ResponseData.kt index 9d6e49e05..8acd925b8 100644 --- a/sdk/src/main/java/com/stytch/sdk/consumer/network/models/ResponseData.kt +++ b/sdk/src/main/java/com/stytch/sdk/consumer/network/models/ResponseData.kt @@ -18,6 +18,7 @@ import com.stytch.sdk.common.network.models.WebAuthNRegistrations import kotlinx.parcelize.Parcelize import kotlinx.parcelize.RawValue +@Keep public interface IAuthData : CommonAuthenticationData { public val session: SessionData public override val sessionJwt: String @@ -25,6 +26,7 @@ public interface IAuthData : CommonAuthenticationData { public val user: UserData } +@Keep public interface INativeOAuthData : IAuthData { public val userCreated: Boolean } @@ -258,6 +260,7 @@ public data class StrengthCheckResponse( val strengthPolicy: StrengthPolicy, ) : Parcelable +@Keep @JsonClass(generateAdapter = false) public enum class StrengthPolicy { @Json(name = "zxcvbn") @@ -285,6 +288,7 @@ public data class UserSearchResponseData( val userType: UserType, ) : Parcelable +@Keep @JsonClass(generateAdapter = false) @Parcelize public enum class UserType : Parcelable { From b470f04895af9a57477eaa9d8063005c5fcca6e9 Mon Sep 17 00:00:00 2001 From: Jordan Haven Date: Wed, 17 Apr 2024 16:19:39 -0400 Subject: [PATCH 2/6] Add test logging to see why things are so flaky on GitHub --- sdk/build.gradle | 10 ++++++++++ ui/build.gradle | 10 ++++++++++ uiworkbench/build.gradle | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/sdk/build.gradle b/sdk/build.gradle index 5dc38aa3c..df7475920 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -1,3 +1,5 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + plugins { id 'com.android.library' id 'kotlin-android' @@ -146,3 +148,11 @@ dependencies { testImplementation("com.squareup.okhttp3:mockwebserver:4.11.0") testImplementation("org.json:json:20230227") } + +tasks.withType(Test).configureEach { + testLogging { + exceptionFormat = TestExceptionFormat.FULL + showStackTraces = true + showStandardStreams = true + } +} \ No newline at end of file diff --git a/ui/build.gradle b/ui/build.gradle index acdf1d2c9..2e7e9d429 100644 --- a/ui/build.gradle +++ b/ui/build.gradle @@ -1,3 +1,5 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' @@ -131,3 +133,11 @@ tasks.named("dokkaHtmlPartial").configure { */ } } + +tasks.withType(Test).configureEach { + testLogging { + exceptionFormat = TestExceptionFormat.FULL + showStackTraces = true + showStandardStreams = true + } +} \ No newline at end of file diff --git a/uiworkbench/build.gradle b/uiworkbench/build.gradle index e65f904a4..ddb5bedba 100644 --- a/uiworkbench/build.gradle +++ b/uiworkbench/build.gradle @@ -1,3 +1,5 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' @@ -78,4 +80,12 @@ dependencies { androidTestImplementation 'androidx.compose.ui:ui-test-junit4' debugImplementation 'androidx.compose.ui:ui-tooling' debugImplementation 'androidx.compose.ui:ui-test-manifest' +} + +tasks.withType(Test).configureEach { + testLogging { + exceptionFormat = TestExceptionFormat.FULL + showStackTraces = true + showStandardStreams = true + } } \ No newline at end of file From dcf75a4d2a31f77ec01107bbf4a8cbb6e6b1b054 Mon Sep 17 00:00:00 2001 From: Jordan Haven Date: Wed, 17 Apr 2024 16:46:26 -0400 Subject: [PATCH 3/6] remove unnecessary logging from uiworkbench; ensure not using mocks in matchers --- sdk/build.gradle | 1 - .../stytch/sdk/b2b/network/StytchB2BApiTest.kt | 2 +- .../sdk/consumer/network/StytchApiTest.kt | 18 +++++++++--------- ui/build.gradle | 1 - uiworkbench/build.gradle | 8 -------- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index df7475920..05b516f29 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -153,6 +153,5 @@ tasks.withType(Test).configureEach { testLogging { exceptionFormat = TestExceptionFormat.FULL showStackTraces = true - showStandardStreams = true } } \ No newline at end of file diff --git a/sdk/src/test/java/com/stytch/sdk/b2b/network/StytchB2BApiTest.kt b/sdk/src/test/java/com/stytch/sdk/b2b/network/StytchB2BApiTest.kt index e7bcffabe..727e9349a 100644 --- a/sdk/src/test/java/com/stytch/sdk/b2b/network/StytchB2BApiTest.kt +++ b/sdk/src/test/java/com/stytch/sdk/b2b/network/StytchB2BApiTest.kt @@ -284,7 +284,7 @@ internal class StytchB2BApiTest { fun `StytchB2BApi Bootstrap getBootstrapData calls appropriate apiService method`() = runTest { every { StytchB2BApi.isInitialized } returns true every { StytchB2BApi.publicToken } returns "mock-public-token" - coEvery { StytchB2BApi.apiService.getBootstrapData("mock-public-token") } returns mockk(relaxed = true) + coEvery { StytchB2BApi.apiService.getBootstrapData(any()) } returns mockk(relaxed = true) StytchB2BApi.getBootstrapData() coVerify { StytchB2BApi.apiService.getBootstrapData("mock-public-token") } } diff --git a/sdk/src/test/java/com/stytch/sdk/consumer/network/StytchApiTest.kt b/sdk/src/test/java/com/stytch/sdk/consumer/network/StytchApiTest.kt index 05cffdb26..db1bf2293 100644 --- a/sdk/src/test/java/com/stytch/sdk/consumer/network/StytchApiTest.kt +++ b/sdk/src/test/java/com/stytch/sdk/consumer/network/StytchApiTest.kt @@ -304,7 +304,7 @@ internal class StytchApiTest { @Test fun `StytchApi User deleteEmailById calls appropriate apiService method`() = runTest { every { StytchApi.isInitialized } returns true - coEvery { StytchApi.apiService.deleteEmailById("emailAddressId") } returns mockk(relaxed = true) + coEvery { StytchApi.apiService.deleteEmailById(any()) } returns mockk(relaxed = true) StytchApi.UserManagement.deleteEmailById("emailAddressId") coVerify { StytchApi.apiService.deleteEmailById("emailAddressId") } } @@ -312,7 +312,7 @@ internal class StytchApiTest { @Test fun `StytchApi User deletePhoneNumberById calls appropriate apiService method`() = runTest { every { StytchApi.isInitialized } returns true - coEvery { StytchApi.apiService.deletePhoneNumberById("phoneNumberId") } returns mockk(relaxed = true) + coEvery { StytchApi.apiService.deletePhoneNumberById(any()) } returns mockk(relaxed = true) StytchApi.UserManagement.deletePhoneNumberById("phoneNumberId") coVerify { StytchApi.apiService.deletePhoneNumberById("phoneNumberId") } } @@ -321,7 +321,7 @@ internal class StytchApiTest { fun `StytchApi User deleteBiometricRegistrationById calls appropriate apiService method`() = runTest { every { StytchApi.isInitialized } returns true coEvery { - StytchApi.apiService.deleteBiometricRegistrationById("biometricsRegistrationId") + StytchApi.apiService.deleteBiometricRegistrationById(any()) } returns mockk(relaxed = true) StytchApi.UserManagement.deleteBiometricRegistrationById("biometricsRegistrationId") coVerify { StytchApi.apiService.deleteBiometricRegistrationById("biometricsRegistrationId") } @@ -379,7 +379,7 @@ internal class StytchApiTest { fun `StytchApi Bootstrap getBootstrapData calls appropriate apiService method`() = runTest { every { StytchApi.isInitialized } returns true every { StytchApi.publicToken } returns "mock-public-token" - coEvery { StytchApi.apiService.getBootstrapData("mock-public-token") } returns mockk(relaxed = true) + coEvery { StytchApi.apiService.getBootstrapData(any()) } returns mockk(relaxed = true) StytchApi.getBootstrapData() coVerify { StytchApi.apiService.getBootstrapData("mock-public-token") } } @@ -401,7 +401,7 @@ internal class StytchApiTest { @Test fun `StytchApi Webauthn registerStart calls appropriate apiService method`() = runTest { every { StytchApi.isInitialized } returns true - coEvery { StytchApi.apiService.webAuthnRegisterStart(mockk(relaxed = true)) } returns mockk(relaxed = true) + coEvery { StytchApi.apiService.webAuthnRegisterStart(any()) } returns mockk(relaxed = true) StytchApi.WebAuthn.registerStart("") coVerify { StytchApi.apiService.webAuthnRegisterStart(any()) } } @@ -409,7 +409,7 @@ internal class StytchApiTest { @Test fun `StytchApi Webauthn register calls appropriate apiService method`() = runTest { every { StytchApi.isInitialized } returns true - coEvery { StytchApi.apiService.webAuthnRegister(mockk(relaxed = true)) } returns mockk(relaxed = true) + coEvery { StytchApi.apiService.webAuthnRegister(any()) } returns mockk(relaxed = true) StytchApi.WebAuthn.register("") coVerify { StytchApi.apiService.webAuthnRegister(any()) } } @@ -418,7 +418,7 @@ internal class StytchApiTest { fun `StytchApi Webauthn webAuthnAuthenticateStartPrimary calls appropriate apiService method`() = runTest { every { StytchApi.isInitialized } returns true coEvery { - StytchApi.apiService.webAuthnAuthenticateStartPrimary(mockk(relaxed = true)) + StytchApi.apiService.webAuthnAuthenticateStartPrimary(any()) } returns mockk(relaxed = true) StytchApi.WebAuthn.authenticateStartPrimary("", false) coVerify { StytchApi.apiService.webAuthnAuthenticateStartPrimary(any()) } @@ -428,7 +428,7 @@ internal class StytchApiTest { fun `StytchApi Webauthn webAuthnAuthenticateStartSecondary calls appropriate apiService method`() = runTest { every { StytchApi.isInitialized } returns true coEvery { - StytchApi.apiService.webAuthnAuthenticateStartSecondary(mockk(relaxed = true)) + StytchApi.apiService.webAuthnAuthenticateStartSecondary(any()) } returns mockk(relaxed = true) StytchApi.WebAuthn.authenticateStartSecondary("", true) coVerify { StytchApi.apiService.webAuthnAuthenticateStartSecondary(any()) } @@ -437,7 +437,7 @@ internal class StytchApiTest { @Test fun `StytchApi Webauthn webAuthnAuthenticate calls appropriate apiService method`() = runTest { every { StytchApi.isInitialized } returns true - coEvery { StytchApi.apiService.webAuthnAuthenticate(mockk(relaxed = true)) } returns mockk(relaxed = true) + coEvery { StytchApi.apiService.webAuthnAuthenticate(any()) } returns mockk(relaxed = true) StytchApi.WebAuthn.authenticate("", 30U) coVerify { StytchApi.apiService.webAuthnAuthenticate(any()) } } diff --git a/ui/build.gradle b/ui/build.gradle index 2e7e9d429..c21ea625d 100644 --- a/ui/build.gradle +++ b/ui/build.gradle @@ -138,6 +138,5 @@ tasks.withType(Test).configureEach { testLogging { exceptionFormat = TestExceptionFormat.FULL showStackTraces = true - showStandardStreams = true } } \ No newline at end of file diff --git a/uiworkbench/build.gradle b/uiworkbench/build.gradle index ddb5bedba..e4c9f863b 100644 --- a/uiworkbench/build.gradle +++ b/uiworkbench/build.gradle @@ -80,12 +80,4 @@ dependencies { androidTestImplementation 'androidx.compose.ui:ui-test-junit4' debugImplementation 'androidx.compose.ui:ui-tooling' debugImplementation 'androidx.compose.ui:ui-test-manifest' -} - -tasks.withType(Test).configureEach { - testLogging { - exceptionFormat = TestExceptionFormat.FULL - showStackTraces = true - showStandardStreams = true - } } \ No newline at end of file From ccb7a8aa9d012847e497d864f1f90c5b14144410 Mon Sep 17 00:00:00 2001 From: Jordan Haven Date: Wed, 17 Apr 2024 17:10:39 -0400 Subject: [PATCH 4/6] Is it the recaptcha? --- sdk/src/test/java/com/stytch/sdk/b2b/StytchB2BClientTest.kt | 3 +++ sdk/src/test/java/com/stytch/sdk/consumer/StytchClientTest.kt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/sdk/src/test/java/com/stytch/sdk/b2b/StytchB2BClientTest.kt b/sdk/src/test/java/com/stytch/sdk/b2b/StytchB2BClientTest.kt index c7df866ab..2efa34711 100644 --- a/sdk/src/test/java/com/stytch/sdk/b2b/StytchB2BClientTest.kt +++ b/sdk/src/test/java/com/stytch/sdk/b2b/StytchB2BClientTest.kt @@ -3,6 +3,7 @@ package com.stytch.sdk.b2b import android.app.Application import android.content.Context import android.net.Uri +import com.google.android.recaptcha.Recaptcha import com.stytch.sdk.b2b.extensions.launchSessionUpdater import com.stytch.sdk.b2b.magicLinks.B2BMagicLinks import com.stytch.sdk.b2b.network.StytchB2BApi @@ -79,6 +80,8 @@ internal class StytchB2BClientTest { mockkObject(StorageHelper) mockkObject(StytchB2BApi) mockkObject(StytchB2BApi.Sessions) + mockkObject(Recaptcha) + coEvery { Recaptcha.getClient(any(), any()) } returns Result.success(mockk(relaxed = true)) every { StorageHelper.initialize(any()) } just runs every { StorageHelper.loadValue(any()) } returns "" every { StorageHelper.generateHashedCodeChallenge() } returns Pair("", "") diff --git a/sdk/src/test/java/com/stytch/sdk/consumer/StytchClientTest.kt b/sdk/src/test/java/com/stytch/sdk/consumer/StytchClientTest.kt index e675ef1c2..52b3a8bf0 100644 --- a/sdk/src/test/java/com/stytch/sdk/consumer/StytchClientTest.kt +++ b/sdk/src/test/java/com/stytch/sdk/consumer/StytchClientTest.kt @@ -3,6 +3,7 @@ package com.stytch.sdk.consumer import android.app.Application import android.content.Context import android.net.Uri +import com.google.android.recaptcha.Recaptcha import com.stytch.sdk.common.DeeplinkHandledStatus import com.stytch.sdk.common.DeeplinkResponse import com.stytch.sdk.common.DeviceInfo @@ -83,6 +84,8 @@ internal class StytchClientTest { mockkObject(StorageHelper) mockkObject(StytchApi) mockkObject(StytchApi.Sessions) + mockkObject(Recaptcha) + coEvery { Recaptcha.getClient(any(), any()) } returns Result.success(mockk(relaxed = true)) every { StorageHelper.initialize(any()) } just runs every { StorageHelper.loadValue(any()) } returns "some-value" every { StorageHelper.generateHashedCodeChallenge() } returns Pair("", "") From f3b1cac641c4ecada7f28e586014de9b1c51bef2 Mon Sep 17 00:00:00 2001 From: Jordan Haven Date: Thu, 18 Apr 2024 10:00:30 -0400 Subject: [PATCH 5/6] Version bump --- sdk/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index 05b516f29..972613ad6 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -10,7 +10,7 @@ plugins { ext { PUBLISH_GROUP_ID = 'com.stytch.sdk' - PUBLISH_VERSION = '0.21.0' + PUBLISH_VERSION = '0.21.1' PUBLISH_ARTIFACT_ID = 'sdk' } From 839fdf7a8eceee1d94e1dc17d79311c2cb6ebd88 Mon Sep 17 00:00:00 2001 From: Jordan Haven Date: Thu, 18 Apr 2024 13:35:51 -0400 Subject: [PATCH 6/6] Add newlines --- sdk/build.gradle | 2 +- ui/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index 972613ad6..6b6fbc5b0 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -154,4 +154,4 @@ tasks.withType(Test).configureEach { exceptionFormat = TestExceptionFormat.FULL showStackTraces = true } -} \ No newline at end of file +} diff --git a/ui/build.gradle b/ui/build.gradle index c21ea625d..5327c902b 100644 --- a/ui/build.gradle +++ b/ui/build.gradle @@ -139,4 +139,4 @@ tasks.withType(Test).configureEach { exceptionFormat = TestExceptionFormat.FULL showStackTraces = true } -} \ No newline at end of file +}