| 1 | package bankinfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/ |
| 2 | |
| 3 | import ( |
| 4 | "reflectscip-go gomod github.com/golang/go/src go1.18 reflect/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.18 testing/" |
| 7 | |
| 8 | "github.com/kr/prettyscip-go gomod github.com/kr/pretty v0.2.0 `github.com/kr/pretty`/" |
| 9 | ) |
| 10 | |
| 11 | func Test_ParseBankInfosscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/Test_ParseBankInfos().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | data string |
| 15 | wantResult []BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo# |
| 16 | wantError error |
| 17 | }{ |
| 18 | { |
| 19 | name: "success", |
| 20 | data: `Nr.;BLZ;Institut;Ort;RZ;Organisation;HBCI-Zugang DNS;HBCI- Zugang IP-Adresse;HBCI-Version;DDV;RDH-1;RDH-2;RDH-3;RDH-4;RDH-5;RDH-6;RDH-7;RDH-8;RDH-9;RDH-10;RAH-7;RAH-9;RAH-10;PIN/TAN-Zugang URL;Version;Datum letzte Änderung;;;;; |
| 21 | 2;10010010;Postbank;Berlin;eigenes Rechenzentrum;BdB;;;;;;;;;;;;;;;;;;https://hbci.postbank.de/banking/hbci.do;FinTS V3.0;30.04.2015;;;;; |
| 22 | 3;10020200;BHF-Bank AG;Berlin;Bank-Verlag GmbH;BdB;hbciserver.bankverlag.de;nicht unterstützt;3.0;;ja;;ja;;ja;;;;;;;;;https://www.bv-activebanking.de/hbciTunnel/hbciTransfer.jsp;FinTS V3.0;;;;;;`, |
| 23 | wantResult: []BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#{ |
| 24 | { |
| 25 | BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.: "10010010", |
| 26 | VersionNumberscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#VersionNumber.: "", |
| 27 | URLscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#URL.: "https://hbci.postbank.de/banking/hbci.do", |
| 28 | VersionNamescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#VersionName.: "FinTS V3.0", |
| 29 | Institutescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#Institute.: "Postbank", |
| 30 | Cityscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#City.: "Berlin", |
| 31 | LastChangedscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#LastChanged.: "30.04.2015", |
| 32 | }, |
| 33 | { |
| 34 | BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.: "10020200", |
| 35 | VersionNumberscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#VersionNumber.: "3.0", |
| 36 | URLscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#URL.: "https://www.bv-activebanking.de/hbciTunnel/hbciTransfer.jsp", |
| 37 | VersionNamescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#VersionName.: "FinTS V3.0", |
| 38 | Institutescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#Institute.: "BHF-Bank AG", |
| 39 | Cityscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#City.: "Berlin", |
| 40 | LastChangedscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#LastChanged.: "", |
| 41 | }, |
| 42 | }, |
| 43 | }, |
| 44 | } |
| 45 | |
| 46 | for _, tt := range tests { |
| 47 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 48 | info, err := ParseBankInfosscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/ParseBankInfos().(stringsscip-go gomod github.com/golang/go/src go1.18 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.18 strings/NewReader().(tt.data)) |
| 49 | |
| 50 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(tt.wantError, err) { |
| 51 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("Expected error to equal\n%v\n\tgot\n%v", tt.wantError, err) |
| 52 | } |
| 53 | |
| 54 | if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(tt.wantResult, info) { |
| 55 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("Results differ:\n%v", prettyscip-go gomod github.com/kr/pretty v0.2.0 `github.com/kr/pretty`/.Diffscip-go gomod github.com/kr/pretty v0.2.0 `github.com/kr/pretty`/Diff().(tt.wantResult, info)) |
| 56 | } |
| 57 | }) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func TestFindByBankIdscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/TestFindByBankId().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 62 | datascip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/data. = []BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#{ |
| 63 | {BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.: "1000000", URLscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#URL.: "1"}, |
| 64 | {BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.: "2000000", URLscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#URL.: "2"}, |
| 65 | {BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.: "3000000", URLscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#URL.: "3"}, |
| 66 | } |
| 67 | |
| 68 | var url string |
| 69 | |
| 70 | url = FindByBankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/FindByBankID().("1000000").URLscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#URL. |
| 71 | |
| 72 | if url != "1" { |
| 73 | t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("Expected url to equal %q, got %q\n", "1", url) |
| 74 | t.Failscip-go gomod github.com/golang/go/src go1.18 testing/common#Fail().() |
| 75 | } |
| 76 | |
| 77 | url = FindByBankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/FindByBankID().("2000000").URLscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#URL. |
| 78 | |
| 79 | if url != "2" { |
| 80 | t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("Expected url to equal %q, got %q\n", "2", url) |
| 81 | t.Failscip-go gomod github.com/golang/go/src go1.18 testing/common#Fail().() |
| 82 | } |
| 83 | |
| 84 | url = FindByBankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/FindByBankID().("3000000").URLscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#URL. |
| 85 | |
| 86 | if url != "3" { |
| 87 | t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("Expected url to equal %q, got %q\n", "3", url) |
| 88 | t.Failscip-go gomod github.com/golang/go/src go1.18 testing/common#Fail().() |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | func TestHbciVersionscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/TestHbciVersion().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 93 | tests := []struct { |
| 94 | versionNumber string |
| 95 | versionName string |
| 96 | result int |
| 97 | }{ |
| 98 | { |
| 99 | versionNumber: "3.0", |
| 100 | versionName: "FinTS V3.0", |
| 101 | result: 300, |
| 102 | }, |
| 103 | { |
| 104 | versionNumber: "2.2", |
| 105 | versionName: "HBCI 2.2 Erweiterung PIN/TAN V1.01", |
| 106 | result: 220, |
| 107 | }, |
| 108 | { |
| 109 | versionNumber: "", |
| 110 | versionName: "FinTS V3.0", |
| 111 | result: 300, |
| 112 | }, |
| 113 | { |
| 114 | versionNumber: "", |
| 115 | versionName: "HBCI 2.2 Erweiterung PIN/TAN V1.01", |
| 116 | result: 220, |
| 117 | }, |
| 118 | { |
| 119 | versionNumber: "2.2", |
| 120 | versionName: "FinTS V3.0", |
| 121 | result: 300, |
| 122 | }, |
| 123 | } |
| 124 | |
| 125 | for _, test := range tests { |
| 126 | |
| 127 | version, err := hbciVersionscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/hbciVersion().(test.versionName, test.versionNumber) |
| 128 | |
| 129 | if err != nil { |
| 130 | t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("Expected no error, got %q\n", err) |
| 131 | t.Failscip-go gomod github.com/golang/go/src go1.18 testing/common#Fail().() |
| 132 | } |
| 133 | |
| 134 | expectedVersion := test.result |
| 135 | |
| 136 | if expectedVersion != version { |
| 137 | t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("Expected version to equal %d, got %d\n", expectedVersion, version) |
| 138 | t.Failscip-go gomod github.com/golang/go/src go1.18 testing/common#Fail().() |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | func TestSortableBankInfosSortInterfacescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/TestSortableBankInfosSortInterface().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 144 | sorted := SortableBankInfosscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#{ |
| 145 | BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#{BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.: "30000000"}, |
| 146 | BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#{BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.: "10000000"}, |
| 147 | BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#{BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.: "20000000"}, |
| 148 | } |
| 149 | |
| 150 | length := sorted.Lenscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#Len().() |
| 151 | |
| 152 | if len(sorted) != length { |
| 153 | t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("Expected length to equal %d, got %d\n", len(sorted), length) |
| 154 | t.Failscip-go gomod github.com/golang/go/src go1.18 testing/common#Fail().() |
| 155 | } |
| 156 | |
| 157 | less := sorted.Lessscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#Less().(0, 1) |
| 158 | |
| 159 | if less { |
| 160 | t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("Expected first entry not to be less than second, but was\n") |
| 161 | t.Failscip-go gomod github.com/golang/go/src go1.18 testing/common#Fail().() |
| 162 | } |
| 163 | |
| 164 | sorted.Swapscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#Swap().(0, 1) |
| 165 | |
| 166 | if sorted[0].BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID. != "10000000" { |
| 167 | t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("Expected first entry to have BankId '10000000', but was %q\n", sorted[0].BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.) |
| 168 | t.Failscip-go gomod github.com/golang/go/src go1.18 testing/common#Fail().() |
| 169 | } |
| 170 | |
| 171 | if sorted[1].BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID. != "30000000" { |
| 172 | t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("Expected first entry to have BankId '30000000', but was %q\n", sorted[1].BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID.) |
| 173 | t.Failscip-go gomod github.com/golang/go/src go1.18 testing/common#Fail().() |
| 174 | } |
| 175 | } |