Commit 34dafe65 authored by Sietse Ringers's avatar Sietse Ringers

feat: support and test time revocation update messages

parent a4dcfed0
......@@ -402,7 +402,7 @@ func (s *Server) handleRevocationMessage(
return server.BinaryResponse(nil, server.RemoteError(server.ErrorInvalidRequest, "POST update expects 1 url argument"))
}
cred := irma.NewCredentialTypeIdentifier(args[0])
var update *revocation.Update
update := &revocation.Update{}
if err := irma.UnmarshalValidateBinary(message, update); err != nil {
return server.BinaryResponse(nil, server.RemoteError(server.ErrorMalformedInput, err.Error()))
}
......
......@@ -117,16 +117,28 @@ func TestRevocationAll(t *testing.T) {
})
t.Run("UpdateAccumulatorTime", func(t *testing.T) {
revocationConfiguration = revocationConf(t)
revocationConfiguration.RevocationSettings[revocationTestCred].PostURLs = []string{
"http://localhost:48680",
}
StartIrmaServer(t, false)
startRevocationServer(t)
_, acc, err := revocationConfiguration.IrmaConfiguration.Revocation.Accumulator(revocationTestCred, 2)
require.NoError(t, err)
tme := acc.Time
acctime := acc.Time
time.Sleep(time.Second)
// run scheduled update of accumulator, triggering POSTing it to our IRMA server
revocationConfiguration.IrmaConfiguration.Scheduler.RunAll()
_, acc, err = revocationConfiguration.IrmaConfiguration.Revocation.Accumulator(revocationTestCred, 2)
sacc1, acc, err := revocationConfiguration.IrmaConfiguration.Revocation.Accumulator(revocationTestCred, 2)
require.NoError(t, err)
require.NotEqual(t, tme, acc.Time)
require.True(t, acc.Time > acctime)
sacc2, acc2, err := irmaServerConfiguration.IrmaConfiguration.Revocation.Accumulator(revocationTestCred, 2)
require.Equal(t, acc, acc2)
require.Equal(t, sacc1, sacc2)
})
t.Run("OtherAccumulator", func(t *testing.T) {
......
......@@ -17,9 +17,10 @@ import (
)
var (
httpServer *http.Server
irmaServer *irmaserver.Server
requestorServer *requestorserver.Server
httpServer *http.Server
irmaServer *irmaserver.Server
irmaServerConfiguration *server.Configuration
requestorServer *requestorserver.Server
logger = logrus.New()
testdata = test.FindTestdataFolder(nil)
......@@ -60,7 +61,7 @@ func StartIrmaServer(t *testing.T, updatedIrmaConf bool) {
}
var err error
irmaServer, err = irmaserver.New(&server.Configuration{
irmaServerConfiguration = &server.Configuration{
URL: "http://localhost:48680",
Logger: logger,
DisableSchemesUpdate: true,
......@@ -70,7 +71,8 @@ func StartIrmaServer(t *testing.T, updatedIrmaConf bool) {
ServerURL: "http://localhost:48683/",
},
},
})
}
irmaServer, err = irmaserver.New(irmaServerConfiguration)
require.NoError(t, err)
......
......@@ -202,6 +202,10 @@ func (m memRevStorage) Insert(typ CredentialTypeIdentifier, update *revocation.U
record.r[update.SignedAccumulator.PKCounter] = update
return
}
if len(update.Events) == 0 && r.SignedAccumulator.Accumulator.Index == update.SignedAccumulator.Accumulator.Index {
r.SignedAccumulator = update.SignedAccumulator
return
}
ours := r.Events
theirs := update.Events
......
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