Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
02c73f36
Commit
02c73f36
authored
Jun 21, 2018
by
Sietse Ringers
Browse files
Restore restoring invalid managers from assets when restoring from remote does not work
parent
3de4368b
Changes
2
Hide whitespace changes
Inline
Side-by-side
irmaconfig.go
View file @
02c73f36
...
...
@@ -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
)
}
}
...
...
irmago_test.go
View file @
02c73f36
...
...
@@ -69,9 +69,10 @@ func TestParseInvalidIrmaConfiguration(t *testing.T) {
require
.
Equal
(
t
,
false
,
conf
.
SchemeManagers
[
smerr
.
Manager
]
.
Valid
)
}
func
Test
Restore
InvalidIrmaConfiguration
(
t
*
testing
.
T
)
{
func
TestInvalidIrmaConfiguration
RestoreFromRemote
(
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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment