summaryrefslogtreecommitdiff
path: root/order_test.go
blob: ff8119c9f79aedb9bf6545b7ee261c58f5668387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package libebics

import (
	"io"
	"net/http"
	"path/filepath"
	"strings"
	"testing"
)

func TestSendIniRequest(t *testing.T) {
	signatureCertificate, err := ReadCertificateFromFile(filepath.Join("certs", "signature_cert.pem"), A005)
	if err != nil {
		t.Error(err.Error())
	}

	ini, err := GenerateIniRequest(*signatureCertificate)
	if err != nil {
		t.Error(err.Error())
	}

	t.Log(ini)

	resp, err := http.Post(
		"https://ebics-test.multivia-suite.de/MVB_ENT/ebicsweb",
		"text/xml; charset=UTF-8",
		strings.NewReader(ini),
	)
	if err != nil {
		t.Error(err.Error())
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	t.Log(string(body))
}

func TestSendHiaRequest(t *testing.T) {
	authenticationCertificate, err := ReadCertificateFromFile(filepath.Join("certs", "authentication_cert.pem"), X002)
	if err != nil {
		t.Error(err.Error())
	}

	encryptionCertificate, err := ReadCertificateFromFile(filepath.Join("certs", "encryption_cert.pem"), E002)
	if err != nil {
		t.Error(err.Error())
	}

	ini, err := GenerateHiaRequest(*authenticationCertificate, *encryptionCertificate)
	if err != nil {
		t.Error(err.Error())
	}

	t.Log(ini)

	resp, err := http.Post(
		"https://ebics-test.multivia-suite.de/MVB_ENT/ebicsweb",
		"text/xml; charset=UTF-8",
		strings.NewReader(ini),
	)
	if err != nil {
		t.Error(err.Error())
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	t.Log(string(body))
}