server_test.go 2.15 KB
Newer Older
1
2
3
4
5
6
7
package sessiontest

import (
	"path/filepath"
	"time"

	"github.com/privacybydesign/irmago/internal/test"
Sietse Ringers's avatar
Sietse Ringers committed
8
9
	"github.com/privacybydesign/irmago/server"
	"github.com/privacybydesign/irmago/server/irmaserver"
10
	"github.com/sirupsen/logrus"
11
12
)

13
14
15
16
var (
	logger   = logrus.New()
	testdata = test.FindTestdataFolder(nil)
)
17

18
func init() {
19
20
	logger.Level = logrus.WarnLevel
	logger.Formatter = &logrus.TextFormatter{}
21
}
22

23
func StartIrmaServer(configuration *irmaserver.Configuration) {
24
	go func() {
25
		err := irmaserver.Start(configuration)
26
27
28
		if err != nil {
			panic("Starting server failed: " + err.Error())
		}
29
	}()
30
	time.Sleep(100 * time.Millisecond) // Give server time to start
31
32
}

Sietse Ringers's avatar
Sietse Ringers committed
33
func StopIrmaServer() {
34
	_ = irmaserver.Stop()
35
36
}

37
38
var IrmaServerConfiguration = &irmaserver.Configuration{
	Configuration: &server.Configuration{
Sietse Ringers's avatar
Sietse Ringers committed
39
		URL:                   "http://localhost:48682/irma",
40
		Logger:                logger,
41
		SchemesPath:           filepath.Join(testdata, "irma_configuration"),
42
43
		IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
	},
44
	DisableRequestorAuthentication: true,
45
	Port: 48682,
46
47
}

48
49
var JwtServerConfiguration = &irmaserver.Configuration{
	Configuration: &server.Configuration{
Sietse Ringers's avatar
Sietse Ringers committed
50
		URL:                   "http://localhost:48682/irma",
51
		Logger:                logger,
52
		SchemesPath:           filepath.Join(testdata, "irma_configuration"),
53
54
55
		IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
	},
	Port: 48682,
56
	DisableRequestorAuthentication: false,
57
58
59
60
61
62
	GlobalPermissions: irmaserver.Permissions{
		Disclosing: []string{"*"},
		Signing:    []string{"*"},
		Issuing:    []string{"*"},
	},
	Requestors: map[string]irmaserver.Requestor{
Sietse Ringers's avatar
Sietse Ringers committed
63
		"requestor1": {
64
65
66
67
			AuthenticationMethod: irmaserver.AuthenticationMethodPublicKey,
			AuthenticationKey:    filepath.Join(testdata, "jwtkeys", "requestor1.pem"),
		},
		"requestor2": {
68
			AuthenticationMethod: irmaserver.AuthenticationMethodToken,
69
70
			AuthenticationKey:    "xa6=*&9?8jeUu5>.f-%rVg`f63pHim",
		},
71
72
73
74
		"requestor3": {
			AuthenticationMethod: irmaserver.AuthenticationMethodHmac,
			AuthenticationKey:    "eGE2PSomOT84amVVdTU+LmYtJXJWZ2BmNjNwSGltCg==",
		},
75
	},
76
	JwtPrivateKey: filepath.Join(testdata, "jwtkeys", "sk.pem"),
77
}