Commit 7508e351 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Merge branch 'master' into scheme-updating

parents 02c73f36 6ca9a8fa
......@@ -5,6 +5,7 @@ import (
"math/big"
"sort"
"time"
"strconv"
"github.com/credentials/go-go-gadget-paillier"
raven "github.com/getsentry/raven-go"
......@@ -82,7 +83,8 @@ type KeyshareHandler interface {
type ChangePinHandler interface {
ChangePinFailure(manager irma.SchemeManagerIdentifier, err error)
ChangePinSuccess(manager irma.SchemeManagerIdentifier)
ChangePinIncorrect(manager irma.SchemeManagerIdentifier)
ChangePinIncorrect(manager irma.SchemeManagerIdentifier, attempts int)
ChangePinBlocked(manager irma.SchemeManagerIdentifier, timeout int)
}
// ClientHandler informs the user that the configuration or the list of attributes
......@@ -781,10 +783,23 @@ func (client *Client) keyshareChangePinWorker(managerID irma.SchemeManagerIdenti
return err
}
if res.Status != kssPinSuccess {
client.handler.ChangePinIncorrect(managerID)
} else {
switch res.Status {
case kssPinSuccess:
client.handler.ChangePinSuccess(managerID)
case kssPinFailure:
attempts, err := strconv.Atoi(res.Message)
if err != nil {
return err
}
client.handler.ChangePinIncorrect(managerID, attempts)
case kssPinError:
timeout, err := strconv.Atoi(res.Message)
if err != nil {
return err
}
client.handler.ChangePinBlocked(managerID, timeout)
default:
return errors.New("Unknown keyshare response")
}
return nil
......
......@@ -60,7 +60,7 @@ func (i *TestClientHandler) ChangePinFailure(manager irma.SchemeManagerIdentifie
i.t.Fatal(err)
}
}
func (i *TestClientHandler) ChangePinIncorrect(manager irma.SchemeManagerIdentifier) {
func (i *TestClientHandler) ChangePinIncorrect(manager irma.SchemeManagerIdentifier, attempts int) {
err := errors.New("incorrect pin")
select {
case i.c <- err: //nop
......@@ -68,6 +68,14 @@ func (i *TestClientHandler) ChangePinIncorrect(manager irma.SchemeManagerIdentif
i.t.Fatal(err)
}
}
func (i *TestClientHandler) ChangePinBlocked(manager irma.SchemeManagerIdentifier, timeout int) {
err := errors.New("blocked account")
select {
case i.c <- err: //nop
default:
i.t.Fatal(err)
}
}
func parseStorage(t *testing.T) *Client {
require.NoError(t, fs.CopyDirectory("../testdata/teststorage", "../testdata/storage/test"))
......
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