Skip to content

Commit

Permalink
Merge pull request #149 from stytchauth/jordan/SDK-1591-OTP-authentic…
Browse files Browse the repository at this point in the history
…ate-error

SDK-1591 Add some more keep annotations
  • Loading branch information
jhaven-stytch authored Apr 18, 2024
2 parents 35292d0 + 839fdf7 commit 85a52b5
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 11 deletions.
11 changes: 10 additions & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat

plugins {
id 'com.android.library'
id 'kotlin-android'
Expand All @@ -8,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'
}

Expand Down Expand Up @@ -146,3 +148,10 @@ dependencies {
testImplementation("com.squareup.okhttp3:mockwebserver:4.11.0")
testImplementation("org.json:json:20230227")
}

tasks.withType(Test).configureEach {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showStackTraces = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public data class AuthenticationFactor(
) : Parcelable
}

@Keep
public interface CommonAuthenticationData {
public val sessionJwt: String
public val sessionToken: String
Expand Down Expand Up @@ -383,6 +384,8 @@ public data class PasswordConfig(
val ludsMinimumCount: Int,
) : Parcelable

@Keep
@JsonClass(generateAdapter = false)
public enum class DFPProtectedAuthMode {
OBSERVATION,
DECISIONING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ 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
public override val sessionToken: String
public val user: UserData
}

@Keep
public interface INativeOAuthData : IAuthData {
public val userCreated: Boolean
}
Expand Down Expand Up @@ -258,6 +260,7 @@ public data class StrengthCheckResponse(
val strengthPolicy: StrengthPolicy,
) : Parcelable

@Keep
@JsonClass(generateAdapter = false)
public enum class StrengthPolicy {
@Json(name = "zxcvbn")
Expand Down Expand Up @@ -285,6 +288,7 @@ public data class UserSearchResponseData(
val userType: UserType,
) : Parcelable

@Keep
@JsonClass(generateAdapter = false)
@Parcelize
public enum class UserType : Parcelable {
Expand Down
3 changes: 3 additions & 0 deletions sdk/src/test/java/com/stytch/sdk/b2b/StytchB2BClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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("", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
}
Expand Down
3 changes: 3 additions & 0 deletions sdk/src/test/java/com/stytch/sdk/consumer/StytchClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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("", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ 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") }
}

@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") }
}
Expand All @@ -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") }
Expand Down Expand Up @@ -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") }
}
Expand All @@ -401,15 +401,15 @@ 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()) }
}

@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()) }
}
Expand All @@ -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()) }
Expand All @@ -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()) }
Expand All @@ -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()) }
}
Expand Down
9 changes: 9 additions & 0 deletions ui/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat

plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
Expand Down Expand Up @@ -131,3 +133,10 @@ tasks.named("dokkaHtmlPartial").configure {
*/
}
}

tasks.withType(Test).configureEach {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showStackTraces = true
}
}
2 changes: 2 additions & 0 deletions uiworkbench/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
Expand Down

0 comments on commit 85a52b5

Please sign in to comment.