Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FX-1451] Add unit tests for RosettaPinSubmitter and RosettaPinElement #261

Conversation

djoksimo
Copy link
Contributor

@djoksimo djoksimo commented Jun 11, 2024

What

  • Cover the new RosettaPinSubmitter
  • Fix vault URL resolution (see here)
  • Cover the ForageVaultWrapper UI element

--

⚠️ Had trouble testing default color-related and stroke properties, but we can introduce coverage for those in the future.

Test Plan

  • ✅ Ran coverage report + tests locally

How

Can be released as-is, should be included before 6/20

@djoksimo djoksimo marked this pull request as ready for review June 11, 2024 21:00
@@ -26,10 +26,11 @@ import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject

internal class ForagePinSubmitter(
internal class RosettaPinSubmitter(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed for consistency with POS code and for less ambiguity while we have dual redundancy

Comment on lines 94 to 95
private fun buildVaultUrl(path: String): HttpUrl =
VAULT_BASE_URL.toHttpUrlOrNull()!!
StopgapGlobalState.envConfig.vaultBaseUrl.toHttpUrlOrNull()!!
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied fix from here

@djoksimo djoksimo changed the title [FX-1451] Add unit tests for ForagePinSubmitter and ForageVaultWrapper [FX-1451] Add unit tests for RosettaPinSubmitter and RosettaPinElement Jun 11, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to RosettaPinElement. The term "wrapper" applies to Basis Theory, but we're not wrapping much in RosettaPinElement

}

@Test
fun `Basis Theory responds with a malformed error`() = runTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^Rosetta rather than BT

val path = buildMockPaymentCapturePath(paymentRef)

return VaultProxyRequest.emptyRequest()
.setHeader(ForageConstants.Headers.X_KEY, "22320ce0-1a3c-4c64-970c-51ed7db34548")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to send this X-KEY header?

Copy link
Contributor Author

@djoksimo djoksimo Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the X-KEY header for Rosetta (omitted here), but on this line, I'm emulating the headers that are set by the Abstract /Base Vault Submitter, I'll update a comment to capture this context in the code

import com.joinforage.forage.android.core.ui.textwatcher.PinTextWatcher
import com.joinforage.forage.android.ecom.services.vault.forage.RosettaPinSubmitter

internal class RosettaPinElement @JvmOverloads constructor(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devinmorgan can this file be moved to core instead of ecom ?

This can also happen in a future PR as this is an internal change, but vocalizing now for visibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main blocker right now is that this file depends on:

import com.joinforage.forage.android.ecom.services.vault.forage.RosettaPinSubmitter

which is an ecom file. So in theory, yes, this file ought to live in core since it's used in both Ecom and Pos but this may be more appropriate to do in a follow on PR since it's slightly move inovled. Nice callout!

@djoksimo djoksimo force-pushed the evan/fx-1368-re-introduce-the-foragevaultwrapper-into-the-coreui-module branch from 6bcfec6 to 8a08eed Compare June 17, 2024 16:57
@djoksimo djoksimo force-pushed the danilo/fx-1451-unit-tests-for-foragepinsubmitter-and-forage-pin-ui-element branch from 9cb2565 to 4299337 Compare June 17, 2024 17:58
@djoksimo djoksimo merged commit 1b0e23e into evan/fx-1368-re-introduce-the-foragevaultwrapper-into-the-coreui-module Jun 17, 2024
6 checks passed
djoksimo added a commit that referenced this pull request Jun 17, 2024
* add ForageResponseParser

* add ForagePinSubmitter

* add ForageVaultWrapper

* use ForageVaultWrapper in ForagePINEditText

* flip logic around to reduce unnecessary diff

* update comment

* Update forage-android/src/main/java/com/joinforage/forage/android/ecom/ui/ForagePINEditText.kt

Co-authored-by: Danilo Joksimovic <[email protected]>

* Rotate sample app value for customer-id

Force re-tokenization of test cards in mobile-qa-tets

* [FX-1451] Add unit tests for RosettaPinSubmitter and RosettaPinElement (#261)

* Add unit tests for ForagePinSubmitter

* Add RosettaPinElement tests!

* Add test for checking default text size

* Bring parity to corner styles

* Add comment about x-key in tests

* Fix tests from merging against Devin's changes

* Appease linter

---------

Co-authored-by: Danilo Joksimovic <[email protected]>
Co-authored-by: Danilo Joksimovic <[email protected]>
djoksimo added a commit that referenced this pull request Jun 17, 2024
* [FX-1376] Fetch rosetta-traffic-percentage to determine vault provider (#258)

* add support for reading rosetta-traffic-percentage flag to LDManager

* update LDManager.getVaultProvider tests

* re-organize and combine lines

* remove `vault-primary-traffic-percentage` flag references entirely

* update LDManager tests

* add TODO comment to clean up vgsVaultWrapper

* clean up unused imports

* [FX-1368] Re-introduce the ForageVaultWrapper  (#260)

* add ForageResponseParser

* add ForagePinSubmitter

* add ForageVaultWrapper

* use ForageVaultWrapper in ForagePINEditText

* flip logic around to reduce unnecessary diff

* update comment

* Update forage-android/src/main/java/com/joinforage/forage/android/ecom/ui/ForagePINEditText.kt

Co-authored-by: Danilo Joksimovic <[email protected]>

* Rotate sample app value for customer-id

Force re-tokenization of test cards in mobile-qa-tets

* [FX-1451] Add unit tests for RosettaPinSubmitter and RosettaPinElement (#261)

* Add unit tests for ForagePinSubmitter

* Add RosettaPinElement tests!

* Add test for checking default text size

* Bring parity to corner styles

* Add comment about x-key in tests

* Fix tests from merging against Devin's changes

* Appease linter

---------

Co-authored-by: Danilo Joksimovic <[email protected]>
Co-authored-by: Danilo Joksimovic <[email protected]>

---------

Co-authored-by: Danilo Joksimovic <[email protected]>
Co-authored-by: Danilo Joksimovic <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants