Commit 344ded3a authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Refactor fix, and ensure that it works with new unittest

parent e3e6345e
......@@ -81,15 +81,9 @@ func (al *AttributeList) Map(conf *Configuration) map[AttributeTypeIdentifier]Tr
if al.attrMap == nil {
al.attrMap = make(map[AttributeTypeIdentifier]TranslatedString)
ctid := al.CredentialType().Identifier()
strings := al.Strings()
ct := conf.CredentialTypes[ctid]
for i := range ct.AttributeTypes {
attrid := ct.AttributeTypes[i].GetAttributeTypeIdentifier()
if i < len(strings) {
al.attrMap[attrid] = strings[i]
} else {
al.attrMap[attrid] = nil
}
attrTypes := conf.CredentialTypes[ctid].AttributeTypes
for i, val := range al.Strings() {
al.attrMap[attrTypes[i].GetAttributeTypeIdentifier()] = val
}
}
return al.attrMap
......@@ -159,11 +153,13 @@ func (al *AttributeList) Attribute(identifier AttributeTypeIdentifier) Translate
if al.CredentialType().Identifier() != identifier.CredentialTypeIdentifier() {
return nil
}
for i, desc := range al.CredentialType().AttributeTypes {
if desc.ID == string(identifier.Name()) {
return al.Strings()[i]
for i, val := range al.Strings() {
if al.CredentialType().AttributeTypes[i].ID == string(identifier.Name()) {
return val
}
}
return nil
}
......
......@@ -207,6 +207,30 @@ func TestWrongSchemeManager(t *testing.T) {
)
}
func TestCredentialInfoListNewAttribute(t *testing.T) {
client := parseStorage(t)
defer test.ClearTestStorage(t)
schemeid := irma.NewSchemeManagerIdentifier("irma-demo")
credid := irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")
attrid := irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.newAttribute")
client.Configuration.SchemeManagers[schemeid].URL = "http://localhost:48681/irma_configuration_updated/irma-demo"
require.NoError(t, client.Configuration.UpdateSchemeManager(schemeid, nil))
require.NoError(t, client.Configuration.ParseFolder())
require.NotNil(t, client.Configuration.CredentialTypes[credid].AttributeType(attrid))
// irma-demo.RU.studentCard.newAttribute now exists in the scheme but not in the instance in the teststorage
for _, credinfo := range client.CredentialInfoList() {
if credinfo.ID == "studentCard" {
require.Nil(t, credinfo.Attributes[attrid])
require.NotEmpty(t, credinfo.Attributes[irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.level")])
return
}
}
require.Fail(t, "studentCard credential not found")
}
// ------
type TestClientHandler struct {
......
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