Skip to content

Commit

Permalink
Add test to confirm delay for unsuccessful authentications.
Browse files Browse the repository at this point in the history
Add integration test to confirm that an unsuccessful attempt to
authenticate results in a delay of minimumAuthenticationFailureTime or
longer.
  • Loading branch information
jonathanknowles committed Aug 3, 2020
1 parent a44c168 commit ec40b5c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Expand Up @@ -26,6 +26,8 @@ import Cardano.Mnemonic
, genEntropy
, mnemonicToText
)
import Cardano.Wallet
( minimumExecutionTimeOnAuthFailure )
import Cardano.Wallet.Api.Types
( AddressAmount (..)
, ApiByronWallet
Expand Down Expand Up @@ -68,6 +70,8 @@ import Data.Text
( Text )
import Data.Text.Class
( toText )
import Data.Time
( diffUTCTime, getCurrentTime )
import Data.Word
( Word64 )
import Test.Hspec
Expand Down Expand Up @@ -933,6 +937,19 @@ spec = do
rup <- request @ApiWallet ctx endpoint headers payload
verify rup expectations

it "WALLETS_UPDATE_PASS_08 - Delay on authentication failure" $ \ctx -> do
w <- emptyWalletWith ctx
("Wallet to update pass", "cardano-passphrase", 20)
let payload = updatePassPayload "incorrect-passphrase" "whatever-pass"
startTime <- getCurrentTime
rup <- request @ApiWallet ctx
(Link.putWalletPassphrase @'Shelley w) Default payload
endTime <- getCurrentTime
let timeElapsed = endTime `diffUTCTime` startTime
timeElapsed `shouldSatisfy` (> minimumExecutionTimeOnAuthFailure)
expectResponseCode @IO HTTP.status403 rup
expectErrorMessage errMsg403WrongPass rup

it "WALLETS_COIN_SELECTION_01 - \
\A singleton payment is included in the coin selection output." $
\ctx -> do
Expand Down
1 change: 1 addition & 0 deletions lib/core/src/Cardano/Wallet.hs
Expand Up @@ -164,6 +164,7 @@ module Cardano.Wallet
, ErrStartTimeLaterThanEndTime (..)

-- ** Root Key
, minimumExecutionTimeOnAuthFailure
, withRootKey
, ErrWithRootKey (..)
, ErrWrongPassphrase (..)
Expand Down

0 comments on commit ec40b5c

Please sign in to comment.