irmago_test.go 928 Bytes
Newer Older
Sietse Ringers's avatar
Sietse Ringers committed
1
package irmago
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

import "testing"
import (
	"github.com/mhe/gabi"
	"github.com/stretchr/testify/assert"
)

func TestAndroidParse(t *testing.T) {
	gabi.MetaStore.ParseFolder("testdata/irma_configuration")
	Manager.Init("testdata/storage")
	err := Manager.ParseAndroidStorage()

	assert.NoError(t, err, "ParseAndroidStorage failed")
	assert.NotEmpty(t, Manager.credentials, "No credentials deserialized")
	assert.Contains(t, Manager.credentials, "irma-demo.RU.studentCard", "irma-demo.RU.studentCard not deserialized")
	assert.NotEmpty(t, Manager.credentials, "irma-demo.RU.studentCard not deserialized")
	cred := Manager.credentials["irma-demo.RU.studentCard"][0]
	assert.NotNil(t, cred.Attributes[0], "Metadata attribute of irma-demo.RU.studentCard should not be nil")

	assert.True(t,
		Manager.credentials["irma-demo.RU.studentCard"][0].Signature.Verify(cred.PublicKey(), cred.Attributes),
		"Credential should be valid",
	)
}