server_test.go 1.99 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
var IrmaServerConfiguration = &irmaserver.Configuration{
	Configuration: &server.Configuration{
Sietse Ringers's avatar
Sietse Ringers committed
39
		URL:                   "http://localhost:48682/irma",
40
41
42
43
		Logger:                logger,
		IrmaConfigurationPath: filepath.Join(testdata, "irma_configuration"),
		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
52
53
54
55
		Logger:                logger,
		IrmaConfigurationPath: filepath.Join(testdata, "irma_configuration"),
		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
71
			AuthenticationKey:    "xa6=*&9?8jeUu5>.f-%rVg`f63pHim",
		},
	},
72
	JwtPrivateKey: filepath.Join(testdata, "jwtkeys", "sk.pem"),
73
}