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
a46bb870
Commit
a46bb870
authored
Apr 15, 2019
by
Sietse Ringers
Browse files
test: restore keyshare registration unit test
parent
b8eadff3
Changes
6
Hide whitespace changes
Inline
Side-by-side
internal/sessiontest/keyshare_test.go
View file @
a46bb870
...
...
@@ -7,10 +7,11 @@ import (
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/test"
"github.com/privacybydesign/irmago/irmaclient"
"github.com/stretchr/testify/require"
)
func
TestManualKey
S
hareSession
(
t
*
testing
.
T
)
{
func
TestManualKey
s
hareSession
(
t
*
testing
.
T
)
{
request
:=
"{
\"
nonce
\"
: 0,
\"
context
\"
: 0,
\"
type
\"
:
\"
signing
\"
,
\"
message
\"
:
\"
I owe you everything
\"
,
\"
content
\"
:[{
\"
label
\"
:
\"
Student number (RU)
\"
,
\"
attributes
\"
:[
\"
test.test.mijnirma.email
\"
]}]}"
ms
:=
createManualSessionHandler
(
t
,
nil
)
...
...
@@ -24,13 +25,32 @@ func TestRequestorIssuanceKeyshareSession(t *testing.T) {
testRequestorIssuance
(
t
,
true
)
}
func
TestKeyshareRegister
(
t
*
testing
.
T
)
{
client
,
handler
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
require
.
NoError
(
t
,
client
.
KeyshareRemoveAll
())
require
.
NoError
(
t
,
client
.
RemoveAllCredentials
())
client
.
KeyshareEnroll
(
irma
.
NewSchemeManagerIdentifier
(
"test"
),
nil
,
"12345"
,
"en"
)
require
.
NoError
(
t
,
<-
handler
.
c
)
require
.
Len
(
t
,
client
.
CredentialInfoList
(),
1
)
sessionHelper
(
t
,
getIssuanceRequest
(
true
),
"issue"
,
client
)
keyshareSessions
(
t
,
client
)
}
// Use the existing keyshare enrollment and credentials
// in a keyshare session of each session type.
// Use keyshareuser.sql to enroll the user at the keyshare server.
func
TestKeyshareSessions
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
keyshareSessions
(
t
,
client
)
}
func
keyshareSessions
(
t
*
testing
.
T
,
client
*
irmaclient
.
Client
)
{
id
:=
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
)
expiry
:=
irma
.
Timestamp
(
irma
.
NewMetadataAttribute
(
0
)
.
Expiry
())
issuanceRequest
:=
getCombinedIssuanceRequest
(
id
)
...
...
internal/sessiontest/logs_test.go
View file @
a46bb870
...
...
@@ -9,7 +9,7 @@ import (
)
func
TestLogging
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
logs
,
err
:=
client
.
Logs
()
oldLogLength
:=
len
(
logs
)
...
...
internal/sessiontest/main_test.go
View file @
a46bb870
...
...
@@ -35,17 +35,18 @@ func TestMain(m *testing.M) {
os
.
Exit
(
m
.
Run
())
}
func
parseStorage
(
t
*
testing
.
T
)
*
irmaclient
.
Client
{
func
parseStorage
(
t
*
testing
.
T
)
(
*
irmaclient
.
Client
,
*
TestClientHandler
)
{
test
.
SetupTestStorage
(
t
)
handler
:=
&
TestClientHandler
{
t
:
t
,
c
:
make
(
chan
error
)}
path
:=
test
.
FindTestdataFolder
(
t
)
client
,
err
:=
irmaclient
.
New
(
filepath
.
Join
(
path
,
"storage"
,
"test"
),
filepath
.
Join
(
path
,
"irma_configuration"
),
""
,
&
TestClientHandler
{
t
:
t
}
,
handler
,
)
require
.
NoError
(
t
,
err
)
return
client
return
client
,
handler
}
func
getDisclosureRequest
(
id
irma
.
AttributeTypeIdentifier
)
*
irma
.
DisclosureRequest
{
...
...
@@ -224,7 +225,7 @@ func getJwt(t *testing.T, request irma.SessionRequest, sessiontype string, alg j
func
sessionHelper
(
t
*
testing
.
T
,
request
irma
.
SessionRequest
,
sessiontype
string
,
client
*
irmaclient
.
Client
)
{
if
client
==
nil
{
client
=
parseStorage
(
t
)
client
,
_
=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
}
...
...
internal/sessiontest/manual_session_test.go
View file @
a46bb870
...
...
@@ -25,7 +25,7 @@ func createManualSessionHandler(t *testing.T, client *irmaclient.Client) *Manual
func
manualSessionHelper
(
t
*
testing
.
T
,
client
*
irmaclient
.
Client
,
h
*
ManualTestHandler
,
request
string
,
verifyAs
string
,
corrupt
bool
)
([]
*
irma
.
DisclosedAttribute
,
irma
.
ProofStatus
)
{
if
client
==
nil
{
client
=
parseStorage
(
t
)
client
,
_
=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
}
...
...
@@ -113,7 +113,7 @@ func TestManualSessionInvalidAttributeValue(t *testing.T) {
}
func
TestManualSessionMultiProof
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
// First, we need to issue an extra credential (BSN)
...
...
internal/sessiontest/requestor_test.go
View file @
a46bb870
...
...
@@ -14,7 +14,7 @@ func requestorSessionHelper(t *testing.T, request irma.SessionRequest) *server.S
StartIrmaServer
(
t
)
defer
StopIrmaServer
()
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
clientChan
:=
make
(
chan
*
SessionResult
)
...
...
internal/sessiontest/session_test.go
View file @
a46bb870
...
...
@@ -40,7 +40,7 @@ func TestMultipleIssuanceSession(t *testing.T) {
}
func
TestDefaultCredentialValidity
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
request
:=
getIssuanceRequest
(
true
)
sessionHelper
(
t
,
request
,
"issue"
,
client
)
}
...
...
@@ -63,7 +63,7 @@ func TestIssuanceOptionalSetAttributes(t *testing.T) {
}
func
TestLargeAttribute
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
require
.
NoError
(
t
,
client
.
RemoveAllCredentials
())
...
...
@@ -76,7 +76,7 @@ func TestLargeAttribute(t *testing.T) {
}
func
TestIssuanceSingletonCredential
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
request
:=
getMultipleIssuanceRequest
()
...
...
@@ -100,7 +100,7 @@ indicates the sign of the integer. In Go this is not the case. This resulted in
signatures being issued in the issuance protocol in two distinct ways, of which we test here
that they have been fixed. */
func
TestAttributeByteEncoding
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
require
.
NoError
(
t
,
client
.
RemoveAllCredentials
())
...
...
@@ -123,7 +123,7 @@ func TestAttributeByteEncoding(t *testing.T) {
}
func
TestDisclosureNewAttributeUpdateSchemeManager
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
schemeid
:=
irma
.
NewSchemeManagerIdentifier
(
"irma-demo"
)
...
...
@@ -148,7 +148,7 @@ func TestDisclosureNewAttributeUpdateSchemeManager(t *testing.T) {
}
func
TestIssueNewAttributeUpdateSchemeManager
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
schemeid
:=
irma
.
NewSchemeManagerIdentifier
(
"irma-demo"
)
...
...
@@ -164,7 +164,7 @@ func TestIssueNewAttributeUpdateSchemeManager(t *testing.T) {
}
func
TestIssueOptionalAttributeUpdateSchemeManager
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
schemeid
:=
irma
.
NewSchemeManagerIdentifier
(
"irma-demo"
)
...
...
@@ -180,7 +180,7 @@ func TestIssueOptionalAttributeUpdateSchemeManager(t *testing.T) {
}
func
TestIssueNewCredTypeUpdateSchemeManager
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
schemeid
:=
irma
.
NewSchemeManagerIdentifier
(
"irma-demo"
)
credid
:=
irma
.
NewCredentialTypeIdentifier
(
"irma-demo.RU.studentCard"
)
...
...
@@ -197,7 +197,7 @@ func TestIssueNewCredTypeUpdateSchemeManager(t *testing.T) {
}
func
TestDisclosureNewCredTypeUpdateSchemeManager
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
schemeid
:=
irma
.
NewSchemeManagerIdentifier
(
"irma-demo"
)
credid
:=
irma
.
NewCredentialTypeIdentifier
(
"irma-demo.RU.studentCard"
)
attrid
:=
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.level"
)
...
...
@@ -223,7 +223,7 @@ func TestDisclosureNewCredTypeUpdateSchemeManager(t *testing.T) {
// within this manager to test the autmatic downloading of credential definitions,
// issuers, and public keys.
func
TestDownloadSchemeManager
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
// Remove irma-demo scheme manager as we need to test adding it
...
...
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