Skip to content
Permalink
Browse files

Merge pull request #267 from input-output-hk/KtorZ/265/fix-inconsiten…

…t-response-code-wallet-update

Fix inconsitent response code wallet update
  • Loading branch information...
piotr-iohk committed May 15, 2019
2 parents aecc07f + 22a9ecb commit 95bc4e277cc29ad18b47a6c82e31ac61033a3b41
@@ -30,6 +30,7 @@ module Cardano.Wallet
, ErrUpdatePassphrase (..)
, ErrWalletAlreadyExists (..)
, ErrWithRootKey (..)
, ErrWrongPassphrase(..)

-- * Construction
, newWalletLayer
@@ -24,6 +24,8 @@ import Cardano.Wallet
, ErrSubmitTx (..)
, ErrUpdatePassphrase (..)
, ErrWalletAlreadyExists (..)
, ErrWithRootKey (..)
, ErrWrongPassphrase (..)
, WalletLayer
)
import Cardano.Wallet.Api
@@ -267,6 +269,11 @@ instance LiftHandler ErrWalletAlreadyExists where
handler = \case
ErrWalletAlreadyExists _ -> err409

instance LiftHandler ErrWithRootKey where
handler = \case
ErrWithRootKeyNoRootKey _ -> err404
ErrWithRootKeyWrongPassphrase ErrWrongPassphrase -> err403

instance LiftHandler ErrCreateUnsignedTx where
handler = \case
ErrCreateUnsignedTxNoSuchWallet _ -> err404
@@ -277,12 +284,12 @@ instance LiftHandler ErrSignTx where
handler = \case
ErrSignTx _ -> err500
ErrSignTxNoSuchWallet _ -> err410
ErrSignTxWithRootKey _ -> err403
ErrSignTxWithRootKey e -> handler e

instance LiftHandler ErrSubmitTx where
handler _ = err500

instance LiftHandler ErrUpdatePassphrase where
handler = \case
ErrUpdatePassphraseNoSuchWallet _ -> err404
ErrUpdatePassphraseWithRootKey _ -> err403
ErrUpdatePassphraseWithRootKey e -> handler e
@@ -1207,20 +1207,16 @@ spec = do
let payload = updatePassPayload "Secure passphrase" "Secure passphrase2"
let delEndp = "v2/wallets" </> (getFromResponse walletId r)
_ <- request @ApiWallet ctx ("DELETE", delEndp) Default Empty

let updEndp = delEndp </> ("passphrase" :: Text)
rup <- request @ApiWallet ctx ("PUT", updEndp) Default payload
expectResponseCode @IO HTTP.status403 rup
expectResponseCode @IO HTTP.status404 rup

describe "WALLETS_UPDATE_PASS_04 - non-existing wallets" $ do
forM_ falseWalletIds $ \(title, walId) -> it title $ \ctx -> do
let payload = updatePassPayload "Secure passphrase" "Secure passphrase2"
let endpoint = "v2/wallets" </> T.pack walId </> ("passphrase" :: Text)
rup <- request @ApiWallet ctx ("PUT", endpoint) Default payload
if (title == "40 chars hex") then
expectResponseCode @IO HTTP.status403 rup
else
expectResponseCode @IO HTTP.status404 rup
expectResponseCode @IO HTTP.status404 rup

it "WALLETS_UPDATE_PASS_04 - 'almost' valid walletId" $ \ctx -> do
r <- request @ApiWallet ctx ("POST", "v2/wallets") Default simplePayload

0 comments on commit 95bc4e2

Please sign in to comment.
You can’t perform that action at this time.