Skip to content
GitLab
Menu
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
344ded3a
Commit
344ded3a
authored
Feb 21, 2019
by
Sietse Ringers
Browse files
Refactor fix, and ensure that it works with new unittest
parent
e3e6345e
Changes
2
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
344ded3a
...
...
@@ -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
}
...
...
irmaclient/irmaclient_test.go
View file @
344ded3a
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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