Commit ddf5df46 authored by Sietse Ringers's avatar Sietse Ringers

test: irmaclient having to contact RA to update its revocation witness

parent 4b186703
......@@ -6,9 +6,12 @@ import (
"io/ioutil"
"net/http"
"reflect"
"strconv"
"time"
"testing"
"github.com/privacybydesign/gabi/revocation"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/test"
"github.com/privacybydesign/irmago/irmaclient"
......@@ -368,6 +371,45 @@ var revocationIssuanceRequest = irma.NewIssuanceRequest([]*irma.CredentialReques
},
}})
func TestRevocationClientUpdate(t *testing.T) {
defer test.ClearTestStorage(t)
attr := irma.NewAttributeTypeIdentifier("irma-demo.MijnOverheid.root.BSN")
cred := attr.CredentialTypeIdentifier()
client, _ := revocationSetup(t)
conf := revocationConfiguration.IrmaConfiguration.Revocation
sk, err := conf.Keys.PrivateKey(cred.IssuerIdentifier(), 2)
require.NoError(t, err)
pk, err := conf.Keys.PublicKey(cred.IssuerIdentifier(), 2)
require.NoError(t, err)
update, err := revocation.NewAccumulator(sk)
require.NoError(t, err)
acc, err := update.SignedAccumulator.UnmarshalVerify(pk)
require.NoError(t, err)
// Advance the accumulator by doing revocations so much that the client will need
// to contact the RA to update its witness
for i := 0; i < irma.RevocationDefaultEventCount+1; i++ {
key := strconv.Itoa(i)
witness, err := revocation.RandomWitness(sk, acc)
require.NoError(t, err)
require.NoError(t, conf.AddIssuanceRecord(&irma.IssuanceRecord{
Key: key,
CredType: cred,
PKCounter: 2,
Attr: (*irma.RevocationAttribute)(witness.E),
Issued: time.Now().UnixNano(),
ValidUntil: time.Now().Add(1 * time.Hour).UnixNano(),
}))
require.NoError(t, conf.Revoke(cred, key))
}
result := revocationSession(t, client)
require.Equal(t, irma.ProofStatusValid, result.ProofStatus)
require.NotEmpty(t, result.Disclosed)
}
func TestRevocation(t *testing.T) {
defer test.ClearTestStorage(t)
attr := irma.NewAttributeTypeIdentifier("irma-demo.MijnOverheid.root.BSN")
......
......@@ -24,8 +24,9 @@ var (
revocationServer *irmaserver.Server
requestorServer *requestorserver.Server
logger = logrus.New()
testdata = test.FindTestdataFolder(nil)
revocationConfiguration *server.Configuration
logger = logrus.New()
testdata = test.FindTestdataFolder(nil)
)
func init() {
......@@ -103,6 +104,7 @@ func StartRevocationServer(t *testing.T) {
// Start revocation server
revocationServer, err = irmaserver.New(conf)
revocationConfiguration = conf
require.NoError(t, err)
mux := http.NewServeMux()
mux.HandleFunc("/", revocationServer.HandlerFunc())
......
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