Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/issue/9541-configuration-key' in…
Browse files Browse the repository at this point in the history
…to issue/9541-bundle-quantity-rules-support
  • Loading branch information
Alejo committed Nov 14, 2023
2 parents ceb00dd + 2ea59fd commit 5fd22e0
Show file tree
Hide file tree
Showing 13 changed files with 496 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.wordpress.android.fluxc.network.rest.wpapi.CookieNonceAuthenticator.C
import org.wordpress.android.fluxc.network.rest.wpapi.CookieNonceAuthenticator.CookieNonceAuthenticationResult.Success
import org.wordpress.android.fluxc.store.AccountStore
import org.wordpress.android.fluxc.store.AccountStore.AuthenticatePayload
import org.wordpress.android.fluxc.store.AccountStore.AuthenticateTwoFactorPayload
import org.wordpress.android.fluxc.store.AccountStore.AuthenticationErrorType
import org.wordpress.android.fluxc.store.AccountStore.OnAccountChanged
import org.wordpress.android.fluxc.store.AccountStore.OnAuthenticationChanged
Expand All @@ -55,9 +56,11 @@ class MainFragment : Fragment() {
// Would be great to not have to keep this state, but it makes HTTPAuth and self signed SSL management easier
private var selfHostedPayload: RefreshSitesXMLRPCPayload? = null

// Used for 2fa
private var authenticatePayload: AuthenticatePayload? = null

// Used for 2fa
private var authenticateTwoFactorPayload: AuthenticateTwoFactorPayload? = null

override fun onAttach(context: Context) {
AndroidSupportInjection.inject(this)
super.onAttach(context)
Expand Down Expand Up @@ -174,8 +177,9 @@ class MainFragment : Fragment() {
}

private fun signIn2fa(twoStepCode: String) {
authenticatePayload?.twoStepCode = twoStepCode
dispatcher.dispatch(AuthenticationActionBuilder.newAuthenticateAction(authenticatePayload))
authenticateTwoFactorPayload?.twoStepCode = twoStepCode
dispatcher.dispatch(AuthenticationActionBuilder
.newAuthenticateTwoFactorAction(authenticateTwoFactorPayload))
}

private fun showHTTPAuthDialog(url: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.wordpress.android.fluxc.persistence.mappers

import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.wordpress.android.fluxc.model.LocalOrRemoteId
import org.wordpress.android.fluxc.model.LocalOrRemoteId.LocalId
import org.wordpress.android.fluxc.model.payments.woo.WooPaymentsDepositsOverviewComposedEntities
import org.wordpress.android.fluxc.network.rest.wpcom.wc.payments.woo.WooPaymentsAccountDepositSummary
Expand Down Expand Up @@ -118,8 +117,10 @@ class WooPaymentsDepositsOverviewMapperTest {
depositsEnabled = true,
depositsBlocked = true,
depositsSchedule = WooPaymentsDepositsSchedule(
delayDays = 1,
interval = "interval"
interval = "interval",
weeklyAnchor = "monday",
monthlyAnchor = 10,
delayDays = 1
),
defaultCurrency = "defaultCurrency"
)
Expand Down Expand Up @@ -181,6 +182,8 @@ class WooPaymentsDepositsOverviewMapperTest {
assertThat(result.account?.depositsBlocked).isEqualTo(true)
assertThat(result.account?.depositsEnabled).isEqualTo(true)
assertThat(result.account?.depositsSchedule?.delayDays).isEqualTo(1)
assertThat(result.account?.depositsSchedule?.monthlyAnchor).isEqualTo(10)
assertThat(result.account?.depositsSchedule?.weeklyAnchor).isEqualTo("monday")
assertThat(result.account?.depositsSchedule?.interval).isEqualTo("interval")
}

Expand All @@ -190,13 +193,15 @@ class WooPaymentsDepositsOverviewMapperTest {
// GIVEN
val entity = WooPaymentsDepositsOverviewComposedEntities(
overview = WooPaymentsDepositsOverviewEntity(
localSiteId = LocalOrRemoteId.LocalId(1),
localSiteId = LocalId(1),
account = WooPaymentsAccountDepositSummaryEntity(
depositsEnabled = true,
depositsBlocked = true,
depositsSchedule = WooPaymentsDepositsScheduleEntity(
delayDays = 1,
interval = "interval"
interval = "interval",
monthlyAnchor = null,
weeklyAnchor = null,
),
defaultCurrency = "defaultCurrency"
)
Expand Down Expand Up @@ -348,6 +353,8 @@ class WooPaymentsDepositsOverviewMapperTest {
assertThat(result.account?.depositsBlocked).isEqualTo(true)
assertThat(result.account?.depositsEnabled).isEqualTo(true)
assertThat(result.account?.depositsSchedule?.delayDays).isEqualTo(1)
assertThat(result.account?.depositsSchedule?.monthlyAnchor).isNull()
assertThat(result.account?.depositsSchedule?.weeklyAnchor).isNull()
assertThat(result.account?.depositsSchedule?.interval).isEqualTo("interval")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
import org.wordpress.android.fluxc.network.discovery.SelfHostedEndpointFinder.DiscoveryResultPayload;
import org.wordpress.android.fluxc.network.rest.wpcom.auth.Authenticator.AuthEmailResponsePayload;
import org.wordpress.android.fluxc.store.AccountStore.AuthEmailPayload;
import org.wordpress.android.fluxc.store.AccountStore.AuthenticateTwoFactorPayload;
import org.wordpress.android.fluxc.store.AccountStore.StartWebauthnChallengePayload;
import org.wordpress.android.fluxc.store.AccountStore.AuthenticateErrorPayload;
import org.wordpress.android.fluxc.store.AccountStore.AuthenticatePayload;
import org.wordpress.android.fluxc.store.AccountStore.FinishWebauthnChallengePayload;

@ActionEnum
public enum AuthenticationAction implements IAction {
// Remote actions
@Action(payloadType = AuthenticatePayload.class)
AUTHENTICATE,
@Action(payloadType = AuthenticateTwoFactorPayload.class)
AUTHENTICATE_TWO_FACTOR,
@Action(payloadType = String.class)
DISCOVER_ENDPOINT,
@Action(payloadType = AuthEmailPayload.class)
Expand All @@ -25,5 +30,10 @@ public enum AuthenticationAction implements IAction {
@Action(payloadType = DiscoveryResultPayload.class)
DISCOVERY_RESULT,
@Action(payloadType = AuthEmailResponsePayload.class)
SENT_AUTH_EMAIL
SENT_AUTH_EMAIL,
@Action(payloadType = StartWebauthnChallengePayload.class)
START_SECURITY_KEY_CHALLENGE,

@Action(payloadType = FinishWebauthnChallengePayload.class)
FINISH_SECURITY_KEY_CHALLENGE
}
Loading

0 comments on commit 5fd22e0

Please sign in to comment.