Commit 8620d499 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Update session tests

parent 795f0962
...@@ -11,8 +11,8 @@ import ( ...@@ -11,8 +11,8 @@ import (
) )
func requestorSessionHelper(t *testing.T, request irma.SessionRequest) *server.SessionResult { func requestorSessionHelper(t *testing.T, request irma.SessionRequest) *server.SessionResult {
StartIrmaClientServer(t) StartIrmaServer(t)
defer StopIrmaClientServer() defer StopIrmaServer()
client := parseStorage(t) client := parseStorage(t)
defer test.ClearTestStorage(t) defer test.ClearTestStorage(t)
......
...@@ -9,14 +9,15 @@ import ( ...@@ -9,14 +9,15 @@ import (
"github.com/privacybydesign/irmago/internal/test" "github.com/privacybydesign/irmago/internal/test"
"github.com/privacybydesign/irmago/server" "github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/irmaserver" "github.com/privacybydesign/irmago/server/irmaserver"
"github.com/privacybydesign/irmago/server/requestorserver"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
var ( var (
httpServer *http.Server httpServer *http.Server
irmaServer *irmaserver.Server irmaServer *irmaserver.Server
combinedServer *irmaserver.Server requestorServer *requestorserver.Server
logger = logrus.New() logger = logrus.New()
testdata = test.FindTestdataFolder(nil) testdata = test.FindTestdataFolder(nil)
...@@ -27,24 +28,24 @@ func init() { ...@@ -27,24 +28,24 @@ func init() {
logger.Formatter = &logrus.TextFormatter{} logger.Formatter = &logrus.TextFormatter{}
} }
func StartIrmaServer(configuration *irmaserver.Configuration) { func StartRequestorServer(configuration *requestorserver.Configuration) {
go func() { go func() {
var err error var err error
if combinedServer, err = irmaserver.New(configuration); err != nil { if requestorServer, err = requestorserver.New(configuration); err != nil {
panic(err) panic(err)
} }
if err = combinedServer.Start(configuration); err != nil { if err = requestorServer.Start(configuration); err != nil {
panic("Starting server failed: " + err.Error()) panic("Starting server failed: " + err.Error())
} }
}() }()
time.Sleep(100 * time.Millisecond) // Give server time to start time.Sleep(100 * time.Millisecond) // Give server time to start
} }
func StopIrmaServer() { func StopRequestorServer() {
_ = combinedServer.Stop() _ = requestorServer.Stop()
} }
func StartIrmaClientServer(t *testing.T) { func StartIrmaServer(t *testing.T) {
testdata := test.FindTestdataFolder(t) testdata := test.FindTestdataFolder(t)
logger := logrus.New() logger := logrus.New()
...@@ -69,11 +70,11 @@ func StartIrmaClientServer(t *testing.T) { ...@@ -69,11 +70,11 @@ func StartIrmaClientServer(t *testing.T) {
}() }()
} }
func StopIrmaClientServer() { func StopIrmaServer() {
_ = httpServer.Close() _ = httpServer.Close()
} }
var IrmaServerConfiguration = &irmaserver.Configuration{ var IrmaServerConfiguration = &requestorserver.Configuration{
Configuration: &server.Configuration{ Configuration: &server.Configuration{
URL: "http://localhost:48682/irma", URL: "http://localhost:48682/irma",
Logger: logger, Logger: logger,
...@@ -84,7 +85,7 @@ var IrmaServerConfiguration = &irmaserver.Configuration{ ...@@ -84,7 +85,7 @@ var IrmaServerConfiguration = &irmaserver.Configuration{
Port: 48682, Port: 48682,
} }
var JwtServerConfiguration = &irmaserver.Configuration{ var JwtServerConfiguration = &requestorserver.Configuration{
Configuration: &server.Configuration{ Configuration: &server.Configuration{
URL: "http://localhost:48682/irma", URL: "http://localhost:48682/irma",
Logger: logger, Logger: logger,
...@@ -94,22 +95,22 @@ var JwtServerConfiguration = &irmaserver.Configuration{ ...@@ -94,22 +95,22 @@ var JwtServerConfiguration = &irmaserver.Configuration{
Port: 48682, Port: 48682,
DisableRequestorAuthentication: false, DisableRequestorAuthentication: false,
MaxRequestAge: 3, MaxRequestAge: 3,
Permissions: irmaserver.Permissions{ Permissions: requestorserver.Permissions{
Disclosing: []string{"*"}, Disclosing: []string{"*"},
Signing: []string{"*"}, Signing: []string{"*"},
Issuing: []string{"*"}, Issuing: []string{"*"},
}, },
Requestors: map[string]irmaserver.Requestor{ Requestors: map[string]requestorserver.Requestor{
"requestor1": { "requestor1": {
AuthenticationMethod: irmaserver.AuthenticationMethodPublicKey, AuthenticationMethod: requestorserver.AuthenticationMethodPublicKey,
AuthenticationKeyFile: filepath.Join(testdata, "jwtkeys", "requestor1.pem"), AuthenticationKeyFile: filepath.Join(testdata, "jwtkeys", "requestor1.pem"),
}, },
"requestor2": { "requestor2": {
AuthenticationMethod: irmaserver.AuthenticationMethodToken, AuthenticationMethod: requestorserver.AuthenticationMethodToken,
AuthenticationKey: "xa6=*&9?8jeUu5>.f-%rVg`f63pHim", AuthenticationKey: "xa6=*&9?8jeUu5>.f-%rVg`f63pHim",
}, },
"requestor3": { "requestor3": {
AuthenticationMethod: irmaserver.AuthenticationMethodHmac, AuthenticationMethod: requestorserver.AuthenticationMethodHmac,
AuthenticationKey: "eGE2PSomOT84amVVdTU+LmYtJXJWZ2BmNjNwSGltCg==", AuthenticationKey: "eGE2PSomOT84amVVdTU+LmYtJXJWZ2BmNjNwSGltCg==",
}, },
}, },
......
...@@ -187,8 +187,8 @@ func sessionHelper(t *testing.T, request irma.SessionRequest, sessiontype string ...@@ -187,8 +187,8 @@ func sessionHelper(t *testing.T, request irma.SessionRequest, sessiontype string
} }
if TestType == "irmaserver" || TestType == "irmaserver-jwt" || TestType == "irmaserver-hmac-jwt" { if TestType == "irmaserver" || TestType == "irmaserver-jwt" || TestType == "irmaserver-hmac-jwt" {
StartIrmaServer(JwtServerConfiguration) StartRequestorServer(JwtServerConfiguration)
defer StopIrmaServer() defer StopRequestorServer()
} }
qr := startSession(t, request, sessiontype) qr := startSession(t, request, sessiontype)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment