Commit 02c73f36 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Restore restoring invalid managers from assets when restoring from remote does not work

parent 3de4368b
......@@ -178,14 +178,16 @@ func (conf *Configuration) ParseOrRestoreFolder() error {
return err
}
err = nil
for id := range conf.DisabledSchemeManagers {
if reinstallErr := conf.ReinstallSchemeManager(conf.SchemeManagers[id]); reinstallErr != nil {
// Again, we can recover only from a *SchemeManagerError, so bail out now otherwise
if _, isSchemeMgrErr := reinstallErr.(*SchemeManagerError); !isSchemeMgrErr {
return err
}
err = reinstallErr
if err = conf.ReinstallSchemeManager(conf.SchemeManagers[id]); err == nil {
continue
}
if _, err = conf.CopyManagerFromAssets(id); err != nil {
return err // File system error, too serious, bail out now
}
name := id.String()
if err = conf.ParseSchemeManagerFolder(filepath.Join(conf.Path, name), NewSchemeManager(name)); err == nil {
delete(conf.DisabledSchemeManagers, id)
}
}
......
......@@ -69,9 +69,10 @@ func TestParseInvalidIrmaConfiguration(t *testing.T) {
require.Equal(t, false, conf.SchemeManagers[smerr.Manager].Valid)
}
func TestRestoreInvalidIrmaConfiguration(t *testing.T) {
func TestInvalidIrmaConfigurationRestoreFromRemote(t *testing.T) {
test.StartSchemeManagerServer()
require.NoError(t, fs.EnsureDirectoryExists("testdata/storage/test"))
conf, err := NewConfiguration("testdata/storage/test/irma_configuration", "testdata/irma_configuration_invalid")
require.NoError(t, err)
......@@ -79,11 +80,33 @@ func TestRestoreInvalidIrmaConfiguration(t *testing.T) {
require.NoError(t, err)
require.Empty(t, conf.DisabledSchemeManagers)
require.Contains(t, conf.SchemeManagers, NewSchemeManagerIdentifier("irma-demo"))
require.Contains(t, conf.CredentialTypes, NewCredentialTypeIdentifier("irma-demo.RU.studentCard"))
test.StopSchemeManagerServer()
test.ClearTestStorage(t)
}
func TestInvalidIrmaConfigurationRestoreFromAssets(t *testing.T) {
require.NoError(t, fs.EnsureDirectoryExists("testdata/storage/test"))
conf, err := NewConfiguration("testdata/storage/test/irma_configuration", "testdata/irma_configuration_invalid")
require.NoError(t, err)
// Fails: no remote and the version in the assets is broken
err = conf.ParseOrRestoreFolder()
require.Error(t, err)
require.NotEmpty(t, conf.DisabledSchemeManagers)
// Try again from correct assets
conf.assets = "testdata/irma_configuration"
err = conf.ParseOrRestoreFolder()
require.NoError(t, err)
require.Empty(t, conf.DisabledSchemeManagers)
require.Contains(t, conf.SchemeManagers, NewSchemeManagerIdentifier("irma-demo"))
require.Contains(t, conf.CredentialTypes, NewCredentialTypeIdentifier("irma-demo.RU.studentCard"))
test.ClearTestStorage(t)
}
func TestParseIrmaConfiguration(t *testing.T) {
conf := parseConfiguration(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