Commit db988407 authored by Sietse Ringers's avatar Sietse Ringers Committed by Ivar Derksen
Browse files

fix: scheme restoration in case of error to incorrect path

parent c5b198b4
......@@ -139,9 +139,18 @@ func TestInvalidIrmaConfigurationRestoreFromRemote(t *testing.T) {
})
require.NoError(t, err)
// check that restoring works
err = conf.ParseOrRestoreFolder()
require.NoError(t, err)
require.Empty(t, conf.DisabledSchemeManagers)
// switch to correct assets, and parse again to check that ParseOrRestoreFolder
// left the folder in a consistent state
conf.assets = filepath.Join("testdata", "irma_configuration")
err = conf.ParseFolder()
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"))
}
......@@ -165,6 +174,12 @@ func TestInvalidIrmaConfigurationRestoreFromAssets(t *testing.T) {
err = conf.ParseOrRestoreFolder()
require.NoError(t, err)
require.Empty(t, conf.DisabledSchemeManagers)
// parse again to check that ParseOrRestoreFolder left the folder in a consistent state
err = conf.ParseFolder()
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"))
require.Contains(t, conf.RequestorSchemes, NewRequestorSchemeIdentifier("test-requestors"))
......
......@@ -430,7 +430,7 @@ func (conf *Configuration) reinstallSchemeFromRemote(scheme Scheme) error {
if err = scheme.delete(conf); err != nil {
return err
}
return conf.installScheme(scheme.url(), pkbts, scheme.path())
return conf.installScheme(scheme.url(), pkbts, filepath.Base(scheme.path()))
}
// newSchemeDir returns the name of a newly created directory into which a scheme can be installed:
......@@ -1329,10 +1329,10 @@ func (scheme *RequestorScheme) validate(conf *Configuration) (error, SchemeManag
// Verify all requestors
for _, requestor := range requestors {
if scheme.Demo && len(requestor.Hostnames) > 0 {
return errors.New("Demo requestor scheme has hostnames: only allowed for non-demo schemes"), SchemeManagerStatusParsingError
return errors.New("Demo requestor has hostnames: only allowed for non-demo schemes"), SchemeManagerStatusParsingError
}
if requestor.ID.RequestorSchemeIdentifier() != scheme.ID {
return errors.Errorf("requestor scheme %s has incorrect ID", requestor.ID), SchemeManagerStatusParsingError
return errors.Errorf("requestor %s has incorrect ID", requestor.ID), SchemeManagerStatusParsingError
}
if requestor.Logo != nil {
if err, status := scheme.checkLogo(conf, *requestor.Logo); err != nil {
......
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