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
7d17151b
Commit
7d17151b
authored
Dec 26, 2017
by
Sietse Ringers
Browse files
Add unit test for large attributes
parent
f8bc10f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
irmaclient/irmaclient_test.go
View file @
7d17151b
...
...
@@ -183,7 +183,7 @@ func TestUnmarshaling(t *testing.T) {
// Do session so we can examine its log item later
logs
,
err
:=
client
.
Logs
()
require
.
NoError
(
t
,
err
)
jwt
:=
get
Issuance
Jwt
(
"testip"
,
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
))
jwt
:=
get
Combined
Jwt
(
"testip"
,
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
))
sessionHelper
(
t
,
jwt
,
"issue"
,
client
)
newclient
,
err
:=
New
(
"testdata/storage/test"
,
"testdata/irma_configuration"
,
"testdata/oldstorage"
,
nil
)
...
...
@@ -422,7 +422,7 @@ func TestDownloadSchemeManager(t *testing.T) {
require
.
Contains
(
t
,
client
.
Configuration
.
SchemeManagers
,
irmademo
)
// Do a session to test downloading of cred types, issuers and keys
jwt
:=
get
Issuance
Jwt
(
"testip"
,
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
))
jwt
:=
get
Combined
Jwt
(
"testip"
,
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
))
sessionHelper
(
t
,
jwt
,
"issue"
,
client
)
teardown
(
t
)
...
...
irmaclient/session_test.go
View file @
7d17151b
...
...
@@ -96,18 +96,19 @@ func getSigningJwt(name string, id irma.AttributeTypeIdentifier) interface{} {
})
}
func
getIssuance
Jwt
(
name
string
,
id
irma
.
AttributeTypeIdentifier
)
interface
{}
{
func
getIssuance
Request
()
*
irma
.
IssuanceRequest
{
expiry
:=
irma
.
Timestamp
(
irma
.
NewMetadataAttribute
()
.
Expiry
())
credid1
:=
irma
.
NewCredentialTypeIdentifier
(
"irma-demo.RU.studentCard"
)
credid2
:=
irma
.
NewCredentialTypeIdentifier
(
"irma-demo.MijnOverheid.root"
)
return
irma
.
NewIdentityProviderJwt
(
name
,
&
irma
.
IssuanceRequest
{
return
&
irma
.
IssuanceRequest
{
Credentials
:
[]
*
irma
.
CredentialRequest
{
{
Validity
:
&
expiry
,
CredentialTypeID
:
&
credid1
,
Attributes
:
map
[
string
]
string
{
"university"
:
"Radboud"
,
"studentCardNumber"
:
"3.14159265358979323846264338328"
,
"studentCardNumber"
:
"3.14159265358979323846264338328
11111111111111111111111111111111111111111
"
,
"studentID"
:
"s1234567"
,
"level"
:
"42"
,
},
...
...
@@ -119,10 +120,19 @@ func getIssuanceJwt(name string, id irma.AttributeTypeIdentifier) interface{} {
},
},
},
Disclose
:
irma
.
AttributeDisjunctionList
{
&
irma
.
AttributeDisjunction
{
Label
:
"foo"
,
Attributes
:
[]
irma
.
AttributeTypeIdentifier
{
id
}},
},
})
}
}
func
getIssuanceJwt
(
name
string
)
interface
{}
{
return
irma
.
NewIdentityProviderJwt
(
name
,
getIssuanceRequest
())
}
func
getCombinedJwt
(
name
string
,
id
irma
.
AttributeTypeIdentifier
)
interface
{}
{
isreq
:=
getIssuanceRequest
()
isreq
.
Disclose
=
irma
.
AttributeDisjunctionList
{
&
irma
.
AttributeDisjunction
{
Label
:
"foo"
,
Attributes
:
[]
irma
.
AttributeTypeIdentifier
{
id
}},
}
return
irma
.
NewIdentityProviderJwt
(
name
,
isreq
)
}
// StartSession starts an IRMA session by posting the request,
...
...
@@ -157,10 +167,27 @@ func TestIssuanceSession(t *testing.T) {
id
:=
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
)
name
:=
"testip"
jwtcontents
:=
get
Issuance
Jwt
(
name
,
id
)
jwtcontents
:=
get
Combined
Jwt
(
name
,
id
)
sessionHelper
(
t
,
jwtcontents
,
"issue"
,
nil
)
}
func
TestLargeAttribute
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
require
.
NoError
(
t
,
client
.
RemoveAllCredentials
())
jwtcontents
:=
getIssuanceJwt
(
"testip"
)
sessionHelper
(
t
,
jwtcontents
,
"issue"
,
client
)
cred
,
err
:=
client
.
credential
(
irma
.
NewCredentialTypeIdentifier
(
"irma-demo.RU.studentCard"
),
0
)
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
cred
.
Signature
.
Verify
(
cred
.
Pk
,
cred
.
Attributes
))
jwtcontents
=
getDisclosureJwt
(
"testsp"
,
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.university"
))
sessionHelper
(
t
,
jwtcontents
,
"verification"
,
client
)
teardown
(
t
)
}
func
sessionHelper
(
t
*
testing
.
T
,
jwtcontents
interface
{},
url
string
,
client
*
Client
)
{
init
:=
client
==
nil
if
init
{
...
...
@@ -216,7 +243,7 @@ func TestKeyshareEnrollmentAndSessions(t *testing.T) {
id
:=
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
)
expiry
:=
irma
.
Timestamp
(
irma
.
NewMetadataAttribute
()
.
Expiry
())
credid
:=
irma
.
NewCredentialTypeIdentifier
(
"test.test.mijnirma"
)
jwt
:=
get
Issuance
Jwt
(
"testip"
,
id
)
jwt
:=
get
Combined
Jwt
(
"testip"
,
id
)
jwt
.
(
*
irma
.
IdentityProviderJwt
)
.
Request
.
Request
.
Credentials
=
append
(
jwt
.
(
*
irma
.
IdentityProviderJwt
)
.
Request
.
Request
.
Credentials
,
&
irma
.
CredentialRequest
{
...
...
@@ -259,7 +286,7 @@ func TestKeyshareSessions(t *testing.T) {
expiry
:=
irma
.
Timestamp
(
irma
.
NewMetadataAttribute
()
.
Expiry
())
credid
:=
irma
.
NewCredentialTypeIdentifier
(
"test.test.mijnirma"
)
jwt
:=
get
Issuance
Jwt
(
"testip"
,
id
)
jwt
:=
get
Combined
Jwt
(
"testip"
,
id
)
jwt
.
(
*
irma
.
IdentityProviderJwt
)
.
Request
.
Request
.
Credentials
=
append
(
jwt
.
(
*
irma
.
IdentityProviderJwt
)
.
Request
.
Request
.
Credentials
,
&
irma
.
CredentialRequest
{
...
...
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