Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rkbalgi committed Oct 6, 2020
1 parent 56b60bc commit 0a3f561
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
Binary file modified internal/db/isosim.bdb
Binary file not shown.
18 changes: 9 additions & 9 deletions internal/iso/server/iso_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"encoding/hex"
"encoding/json"
netutil "github.com/rkbalgi/libiso/net"
isov2 "github.com/rkbalgi/libiso/v2/iso8583"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"isosim/internal/db"
"isosim/internal/iso"
"strconv"
"testing"
)
Expand All @@ -20,11 +20,11 @@ func Test_IsoServer_MessageProcessing(t *testing.T) {
t.Fatal(err)
}

if err := iso.ReadSpecs("../../../test/testdata/specs"); err != nil {
if err := isov2.ReadSpecs("../../../test/testdata/specs"); err != nil {
t.Fatal(err)
}
specName := "Iso8583-MiniSpec"
spec := iso.SpecByName(specName)
spec := isov2.SpecByName(specName)
if spec == nil {
t.Fatal("No such spec - " + specName)
}
Expand Down Expand Up @@ -67,7 +67,7 @@ func Test_IsoServer_MessageProcessing(t *testing.T) {
if err := ncc.OpenConnection(); err != nil {
t.Fatal(err)
}
var parsedMsg *iso.ParsedMsg
var parsedMsg *isov2.ParsedMsg
t.Log(string(dsData))

tc := &db.TestCase{}
Expand All @@ -84,30 +84,30 @@ func Test_IsoServer_MessageProcessing(t *testing.T) {
t.Fatal(err)
}

isoReqMsg := iso.FromParsedMsg(parsedMsg)
isoReqMsg := isov2.FromParsedMsg(parsedMsg)

t.Run("with amount 900", func(t *testing.T) {
isoReqMsg.Bitmap().Set(4, "000000000900")
sendAndVerify(t, ncc, spec, isoReqMsg, "100")

})
t.Run("with amount 200", func(t *testing.T) {
isoReqMsg := iso.FromParsedMsg(parsedMsg)
isoReqMsg := isov2.FromParsedMsg(parsedMsg)
isoReqMsg.Bitmap().Set(4, "000000000200")
sendAndVerify(t, ncc, spec, isoReqMsg, "200")

})

t.Run("with amount 100", func(t *testing.T) {
isoReqMsg := iso.FromParsedMsg(parsedMsg)
isoReqMsg := isov2.FromParsedMsg(parsedMsg)
isoReqMsg.Bitmap().Set(4, "000000000100")
sendAndVerify(t, ncc, spec, isoReqMsg, "000")

})

}

func sendAndVerify(t *testing.T, ncc *netutil.NetCatClient, spec *iso.Spec, isoReqMsg *iso.Iso, expectedF39 string) {
func sendAndVerify(t *testing.T, ncc *netutil.NetCatClient, spec *isov2.Spec, isoReqMsg *isov2.Iso, expectedF39 string) {

data, _, err := isoReqMsg.Assemble()
if err != nil {
Expand All @@ -126,7 +126,7 @@ func sendAndVerify(t *testing.T, ncc *netutil.NetCatClient, spec *iso.Spec, isoR
if err != nil {
t.Fatal(err)
}
isoResponseMsg := iso.FromParsedMsg(pResponseMsg)
isoResponseMsg := isov2.FromParsedMsg(pResponseMsg)
assert.Equal(t, expectedF39, isoResponseMsg.Bitmap().Get(39).Value())

}
5 changes: 2 additions & 3 deletions internal/services/crypto/http_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"github.com/go-kit/kit/log/logrus"
"github.com/go-kit/kit/transport"
httptransport "github.com/go-kit/kit/transport/http"
isov2 "github.com/rkbalgi/libiso/v2/iso8583"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"io/ioutil"
"isosim/internal/iso"

"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -89,7 +88,7 @@ func Test_PinGenHTTPService(t *testing.T) {
t.Run("MAC Generation X9.19", func(t *testing.T) {

pgr := &MacGenRequest{
MacAlgo: iso.ANSIX9_19,
MacAlgo: isov2.ANSIX9_19,
MacKey: "76850752AD7307ADE554D06D3BA73279",
MacData: "8155ADCC76B2FB0064F2C40037710477CE13C4BF75FD3DADF13B6D137AC1B915",
}
Expand Down
8 changes: 4 additions & 4 deletions internal/services/data/json_field_rep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ package data
import (
"encoding/json"
"fmt"
isov2 "github.com/rkbalgi/libiso/v2/iso8583"
log "github.com/sirupsen/logrus"
"isosim/internal/iso"
"path/filepath"
"testing"
)

func init() {
log.SetLevel(log.TraceLevel)
err := iso.ReadSpecs(filepath.Join("..", "..", "..", "test", "testdata", "specs"))
err := isov2.ReadSpecs(filepath.Join("..", "..", "..", "test", "testdata", "specs"))
if err != nil {
fmt.Print(err)
}
}
func TestNewJsonMessageTemplate(t *testing.T) {

msg := iso.SpecByName("ISO8583-Test").MessageByName("1100 - Authorization")
msg := isov2.SpecByName("ISO8583-Test").MessageByName("1100 - Authorization")

jmt := NewJsonMessageTemplate(msg)
if jsonData, err := json.Marshal(jmt); err != nil {
Expand All @@ -29,7 +29,7 @@ func TestNewJsonMessageTemplate(t *testing.T) {

}

func printChildren(f *iso.Field) {
func printChildren(f *isov2.Field) {
if f.HasChildren() {
for _, c := range f.Children {
fmt.Println("->" + c.Name)
Expand Down
6 changes: 3 additions & 3 deletions internal/services/websim/http_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/go-kit/kit/log/logrus"
"github.com/go-kit/kit/transport"
httptransport "github.com/go-kit/kit/transport/http"
isov2 "github.com/rkbalgi/libiso/v2/iso8583"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"io/ioutil"
"isosim/internal/db"
"isosim/internal/iso"
"net/http"
"net/http/httptest"
"strconv"
Expand Down Expand Up @@ -65,7 +65,7 @@ func Test_WebsimHttpService(t *testing.T) {
t.Fatal(err)
}

if err := iso.ReadSpecs("../../../test/testdata/specs"); err != nil {
if err := isov2.ReadSpecs("../../../test/testdata/specs"); err != nil {
t.Fatal(err)
}
s := httptest.NewServer(testHttpHandler{})
Expand Down Expand Up @@ -99,7 +99,7 @@ func Test_WebsimHttpService(t *testing.T) {
})

t.Run("Get all message for spec - Success", func(t *testing.T) {
spec := iso.SpecByName("Iso8583-MiniSpec")
spec := isov2.SpecByName("Iso8583-MiniSpec")
t.Log(spec.ID)
req, err := http.NewRequest(http.MethodGet, s.URL+URLMessages4Spec+"/"+strconv.Itoa(spec.ID), nil)
if err != nil {
Expand Down

0 comments on commit 0a3f561

Please sign in to comment.