From 213395ee4d6eb270dd6b4781d613edd517d2c976 Mon Sep 17 00:00:00 2001 From: Jan Cajthaml Date: Sun, 26 Dec 2021 23:19:30 +0100 Subject: [PATCH] replay create account with same payload results in ok --- bbtest/features/api.feature | 25 ++++++++++++++++++++----- services/vault-rest/go.mod | 2 +- services/vault-rest/go.sum | 4 ++-- services/vault-unit/actor/account.go | 5 +++++ services/vault-unit/go.mod | 2 +- services/vault-unit/go.sum | 4 ++-- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/bbtest/features/api.feature b/bbtest/features/api.feature index d2f089a9..b20a3db8 100644 --- a/bbtest/features/api.feature +++ b/bbtest/features/api.feature @@ -102,7 +102,7 @@ Feature: REST | method | POST | """ { - "name": "yyy", + "name": "A", "format": "test", "currency": "XXX", "isBalanceCheck": false @@ -117,16 +117,31 @@ Feature: REST | method | POST | """ { - "name": "yyy", + "name": "A", "format": "test", "currency": "XXX", - "isBalanceCheck": false + "isBalanceCheck": true } """ Then HTTP response is | key | value | | status | 409 | + When I request HTTP https://127.0.0.1/account/API + | key | value | + | method | POST | + """ + { + "name": "A", + "format": "test", + "currency": "XXX", + "isBalanceCheck": false + } + """ + Then HTTP response is + | key | value | + | status | 200 | + When I request HTTP https://127.0.0.1/account/API | key | value | | method | POST | @@ -160,7 +175,7 @@ Feature: REST | method | POST | """ { - "name": "xxx", + "name": "C", "format": "test", "currency": "XXX", "isBalanceCheck": false @@ -170,7 +185,7 @@ Feature: REST | key | value | | status | 200 | - When I request HTTP https://127.0.0.1/account/API/xxx + When I request HTTP https://127.0.0.1/account/API/C | key | value | | method | GET | Then HTTP response is diff --git a/services/vault-rest/go.mod b/services/vault-rest/go.mod index 210b17a8..db1d45ea 100644 --- a/services/vault-rest/go.mod +++ b/services/vault-rest/go.mod @@ -5,7 +5,7 @@ go 1.17 require ( github.com/coreos/go-systemd/v22 v22.3.2 github.com/jancajthaml-openbank/actor-system v1.5.4 - github.com/jancajthaml-openbank/local-fs v1.2.4 + github.com/jancajthaml-openbank/local-fs v1.2.8 github.com/labstack/echo/v4 v4.6.1 github.com/rs/xid v1.3.0 github.com/rs/zerolog v1.26.1 diff --git a/services/vault-rest/go.sum b/services/vault-rest/go.sum index a1d90dd3..bc8f26bd 100644 --- a/services/vault-rest/go.sum +++ b/services/vault-rest/go.sum @@ -7,8 +7,8 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/jancajthaml-openbank/actor-system v1.5.4 h1:1Eqn4A62uBPkEPW/0k9VxwSqdCdWKUWGlRQEQG9oPtU= github.com/jancajthaml-openbank/actor-system v1.5.4/go.mod h1:nIHD5as3cIrWQKj/YH1qJcEoGDJ9bLspb/rEfRwCv4U= -github.com/jancajthaml-openbank/local-fs v1.2.4 h1:pXzHV0T+uIHj86uSdkr7ooxjWYrHhQF7Vt0QQ2F5u9M= -github.com/jancajthaml-openbank/local-fs v1.2.4/go.mod h1:W19XcWPceSnj+ZE8UOZapMlinVIxq8xJsGogTfv80XM= +github.com/jancajthaml-openbank/local-fs v1.2.8 h1:66HspCnsoPgrrNqU/O2EShpkdcuoqDXtSOzTli3Igeo= +github.com/jancajthaml-openbank/local-fs v1.2.8/go.mod h1:W19XcWPceSnj+ZE8UOZapMlinVIxq8xJsGogTfv80XM= github.com/labstack/echo/v4 v4.6.1 h1:OMVsrnNFzYlGSdaiYGHbgWQnr+JM7NG+B9suCPie14M= github.com/labstack/echo/v4 v4.6.1/go.mod h1:RnjgMWNDB9g/HucVWhQYNQP9PvbYf6adqftqryo7s9k= github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= diff --git a/services/vault-unit/actor/account.go b/services/vault-unit/actor/account.go index 887de3a8..d9a0e9ca 100644 --- a/services/vault-unit/actor/account.go +++ b/services/vault-unit/actor/account.go @@ -86,6 +86,11 @@ func ExistAccount(s *System, state model.Account) system.ReceiverFunction { return ExistAccount(s, state) case CreateAccount: + if (msg.Format == state.Format && msg.Currency == state.Currency && msg.IsBalanceCheck == state.IsBalanceCheck) { + s.SendMessage(RespCreateAccount, context.Sender, context.Receiver) + log.Debug().Msgf("%s/Exist/CreateAccount Already Exist", state.Name) + return ExistAccount(s, state) + } s.SendMessage(FatalError, context.Sender, context.Receiver) log.Debug().Msgf("%s/Exist/CreateAccount Error", state.Name) return ExistAccount(s, state) diff --git a/services/vault-unit/go.mod b/services/vault-unit/go.mod index 194937ce..2f037fe9 100644 --- a/services/vault-unit/go.mod +++ b/services/vault-unit/go.mod @@ -5,7 +5,7 @@ go 1.17 require ( github.com/DataDog/datadog-go v4.8.3+incompatible github.com/jancajthaml-openbank/actor-system v1.5.4 - github.com/jancajthaml-openbank/local-fs v1.2.4 + github.com/jancajthaml-openbank/local-fs v1.2.8 github.com/rs/zerolog v1.26.1 github.com/stretchr/testify v1.7.0 ) diff --git a/services/vault-unit/go.sum b/services/vault-unit/go.sum index 81c56db0..b7626f4b 100644 --- a/services/vault-unit/go.sum +++ b/services/vault-unit/go.sum @@ -9,8 +9,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/jancajthaml-openbank/actor-system v1.5.4 h1:1Eqn4A62uBPkEPW/0k9VxwSqdCdWKUWGlRQEQG9oPtU= github.com/jancajthaml-openbank/actor-system v1.5.4/go.mod h1:nIHD5as3cIrWQKj/YH1qJcEoGDJ9bLspb/rEfRwCv4U= -github.com/jancajthaml-openbank/local-fs v1.2.4 h1:pXzHV0T+uIHj86uSdkr7ooxjWYrHhQF7Vt0QQ2F5u9M= -github.com/jancajthaml-openbank/local-fs v1.2.4/go.mod h1:W19XcWPceSnj+ZE8UOZapMlinVIxq8xJsGogTfv80XM= +github.com/jancajthaml-openbank/local-fs v1.2.8 h1:66HspCnsoPgrrNqU/O2EShpkdcuoqDXtSOzTli3Igeo= +github.com/jancajthaml-openbank/local-fs v1.2.8/go.mod h1:W19XcWPceSnj+ZE8UOZapMlinVIxq8xJsGogTfv80XM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/pebbe/zmq4 v1.2.7 h1:6EaX83hdFSRUEhgzSW1E/SPoTS3JeYZgYkBvwdcrA9A= github.com/pebbe/zmq4 v1.2.7/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48=