Skip to content

Commit

Permalink
Update Native Auth password reset API response (#2281)
Browse files Browse the repository at this point in the history
Update relevant response classes to include the
continuation token returned from the updated poll completion response,
and updates constructors in test classes to reflect the change.
  • Loading branch information
rmccahill authored Jan 18, 2024
1 parent 389106f commit 4900edb
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 22 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ V.Next
- [MINOR] Add IsQrPinAvailableCommand, controllers behavior and define constants for the isQrAvailable API (#2219)
- [MINOR] Add PreferredAuthMethod to interactive token flow (#2245)
- [MINOR] Implement updates of the native auth web API (#2261)
- [MINOR] Update ResetPasswordPollCompletion related command, results, and responses to support signing in a user after a successful password reset. (#2281)

V.17.0.0
---------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,10 @@ class NativeAuthMsalController : BaseNativeAuthController() {
}

is ResetPasswordPollCompletionApiResult.PollingSucceeded -> {
ResetPasswordCommandResult.Complete
ResetPasswordCommandResult.Complete(
continuationToken = pollCompletionApiResult.continuationToken,
expiresIn = pollCompletionApiResult.expiresIn
)
}

is ResetPasswordPollCompletionApiResult.InProgress -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
import org.powermock.core.classloader.annotations.PowerMockIgnore
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import java.util.UUID

Expand All @@ -81,7 +81,7 @@ import java.util.UUID


@RunWith(
PowerMockRunner::class
RobolectricTestRunner::class
)
@PowerMockIgnore("javax.net.ssl.*")
@PrepareForTest(DiagnosticContext::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class CommandResultUtilTestSignUpStartCommandResult(private val resultValue: Any
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -217,7 +217,7 @@ class CommandResultUtilTestSignUpSubmitCodeCommandResult(private val resultValue
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -287,7 +287,7 @@ class CommandResultUtilTestSignUpSignUpSubmitUserAttributesCommandResult(private
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -357,7 +357,7 @@ class CommandResultUtilTestSignUpSubmitPasswordCommandResult(private val resultV
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -424,7 +424,7 @@ class CommandResultUtilTestSignUpResendCodeCommandResult(private val resultValue
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -531,7 +531,7 @@ class CommandResultUtilTestSignInStartCommandResult(private val resultValue: Any
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -600,7 +600,7 @@ class CommandResultUtilTestSignInWithContinuationTokenCommandResult(private val
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -668,7 +668,7 @@ class CommandResultUtilTestSignInSubmitCodeCommandResult(private val resultValue
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -735,7 +735,7 @@ class CommandResultUtilTestSignInResendCodeCommandResult(private val resultValue
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -803,7 +803,7 @@ class CommandResultUtilTestSignInSubmitPasswordCommandResult(private val resultV
fun testCheckAndWrapCommandResultTypeCompletedStatusWrongType() {
val commandResult = CommandResult<Any>(
ResultStatus.COMPLETED,
ResetPasswordCommandResult.Complete,
ResetPasswordCommandResult.Complete("", null),
null
)

Expand Down Expand Up @@ -849,7 +849,7 @@ private val resetPasswordCodeRequiredCommandResult = ResetPasswordCommandResult.
codeLength = CODE_LENGTH
)

private val resetPasswordCompleteCommandResult = ResetPasswordCommandResult.Complete
private val resetPasswordCompleteCommandResult = ResetPasswordCommandResult.Complete("", null)

private val resetPasswordEmailNotVerifiedCommandResult = ResetPasswordCommandResult.EmailNotVerified(
error = ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,8 @@ interface ResetPasswordCommandResult {
data class PasswordResetFailed(val error: String, val errorDescription: String, val correlationId: String = DiagnosticContext.INSTANCE.threadCorrelationId) :
ResetPasswordSubmitNewPasswordCommandResult

object Complete : ResetPasswordSubmitNewPasswordCommandResult
data class Complete (
val continuationToken: String?,
val expiresIn: Int?
) : ResetPasswordSubmitNewPasswordCommandResult
}
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ class NativeAuthResponseHandler {
errorUri = null,
status = null,
continuationToken = null,
expiresIn = null,
subError = null
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ResetPasswordPollCompletionApiResponse(
@Expose override var statusCode: Int,
@Expose @SerializedName("status") val status: String?,
@SerializedName("continuation_token") val continuationToken: String?,
@SerializedName("expires_in") val expiresIn: Int?,
@SerializedName("error") val error: String?,
@SerializedName("error_description") val errorDescription: String?,
@SerializedName("error_uri") val errorUri: String?,
Expand Down Expand Up @@ -115,7 +116,10 @@ class ResetPasswordPollCompletionApiResponse(
ResetPasswordPollCompletionApiResult.InProgress
}
status.isPollSucceeded() -> {
ResetPasswordPollCompletionApiResult.PollingSucceeded
ResetPasswordPollCompletionApiResult.PollingSucceeded(
continuationToken = continuationToken,
expiresIn = expiresIn
)
}
else -> {
ResetPasswordPollCompletionApiResult.PollingFailed(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ sealed interface ResetPasswordPollCompletionApiResult {
errorDescription = errorDescription,
), ResetPasswordPollCompletionApiResult

object PollingSucceeded : ResetPasswordPollCompletionApiResult
data class PollingSucceeded(
val continuationToken: String?,
val expiresIn: Int?
) : ResetPasswordPollCompletionApiResult

data class UserNotFound(
override val error: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,8 @@ class NativeAuthResponseHandlerTest {
error = null,
errorDescription = null,
errorUri = null,
subError = null
subError = null,
expiresIn = null
)

val apiResult = resetPasswordPollCompletionApiResponse.toResult()
Expand All @@ -1894,7 +1895,8 @@ class NativeAuthResponseHandlerTest {
error = null,
errorDescription = null,
errorUri = null,
subError = null
subError = null,
expiresIn = null
)

val apiResult = resetPasswordPollCompletionApiResponse.toResult()
Expand All @@ -1910,7 +1912,8 @@ class NativeAuthResponseHandlerTest {
error = null,
errorDescription = null,
errorUri = null,
subError = null
subError = null,
expiresIn = null
)

val apiResult = resetPasswordPollCompletionApiResponse.toResult()
Expand All @@ -1927,6 +1930,7 @@ class NativeAuthResponseHandlerTest {
subError = passwordBannedError,
status = null,
continuationToken = null,
expiresIn = null
)

val apiResult = resetPasswordSubmitApiResponse.toResult()
Expand All @@ -1943,6 +1947,7 @@ class NativeAuthResponseHandlerTest {
subError = passwordTooShortError,
status = null,
continuationToken = null,
expiresIn = null
)

val apiResult = resetPasswordSubmitApiResponse.toResult()
Expand All @@ -1959,6 +1964,7 @@ class NativeAuthResponseHandlerTest {
subError = passwordTooLongError,
status = null,
continuationToken = null,
expiresIn = null
)

val apiResult = resetPasswordSubmitApiResponse.toResult()
Expand All @@ -1975,6 +1981,7 @@ class NativeAuthResponseHandlerTest {
subError = passwordRecentlyUsedError,
status = null,
continuationToken = null,
expiresIn = null
)

val apiResult = resetPasswordSubmitApiResponse.toResult()
Expand All @@ -1991,6 +1998,7 @@ class NativeAuthResponseHandlerTest {
subError = passwordTooWeakError,
status = null,
continuationToken = null,
expiresIn = null
)

val apiResult = resetPasswordSubmitApiResponse.toResult()
Expand All @@ -2007,6 +2015,7 @@ class NativeAuthResponseHandlerTest {
subError = null,
status = null,
continuationToken = null,
expiresIn = null
)

val apiResult = resetPasswordSubmitApiResponse.toResult()
Expand All @@ -2023,6 +2032,7 @@ class NativeAuthResponseHandlerTest {
subError = null,
status = null,
continuationToken = null,
expiresIn = null
)

val apiResult = resetPasswordSubmitApiResponse.toResult()
Expand All @@ -2038,7 +2048,8 @@ class NativeAuthResponseHandlerTest {
error = null,
errorDescription = null,
errorUri = null,
subError = null
subError = null,
expiresIn = null
)

val apiResult = resetPasswordPollCompletionApiResponse.toResult()
Expand All @@ -2054,7 +2065,8 @@ class NativeAuthResponseHandlerTest {
error = null,
errorDescription = null,
errorUri = null,
subError = null
subError = null,
expiresIn = null
)

val apiResult = resetPasswordPollCompletionApiResponse.toResult()
Expand Down

0 comments on commit 4900edb

Please sign in to comment.