Commit 94b9d8ce authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Rename test manual session handler struct

parent 394c10f0
...@@ -132,11 +132,13 @@ type SessionResult struct { ...@@ -132,11 +132,13 @@ type SessionResult struct {
Result *irma.SignedMessage Result *irma.SignedMessage
} }
type ManualSessionHandler struct { // ManualTestHandler embeds a TestHandler to inherit its methods.
// Below we overwrite the methods that require behaviour specific to manual settings.
type ManualTestHandler struct {
TestHandler TestHandler
} }
func (th *ManualSessionHandler) Success(result string) { func (th *ManualTestHandler) Success(result string) {
if len(result) == 0 { if len(result) == 0 {
th.c <- nil th.c <- nil
return return
...@@ -155,7 +157,7 @@ func (th *ManualSessionHandler) Success(result string) { ...@@ -155,7 +157,7 @@ func (th *ManualSessionHandler) Success(result string) {
Result: irmaSignedMessage, Result: irmaSignedMessage,
} }
} }
func (th *ManualSessionHandler) RequestSignaturePermission(request irma.SignatureRequest, requesterName string, ph PermissionHandler) { func (th *ManualTestHandler) RequestSignaturePermission(request irma.SignatureRequest, requesterName string, ph PermissionHandler) {
var attributes []*irma.AttributeIdentifier var attributes []*irma.AttributeIdentifier
for _, cand := range request.Candidates { for _, cand := range request.Candidates {
attributes = append(attributes, cand[0]) attributes = append(attributes, cand[0])
...@@ -163,14 +165,14 @@ func (th *ManualSessionHandler) RequestSignaturePermission(request irma.Signatur ...@@ -163,14 +165,14 @@ func (th *ManualSessionHandler) RequestSignaturePermission(request irma.Signatur
c := irma.DisclosureChoice{attributes} c := irma.DisclosureChoice{attributes}
ph(true, &c) ph(true, &c)
} }
func (th *ManualSessionHandler) RequestIssuancePermission(request irma.IssuanceRequest, issuerName string, ph PermissionHandler) { func (th *ManualTestHandler) RequestIssuancePermission(request irma.IssuanceRequest, issuerName string, ph PermissionHandler) {
ph(true, nil) ph(true, nil)
} }
// These handlers should not be called, fail test if they are called // These handlers should not be called, fail test if they are called
func (th *ManualSessionHandler) RequestSchemeManagerPermission(manager *irma.SchemeManager, callback func(proceed bool)) { func (th *ManualTestHandler) RequestSchemeManagerPermission(manager *irma.SchemeManager, callback func(proceed bool)) {
th.Failure(&irma.SessionError{Err: errors.New("Unexpected session type")}) th.Failure(&irma.SessionError{Err: errors.New("Unexpected session type")})
} }
func (th *ManualSessionHandler) RequestVerificationPermission(request irma.DisclosureRequest, verifierName string, ph PermissionHandler) { func (th *ManualTestHandler) RequestVerificationPermission(request irma.DisclosureRequest, verifierName string, ph PermissionHandler) {
th.Failure(&irma.SessionError{Err: errors.New("Unexpected session type")}) th.Failure(&irma.SessionError{Err: errors.New("Unexpected session type")})
} }
...@@ -11,9 +11,9 @@ import ( ...@@ -11,9 +11,9 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
// Create a ManualSessionHandler for unit tests // Create a ManualTestHandler for unit tests
func createManualSessionHandler(t *testing.T, client *Client) *ManualSessionHandler { func createManualSessionHandler(t *testing.T, client *Client) *ManualTestHandler {
return &ManualSessionHandler{ return &ManualTestHandler{
TestHandler: TestHandler{ TestHandler: TestHandler{
t: t, t: t,
c: make(chan *SessionResult), c: make(chan *SessionResult),
...@@ -22,7 +22,7 @@ func createManualSessionHandler(t *testing.T, client *Client) *ManualSessionHand ...@@ -22,7 +22,7 @@ func createManualSessionHandler(t *testing.T, client *Client) *ManualSessionHand
} }
} }
func manualSessionHelper(t *testing.T, client *Client, h *ManualSessionHandler, request string, verifyAs string, corrupt bool) *irma.SignatureProofResult { func manualSessionHelper(t *testing.T, client *Client, h *ManualTestHandler, request string, verifyAs string, corrupt bool) *irma.SignatureProofResult {
init := client == nil init := client == nil
if init { if init {
client = parseStorage(t) client = parseStorage(t)
......
Supports Markdown
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