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

import (
	"path/filepath"
	"time"

	"github.com/Sirupsen/logrus"
	"github.com/privacybydesign/irmago/internal/test"
Sietse Ringers's avatar
Sietse Ringers committed
9
10
	"github.com/privacybydesign/irmago/server"
	"github.com/privacybydesign/irmago/server/irmaserver"
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() {
Sietse Ringers's avatar
Sietse Ringers committed
34
	irmaserver.Stop()
35
36
}

37
38
39
40
41
42
43
var IrmaServerConfiguration = &irmaserver.Configuration{
	Configuration: &server.Configuration{
		Logger:                logger,
		IrmaConfigurationPath: filepath.Join(testdata, "irma_configuration"),
		IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
	},
	Port: 48682,
44
45
}

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var JwtServerConfiguration = &irmaserver.Configuration{
	Configuration: &server.Configuration{
		Logger:                logger,
		IrmaConfigurationPath: filepath.Join(testdata, "irma_configuration"),
		IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
	},
	Port: 48682,
	AuthenticateRequestors: true,
	GlobalPermissions: irmaserver.Permissions{
		Disclosing: []string{"*"},
		Signing:    []string{"*"},
		Issuing:    []string{"*"},
	},
	Requestors: map[string]irmaserver.Requestor{
		"requestor1": irmaserver.Requestor{
			AuthenticationMethod: irmaserver.AuthenticationMethodPublicKey,
			AuthenticationKey:    filepath.Join(testdata, "jwtkeys", "requestor1.pem"),
		},
		"requestor2": {
65
			AuthenticationMethod: irmaserver.AuthenticationMethodToken,
66
67
68
			AuthenticationKey:    "xa6=*&9?8jeUu5>.f-%rVg`f63pHim",
		},
	},
69
	JwtPrivateKey: filepath.Join(testdata, "jwtkeys", "sk.pem"),
70
}