From 5596cfbf8d2f88a4e4f21b1f8b36c0bc6ca10507 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Wed, 29 Mar 2017 05:41:28 -0400 Subject: [PATCH] Don't require UIDs to be 36 characters The spec strongly recommends this, but doesn't strictly require it --- banking.go | 4 +--- creditcards.go | 4 +--- investments.go | 4 +--- profile.go | 4 +--- securities.go | 8 ++------ signon.go | 5 ----- signup.go | 4 +--- types.go | 4 +++- types_test.go | 10 +++++----- 9 files changed, 15 insertions(+), 32 deletions(-) diff --git a/banking.go b/banking.go index d990a77..e785454 100644 --- a/banking.go +++ b/banking.go @@ -21,9 +21,7 @@ func (r *StatementRequest) Name() string { } func (r *StatementRequest) Valid() (bool, error) { - if ok, err := r.TrnUID.Valid(); !ok { - return false, err - } + // TODO implement return true, nil } diff --git a/creditcards.go b/creditcards.go index 1966ef8..4ef61e7 100644 --- a/creditcards.go +++ b/creditcards.go @@ -21,9 +21,7 @@ func (r *CCStatementRequest) Name() string { } func (r *CCStatementRequest) Valid() (bool, error) { - if ok, err := r.TrnUID.Valid(); !ok { - return false, err - } + // TODO implement return true, nil } diff --git a/investments.go b/investments.go index caee811..128d092 100644 --- a/investments.go +++ b/investments.go @@ -29,9 +29,7 @@ func (r *InvStatementRequest) Name() string { } func (r *InvStatementRequest) Valid() (bool, error) { - if ok, err := r.TrnUID.Valid(); !ok { - return false, err - } + // TODO implement return true, nil } diff --git a/profile.go b/profile.go index f2e3087..e31b43f 100644 --- a/profile.go +++ b/profile.go @@ -17,9 +17,7 @@ func (r *ProfileRequest) Name() string { } func (r *ProfileRequest) Valid() (bool, error) { - if ok, err := r.TrnUID.Valid(); !ok { - return false, err - } + // TODO implement r.ClientRouting = "NONE" return true, nil } diff --git a/securities.go b/securities.go index 2eb62b4..312b4a3 100644 --- a/securities.go +++ b/securities.go @@ -32,9 +32,7 @@ func (r *SecListRequest) Name() string { } func (r *SecListRequest) Valid() (bool, error) { - if ok, err := r.TrnUID.Valid(); !ok { - return false, err - } + // TODO implement return true, nil } @@ -51,9 +49,7 @@ func (r SecListResponse) Name() string { } func (r SecListResponse) Valid() (bool, error) { - if ok, err := r.TrnUID.Valid(); !ok { - return false, err - } + // TODO implement return true, nil } diff --git a/signon.go b/signon.go index 4345045..360ae8f 100644 --- a/signon.go +++ b/signon.go @@ -47,11 +47,6 @@ func (r *SignonRequest) Valid() (bool, error) { if len(r.AppVer) < 1 || len(r.AppVer) > 4 { return false, errors.New("SONRQ>APPVER invalid length") } - if ok, err := r.ClientUID.Valid(); !ok { - if len(r.ClientUID) > 0 { // ClientUID isn't required - return false, err - } - } return true, nil } diff --git a/signup.go b/signup.go index 9815bcb..7c594b0 100644 --- a/signup.go +++ b/signup.go @@ -18,9 +18,7 @@ func (r *AcctInfoRequest) Name() string { } func (r *AcctInfoRequest) Valid() (bool, error) { - if ok, err := r.TrnUID.Valid(); !ok { - return false, err - } + // TODO implement return true, nil } diff --git a/types.go b/types.go index 2c2cfa9..0414cf7 100644 --- a/types.go +++ b/types.go @@ -216,7 +216,9 @@ func (ob *Boolean) String() string { type UID string -func (ou UID) Valid() (bool, error) { +// The OFX specification recommends that UIDs follow the standard UUID +// 36-character format +func (ou UID) RecommendedFormat() (bool, error) { if len(ou) != 36 { return false, errors.New("UID not 36 characters long") } diff --git a/types_test.go b/types_test.go index 91c46d2..c1a0c5a 100644 --- a/types_test.go +++ b/types_test.go @@ -276,21 +276,21 @@ func TestUnmarshalUID(t *testing.T) { unmarshalHelper(t, "d1cf3d3d-9ef9-4a97-b180-81706829cb04", &u, &overwritten) } -func TestUIDValid(t *testing.T) { +func TestUIDRecommendedFormat(t *testing.T) { var u ofxgo.UID = "d1cf3d3d-9ef9-4a97-b180-81706829cb04" - if ok, err := u.Valid(); !ok || err != nil { + if ok, err := u.RecommendedFormat(); !ok || err != nil { t.Fatalf("UID unexpectedly failed validation\n") } u = "d1cf3d3d-9ef9-4a97-b180-81706829cb0" - if ok, err := u.Valid(); ok || err == nil { + if ok, err := u.RecommendedFormat(); ok || err == nil { t.Fatalf("UID should have failed validation because it's too short\n") } u = "d1cf3d3d-9ef94a97-b180-81706829cb04" - if ok, err := u.Valid(); ok || err == nil { + if ok, err := u.RecommendedFormat(); ok || err == nil { t.Fatalf("UID should have failed validation because it's missing hyphens\n") } u = "d1cf3d3d-9ef9-4a97-b180981706829cb04" - if ok, err := u.Valid(); ok || err == nil { + if ok, err := u.RecommendedFormat(); ok || err == nil { t.Fatalf("UID should have failed validation because its hyphens have been replaced\n") } }