-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add min amount validation to server side one time payments (#6665)
We already have client side validation for this, but we'd like to enforce server side too as this makes us more robust. I've tested this in CODE. In order to do this I had to temporarily remove the client side validation. The error message we show in this case is quite generic, but I think in general we don't expect users to hit this as the client side validation should kick in before the request even makes it to the backend.
- Loading branch information
Showing
5 changed files
with
44 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
support-payment-api/src/test/scala/model/CurrencyTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package model | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.must.Matchers | ||
|
||
class CurrencyTest extends AnyFlatSpec with Matchers { | ||
"exceedsMaxAmount" should "return true if the amount is greater than the allowed range" in { | ||
Currency.isAmountOutOfBounds(2100, Currency.GBP) mustBe true | ||
} | ||
|
||
it should "return true if the amount is below the allowed range" in { | ||
Currency.isAmountOutOfBounds(0.5, Currency.GBP) mustBe true | ||
} | ||
|
||
it should "return false if the amount is within the allowed range" in { | ||
Currency.isAmountOutOfBounds(100, Currency.GBP) mustBe false | ||
} | ||
|
||
it should "allow the amount to be 4% larger than the nominal max to allow for covering transaction cost" in { | ||
Currency.isAmountOutOfBounds(2080, Currency.GBP) mustBe false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters