Commit a46bb870 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

test: restore keyshare registration unit test

parent b8eadff3
......@@ -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 TestManualKeyShareSession(t *testing.T) {
func TestManualKeyshareSession(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)
......
......@@ -9,7 +9,7 @@ import (
)
func TestLogging(t *testing.T) {
client := parseStorage(t)
client, _ := parseStorage(t)
logs, err := client.Logs()
oldLogLength := len(logs)
......
......@@ -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)
}
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
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