Rename methods around verification, to match SDK naming.
This commit is contained in:
parent
81130bb195
commit
e4c58b3fc6
5 changed files with 39 additions and 39 deletions
|
|
@ -46,7 +46,7 @@ class OutgoingVerificationStateMachine(
|
||||||
inState<State.RequestingVerification> {
|
inState<State.RequestingVerification> {
|
||||||
onEnterEffect { event ->
|
onEnterEffect { event ->
|
||||||
when (event.verificationRequest) {
|
when (event.verificationRequest) {
|
||||||
is VerificationRequest.Outgoing.CurrentSession -> sessionVerificationService.requestCurrentSessionVerification()
|
is VerificationRequest.Outgoing.CurrentSession -> sessionVerificationService.requestDeviceVerification()
|
||||||
is VerificationRequest.Outgoing.User -> sessionVerificationService.requestUserVerification(event.verificationRequest.userId)
|
is VerificationRequest.Outgoing.User -> sessionVerificationService.requestUserVerification(event.verificationRequest.userId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ class OutgoingVerificationStateMachine(
|
||||||
}
|
}
|
||||||
inState<State.StartingSasVerification> {
|
inState<State.StartingSasVerification> {
|
||||||
onEnterEffect {
|
onEnterEffect {
|
||||||
sessionVerificationService.startVerification()
|
sessionVerificationService.startSasVerification()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inState<State.VerificationRequestAccepted> {
|
inState<State.VerificationRequestAccepted> {
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,11 @@ class OutgoingVerificationPresenterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - Handles requestVerification for session verification`() = runTest {
|
fun `present - Handles requestVerification for session verification`() = runTest {
|
||||||
val requestSessionVerificationRecorder = lambdaRecorder<Unit> {}
|
val requestDeviceVerificationRecorder = lambdaRecorder<Unit> {}
|
||||||
val startVerificationRecorder = lambdaRecorder<Unit> {}
|
val startSasVerificationRecorder = lambdaRecorder<Unit> {}
|
||||||
val service = unverifiedSessionService(
|
val service = unverifiedSessionService(
|
||||||
requestSessionVerificationLambda = requestSessionVerificationRecorder,
|
requestDeviceVerificationLambda = requestDeviceVerificationRecorder,
|
||||||
startVerificationLambda = startVerificationRecorder,
|
startSasVerificationLambda = startSasVerificationRecorder,
|
||||||
)
|
)
|
||||||
val presenter = createOutgoingVerificationPresenter(
|
val presenter = createOutgoingVerificationPresenter(
|
||||||
service = service,
|
service = service,
|
||||||
|
|
@ -63,18 +63,18 @@ class OutgoingVerificationPresenterTest {
|
||||||
presenter.test {
|
presenter.test {
|
||||||
requestVerificationAndAwaitVerifyingState(service)
|
requestVerificationAndAwaitVerifyingState(service)
|
||||||
|
|
||||||
requestSessionVerificationRecorder.assertions().isCalledOnce()
|
requestDeviceVerificationRecorder.assertions().isCalledOnce()
|
||||||
startVerificationRecorder.assertions().isCalledOnce()
|
startSasVerificationRecorder.assertions().isCalledOnce()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - Handles requestVerification for user verification`() = runTest {
|
fun `present - Handles requestVerification for user verification`() = runTest {
|
||||||
val requestUserVerificationRecorder = lambdaRecorder<UserId, Unit> {}
|
val requestUserVerificationRecorder = lambdaRecorder<UserId, Unit> {}
|
||||||
val startVerificationRecorder = lambdaRecorder<Unit> {}
|
val startSasVerificationRecorder = lambdaRecorder<Unit> {}
|
||||||
val service = unverifiedSessionService(
|
val service = unverifiedSessionService(
|
||||||
requestUserVerificationLambda = requestUserVerificationRecorder,
|
requestUserVerificationLambda = requestUserVerificationRecorder,
|
||||||
startVerificationLambda = startVerificationRecorder,
|
startSasVerificationLambda = startSasVerificationRecorder,
|
||||||
)
|
)
|
||||||
val presenter = createOutgoingVerificationPresenter(
|
val presenter = createOutgoingVerificationPresenter(
|
||||||
service = service,
|
service = service,
|
||||||
|
|
@ -84,7 +84,7 @@ class OutgoingVerificationPresenterTest {
|
||||||
requestVerificationAndAwaitVerifyingState(service)
|
requestVerificationAndAwaitVerifyingState(service)
|
||||||
|
|
||||||
requestUserVerificationRecorder.assertions().isCalledOnce()
|
requestUserVerificationRecorder.assertions().isCalledOnce()
|
||||||
startVerificationRecorder.assertions().isCalledOnce()
|
startSasVerificationRecorder.assertions().isCalledOnce()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,8 +106,8 @@ class OutgoingVerificationPresenterTest {
|
||||||
@Test
|
@Test
|
||||||
fun `present - A failure when verifying cancels it`() = runTest {
|
fun `present - A failure when verifying cancels it`() = runTest {
|
||||||
val service = unverifiedSessionService(
|
val service = unverifiedSessionService(
|
||||||
requestSessionVerificationLambda = { },
|
requestDeviceVerificationLambda = { },
|
||||||
startVerificationLambda = { },
|
startSasVerificationLambda = { },
|
||||||
approveVerificationLambda = { },
|
approveVerificationLambda = { },
|
||||||
)
|
)
|
||||||
val presenter = createOutgoingVerificationPresenter(service)
|
val presenter = createOutgoingVerificationPresenter(service)
|
||||||
|
|
@ -125,7 +125,7 @@ class OutgoingVerificationPresenterTest {
|
||||||
@Test
|
@Test
|
||||||
fun `present - A fail when requesting verification resets the state to the canceled one`() = runTest {
|
fun `present - A fail when requesting verification resets the state to the canceled one`() = runTest {
|
||||||
val service = unverifiedSessionService(
|
val service = unverifiedSessionService(
|
||||||
requestSessionVerificationLambda = { },
|
requestDeviceVerificationLambda = { },
|
||||||
)
|
)
|
||||||
val presenter = createOutgoingVerificationPresenter(service)
|
val presenter = createOutgoingVerificationPresenter(service)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
|
|
@ -139,8 +139,8 @@ class OutgoingVerificationPresenterTest {
|
||||||
@Test
|
@Test
|
||||||
fun `present - Canceling the flow once it's verifying cancels it`() = runTest {
|
fun `present - Canceling the flow once it's verifying cancels it`() = runTest {
|
||||||
val service = unverifiedSessionService(
|
val service = unverifiedSessionService(
|
||||||
requestSessionVerificationLambda = { },
|
requestDeviceVerificationLambda = { },
|
||||||
startVerificationLambda = { },
|
startSasVerificationLambda = { },
|
||||||
cancelVerificationLambda = { },
|
cancelVerificationLambda = { },
|
||||||
)
|
)
|
||||||
val presenter = createOutgoingVerificationPresenter(service)
|
val presenter = createOutgoingVerificationPresenter(service)
|
||||||
|
|
@ -154,8 +154,8 @@ class OutgoingVerificationPresenterTest {
|
||||||
@Test
|
@Test
|
||||||
fun `present - When verifying, if we receive another challenge we ignore it`() = runTest {
|
fun `present - When verifying, if we receive another challenge we ignore it`() = runTest {
|
||||||
val service = unverifiedSessionService(
|
val service = unverifiedSessionService(
|
||||||
requestSessionVerificationLambda = { },
|
requestDeviceVerificationLambda = { },
|
||||||
startVerificationLambda = { },
|
startSasVerificationLambda = { },
|
||||||
)
|
)
|
||||||
val presenter = createOutgoingVerificationPresenter(service)
|
val presenter = createOutgoingVerificationPresenter(service)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
|
|
@ -168,8 +168,8 @@ class OutgoingVerificationPresenterTest {
|
||||||
@Test
|
@Test
|
||||||
fun `present - Go back after cancellation returns to initial state`() = runTest {
|
fun `present - Go back after cancellation returns to initial state`() = runTest {
|
||||||
val service = unverifiedSessionService(
|
val service = unverifiedSessionService(
|
||||||
requestSessionVerificationLambda = { },
|
requestDeviceVerificationLambda = { },
|
||||||
startVerificationLambda = { },
|
startSasVerificationLambda = { },
|
||||||
)
|
)
|
||||||
val presenter = createOutgoingVerificationPresenter(service)
|
val presenter = createOutgoingVerificationPresenter(service)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
|
|
@ -189,8 +189,8 @@ class OutgoingVerificationPresenterTest {
|
||||||
VerificationEmoji(number = 30)
|
VerificationEmoji(number = 30)
|
||||||
)
|
)
|
||||||
val service = unverifiedSessionService(
|
val service = unverifiedSessionService(
|
||||||
requestSessionVerificationLambda = { },
|
requestDeviceVerificationLambda = { },
|
||||||
startVerificationLambda = { },
|
startSasVerificationLambda = { },
|
||||||
approveVerificationLambda = { },
|
approveVerificationLambda = { },
|
||||||
)
|
)
|
||||||
val presenter = createOutgoingVerificationPresenter(service)
|
val presenter = createOutgoingVerificationPresenter(service)
|
||||||
|
|
@ -215,8 +215,8 @@ class OutgoingVerificationPresenterTest {
|
||||||
@Test
|
@Test
|
||||||
fun `present - When verification is declined, the flow is canceled`() = runTest {
|
fun `present - When verification is declined, the flow is canceled`() = runTest {
|
||||||
val service = unverifiedSessionService(
|
val service = unverifiedSessionService(
|
||||||
requestSessionVerificationLambda = { },
|
requestDeviceVerificationLambda = { },
|
||||||
startVerificationLambda = { },
|
startSasVerificationLambda = { },
|
||||||
declineVerificationLambda = { },
|
declineVerificationLambda = { },
|
||||||
)
|
)
|
||||||
val presenter = createOutgoingVerificationPresenter(service)
|
val presenter = createOutgoingVerificationPresenter(service)
|
||||||
|
|
@ -298,23 +298,23 @@ class OutgoingVerificationPresenterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun unverifiedSessionService(
|
private suspend fun unverifiedSessionService(
|
||||||
requestSessionVerificationLambda: () -> Unit = { lambdaError() },
|
requestDeviceVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
requestUserVerificationLambda: (UserId) -> Unit = { lambdaError() },
|
requestUserVerificationLambda: (UserId) -> Unit = { lambdaError() },
|
||||||
cancelVerificationLambda: () -> Unit = { lambdaError() },
|
cancelVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
approveVerificationLambda: () -> Unit = { lambdaError() },
|
approveVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
declineVerificationLambda: () -> Unit = { lambdaError() },
|
declineVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
startVerificationLambda: () -> Unit = { lambdaError() },
|
startSasVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
resetLambda: (Boolean) -> Unit = { },
|
resetLambda: (Boolean) -> Unit = { },
|
||||||
acknowledgeVerificationRequestLambda: (VerificationRequest.Incoming) -> Unit = { lambdaError() },
|
acknowledgeVerificationRequestLambda: (VerificationRequest.Incoming) -> Unit = { lambdaError() },
|
||||||
acceptVerificationRequestLambda: () -> Unit = { lambdaError() },
|
acceptVerificationRequestLambda: () -> Unit = { lambdaError() },
|
||||||
): FakeSessionVerificationService {
|
): FakeSessionVerificationService {
|
||||||
return FakeSessionVerificationService(
|
return FakeSessionVerificationService(
|
||||||
requestCurrentSessionVerificationLambda = requestSessionVerificationLambda,
|
requestDeviceVerificationLambda = requestDeviceVerificationLambda,
|
||||||
requestUserVerificationLambda = requestUserVerificationLambda,
|
requestUserVerificationLambda = requestUserVerificationLambda,
|
||||||
cancelVerificationLambda = cancelVerificationLambda,
|
cancelVerificationLambda = cancelVerificationLambda,
|
||||||
approveVerificationLambda = approveVerificationLambda,
|
approveVerificationLambda = approveVerificationLambda,
|
||||||
declineVerificationLambda = declineVerificationLambda,
|
declineVerificationLambda = declineVerificationLambda,
|
||||||
startVerificationLambda = startVerificationLambda,
|
startSasVerificationLambda = startSasVerificationLambda,
|
||||||
resetLambda = resetLambda,
|
resetLambda = resetLambda,
|
||||||
acknowledgeVerificationRequestLambda = acknowledgeVerificationRequestLambda,
|
acknowledgeVerificationRequestLambda = acknowledgeVerificationRequestLambda,
|
||||||
acceptVerificationRequestLambda = acceptVerificationRequestLambda,
|
acceptVerificationRequestLambda = acceptVerificationRequestLambda,
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ interface SessionVerificationService {
|
||||||
/**
|
/**
|
||||||
* Request verification of the current session.
|
* Request verification of the current session.
|
||||||
*/
|
*/
|
||||||
suspend fun requestCurrentSessionVerification()
|
suspend fun requestDeviceVerification()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request verification of the user with the given [userId].
|
* Request verification of the user with the given [userId].
|
||||||
|
|
@ -56,9 +56,9 @@ interface SessionVerificationService {
|
||||||
suspend fun declineVerification()
|
suspend fun declineVerification()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the verification of the unverified session from another device.
|
* Transition the current verification request into a SAS verification flow.
|
||||||
*/
|
*/
|
||||||
suspend fun startVerification()
|
suspend fun startSasVerification()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the verification service state to the initial step.
|
* Returns the verification service state to the initial step.
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ class RustSessionVerificationService(
|
||||||
this.listener = listener
|
this.listener = listener
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun requestCurrentSessionVerification() = tryOrFail {
|
override suspend fun requestDeviceVerification() = tryOrFail {
|
||||||
ensureEncryptionIsInitialized()
|
ensureEncryptionIsInitialized()
|
||||||
verificationController.requestDeviceVerification()
|
verificationController.requestDeviceVerification()
|
||||||
currentVerificationRequest = VerificationRequest.Outgoing.CurrentSession
|
currentVerificationRequest = VerificationRequest.Outgoing.CurrentSession
|
||||||
|
|
@ -146,7 +146,7 @@ class RustSessionVerificationService(
|
||||||
|
|
||||||
override suspend fun declineVerification() = tryOrFail { verificationController.declineVerification() }
|
override suspend fun declineVerification() = tryOrFail { verificationController.declineVerification() }
|
||||||
|
|
||||||
override suspend fun startVerification() = tryOrFail {
|
override suspend fun startSasVerification() = tryOrFail {
|
||||||
verificationController.startSasVerification()
|
verificationController.startSasVerification()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ import kotlinx.coroutines.flow.StateFlow
|
||||||
|
|
||||||
class FakeSessionVerificationService(
|
class FakeSessionVerificationService(
|
||||||
initialSessionVerifiedStatus: SessionVerifiedStatus = SessionVerifiedStatus.Unknown,
|
initialSessionVerifiedStatus: SessionVerifiedStatus = SessionVerifiedStatus.Unknown,
|
||||||
private val requestCurrentSessionVerificationLambda: () -> Unit = { lambdaError() },
|
private val requestDeviceVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
private val requestUserVerificationLambda: (UserId) -> Unit = { lambdaError() },
|
private val requestUserVerificationLambda: (UserId) -> Unit = { lambdaError() },
|
||||||
private val cancelVerificationLambda: () -> Unit = { lambdaError() },
|
private val cancelVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
private val approveVerificationLambda: () -> Unit = { lambdaError() },
|
private val approveVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
private val declineVerificationLambda: () -> Unit = { lambdaError() },
|
private val declineVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
private val startVerificationLambda: () -> Unit = { lambdaError() },
|
private val startSasVerificationLambda: () -> Unit = { lambdaError() },
|
||||||
private val resetLambda: (Boolean) -> Unit = { lambdaError() },
|
private val resetLambda: (Boolean) -> Unit = { lambdaError() },
|
||||||
private val acknowledgeVerificationRequestLambda: (VerificationRequest.Incoming) -> Unit = { lambdaError() },
|
private val acknowledgeVerificationRequestLambda: (VerificationRequest.Incoming) -> Unit = { lambdaError() },
|
||||||
private val acceptVerificationRequestLambda: () -> Unit = { lambdaError() },
|
private val acceptVerificationRequestLambda: () -> Unit = { lambdaError() },
|
||||||
|
|
@ -40,8 +40,8 @@ class FakeSessionVerificationService(
|
||||||
override val sessionVerifiedStatus: StateFlow<SessionVerifiedStatus> = _sessionVerifiedStatus
|
override val sessionVerifiedStatus: StateFlow<SessionVerifiedStatus> = _sessionVerifiedStatus
|
||||||
override val needsSessionVerification: Flow<Boolean> = _needsSessionVerification
|
override val needsSessionVerification: Flow<Boolean> = _needsSessionVerification
|
||||||
|
|
||||||
override suspend fun requestCurrentSessionVerification() {
|
override suspend fun requestDeviceVerification() {
|
||||||
requestCurrentSessionVerificationLambda()
|
requestDeviceVerificationLambda()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun requestUserVerification(userId: UserId) {
|
override suspend fun requestUserVerification(userId: UserId) {
|
||||||
|
|
@ -60,8 +60,8 @@ class FakeSessionVerificationService(
|
||||||
declineVerificationLambda()
|
declineVerificationLambda()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun startVerification() {
|
override suspend fun startSasVerification() {
|
||||||
startVerificationLambda()
|
startSasVerificationLambda()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun reset(cancelAnyPendingVerificationAttempt: Boolean) {
|
override suspend fun reset(cancelAnyPendingVerificationAttempt: Boolean) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue