Commit 415def8e authored by Sietse Ringers's avatar Sietse Ringers

test: irmaclient periodic revocation update

parent 4f6a32dc
......@@ -302,7 +302,7 @@ func TestRevocationAll(t *testing.T) {
require.Equal(t, irma.ProofStatusInvalid, status)
})
t.Run("ClientUpdate", func(t *testing.T) {
t.Run("ClientSessionServerUpdate", func(t *testing.T) {
defer test.ClearTestStorage(t)
client, _ := revocationSetup(t)
defer stopRevocationServer()
......@@ -320,6 +320,42 @@ func TestRevocationAll(t *testing.T) {
require.NotEmpty(t, result.Disclosed)
})
t.Run("ClientAutoServerUpdate", func(t *testing.T) {
defer test.ClearTestStorage(t)
client, _ := revocationSetup(t) // revocation server is stopped manually below
// Advance the accumulator by performing a few revocations
conf := revocationConfiguration.IrmaConfiguration.Revocation
sacc, err := conf.Accumulator(revocationTestCred, revocationPkCounter)
require.NoError(t, err)
fakeMultipleRevocations(t, irma.RevocationParameters.DefaultUpdateEventCount+3, conf, sacc.Accumulator)
// Client updates at revocation server
require.NoError(t, client.NonrevUpdateFromServer(revocationTestCred))
// Start an IRMA server and let it update at revocation server
StartIrmaServer(t, false)
defer StopIrmaServer()
conf = irmaServerConfiguration.IrmaConfiguration.Revocation
require.NoError(t, conf.SyncDB(revocationTestCred))
// IRMA server's accumulator is now at the same index as that of the revocation server
sacc, err = conf.Accumulator(revocationTestCred, revocationPkCounter)
require.NoError(t, err)
pk, err := conf.Keys.PublicKey(revocationTestCred.IssuerIdentifier(), revocationPkCounter)
require.NoError(t, err)
acc, err := sacc.UnmarshalVerify(pk)
require.NoError(t, err)
require.Equal(t, irma.RevocationParameters.DefaultUpdateEventCount+3, acc.Index)
// Stop revocation server and do session
// IRMA server is at index 3, so if the client would not be it would need to update, which would fail
stopRevocationServer()
result := revocationSession(t, client, nil, sessionOptionReuseServer)
require.Equal(t, irma.ProofStatusValid, result.ProofStatus)
require.NotEmpty(t, result.Disclosed)
})
t.Run("SameIrmaServer", func(t *testing.T) {
StartIrmaServer(t, false)
defer StopIrmaServer()
......
......@@ -64,7 +64,7 @@ func (client *Client) initRevocation() {
if r < p {
irma.Logger.Debugf("scheduling nonrevocation witness remote update for %s-%s", id, attrs.Hash())
client.jobs <- func() {
if err = client.nonrevUpdateFromServer(id); err != nil {
if err = client.NonrevUpdateFromServer(id); err != nil {
client.reportError(err)
return
}
......@@ -208,7 +208,7 @@ func (client *Client) nonrevApplyUpdates(id irma.CredentialTypeIdentifier, count
return nil
}
func (client *Client) nonrevUpdateFromServer(id irma.CredentialTypeIdentifier) error {
func (client *Client) NonrevUpdateFromServer(id irma.CredentialTypeIdentifier) error {
return client.nonrevUpdate(id, nil)
}
......
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