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
e42904e3
Commit
e42904e3
authored
Aug 23, 2017
by
Sietse Ringers
Browse files
Add test for attribute candidate searching
parent
e0f77546
Changes
3
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
e42904e3
...
...
@@ -80,8 +80,11 @@ func (al *AttributeList) Strings() []string {
}
func
(
al
*
AttributeList
)
Attribute
(
identifier
AttributeTypeIdentifier
)
string
{
if
al
.
CredentialType
()
.
Identifier
()
!=
identifier
.
CredentialTypeIdentifier
()
{
return
""
}
for
i
,
desc
:=
range
al
.
CredentialType
()
.
Attributes
{
if
desc
.
ID
==
string
(
identifier
.
String
())
{
if
desc
.
ID
==
string
(
identifier
.
Name
())
{
return
al
.
Strings
()[
i
]
}
}
...
...
irmago_test.go
View file @
e42904e3
...
...
@@ -199,3 +199,39 @@ func TestAttributeDisjunctionMarshaling(t *testing.T) {
disjunction
.
selected
=
&
disjunction
.
Attributes
[
0
]
require
.
True
(
t
,
disjunction
.
Satisfied
())
}
func
TestCandidates
(
t
*
testing
.
T
)
{
parseMetaStore
(
t
)
parseStorage
(
t
)
parseAndroidStorage
(
t
)
attrtype
:=
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
)
disjunction
:=
&
AttributeDisjunction
{
Attributes
:
[]
AttributeTypeIdentifier
{
attrtype
},
}
attrs
:=
Manager
.
Candidates
(
disjunction
)
require
.
NotNil
(
t
,
attrs
)
require
.
Len
(
t
,
attrs
,
1
)
attr
:=
attrs
[
0
]
require
.
NotNil
(
t
,
attr
)
require
.
Equal
(
t
,
attr
.
Type
,
attrtype
)
disjunction
=
&
AttributeDisjunction
{
Attributes
:
[]
AttributeTypeIdentifier
{
attrtype
},
Values
:
map
[
AttributeTypeIdentifier
]
string
{
attrtype
:
"s1234567"
},
}
attrs
=
Manager
.
Candidates
(
disjunction
)
require
.
NotNil
(
t
,
attrs
)
require
.
Len
(
t
,
attrs
,
1
)
disjunction
=
&
AttributeDisjunction
{
Attributes
:
[]
AttributeTypeIdentifier
{
attrtype
},
Values
:
map
[
AttributeTypeIdentifier
]
string
{
attrtype
:
"foobarbaz"
},
}
attrs
=
Manager
.
Candidates
(
disjunction
)
require
.
NotNil
(
t
,
attrs
)
require
.
Empty
(
t
,
attrs
)
teardown
(
t
)
}
manager.go
View file @
e42904e3
...
...
@@ -201,7 +201,7 @@ func (cm *CredentialManager) Add(cred *Credential) (err error) {
}
func
(
cm
*
CredentialManager
)
Candidates
(
disjunction
*
AttributeDisjunction
)
[]
*
AttributeIdentifier
{
candidates
:=
make
([]
*
AttributeIdentifier
,
10
)
candidates
:=
make
([]
*
AttributeIdentifier
,
0
,
10
)
for
_
,
attribute
:=
range
disjunction
.
Attributes
{
credId
:=
attribute
.
CredentialTypeIdentifier
()
...
...
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