Commit 7699c212 authored by Sietse Ringers's avatar Sietse Ringers Committed by Tomas
Browse files

chore: rename flag to local_tests, include all tests except those involving keyshare servers

parent f15e2e05
// +build !local_tests
package sessiontest
import (
"testing"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/test"
"github.com/stretchr/testify/require"
)
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)
_, status := manualSessionHelper(t, nil, ms, request, request, false)
require.Equal(t, irma.ProofStatusValid, status)
_, status = manualSessionHelper(t, nil, ms, request, "", false)
require.Equal(t, irma.ProofStatusValid, status)
}
func TestRequestorIssuanceKeyshareSession(t *testing.T) {
testRequestorIssuance(t, true)
}
// 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)
defer test.ClearTestStorage(t)
id := irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID")
expiry := irma.Timestamp(irma.NewMetadataAttribute(0).Expiry())
issuanceRequest := getCombinedIssuanceRequest(id)
issuanceRequest.Credentials = append(issuanceRequest.Credentials,
&irma.CredentialRequest{
Validity: &expiry,
CredentialTypeID: irma.NewCredentialTypeIdentifier("test.test.mijnirma"),
Attributes: map[string]string{"email": "testusername"},
},
)
sessionHelper(t, issuanceRequest, "issue", client)
disclosureRequest := getDisclosureRequest(id)
disclosureRequest.Content = append(disclosureRequest.Content,
&irma.AttributeDisjunction{
Label: "foo",
Attributes: []irma.AttributeTypeIdentifier{irma.NewAttributeTypeIdentifier("test.test.mijnirma.email")},
},
)
sessionHelper(t, disclosureRequest, "verification", client)
sigRequest := getSigningRequest(id)
sigRequest.Content = append(sigRequest.Content,
&irma.AttributeDisjunction{
Label: "foo",
Attributes: []irma.AttributeTypeIdentifier{irma.NewAttributeTypeIdentifier("test.test.mijnirma.email")},
},
)
sessionHelper(t, sigRequest, "signature", client)
}
......@@ -227,35 +227,3 @@ func sessionHelper(t *testing.T, request irma.SessionRequest, sessiontype string
require.NoError(t, result.Err)
}
}
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)
issuanceRequest.Credentials = append(issuanceRequest.Credentials,
&irma.CredentialRequest{
Validity: &expiry,
CredentialTypeID: irma.NewCredentialTypeIdentifier("test.test.mijnirma"),
Attributes: map[string]string{"email": "testusername"},
},
)
sessionHelper(t, issuanceRequest, "issue", client)
disclosureRequest := getDisclosureRequest(id)
disclosureRequest.Content = append(disclosureRequest.Content,
&irma.AttributeDisjunction{
Label: "foo",
Attributes: []irma.AttributeTypeIdentifier{irma.NewAttributeTypeIdentifier("test.test.mijnirma.email")},
},
)
sessionHelper(t, disclosureRequest, "verification", client)
sigRequest := getSigningRequest(id)
sigRequest.Content = append(sigRequest.Content,
&irma.AttributeDisjunction{
Label: "foo",
Attributes: []irma.AttributeTypeIdentifier{irma.NewAttributeTypeIdentifier("test.test.mijnirma.email")},
},
)
sessionHelper(t, sigRequest, "signature", client)
}
// +build !unit_tests
package sessiontest
import (
......@@ -114,16 +112,6 @@ func TestManualSessionInvalidAttributeValue(t *testing.T) {
require.Equal(t, irma.AttributeProofStatusInvalidValue, attrs[0].Status)
}
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)
_, status := manualSessionHelper(t, nil, ms, request, request, false)
require.Equal(t, irma.ProofStatusValid, status)
_, status = manualSessionHelper(t, nil, ms, request, "", false)
require.Equal(t, irma.ProofStatusValid, status)
}
func TestManualSessionMultiProof(t *testing.T) {
client := parseStorage(t)
defer test.ClearTestStorage(t)
......
// +build !unit_tests
package sessiontest
import (
......@@ -81,6 +79,10 @@ func TestRequestorDisclosureSession(t *testing.T) {
}
func TestRequestorIssuanceSession(t *testing.T) {
testRequestorIssuance(t, false)
}
func testRequestorIssuance(t *testing.T, keyshare bool) {
attrid := irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID")
request := &irma.IssuanceRequest{
BaseRequest: irma.BaseRequest{Type: irma.ActionIssuing},
......@@ -98,10 +100,13 @@ func TestRequestorIssuanceSession(t *testing.T) {
Attributes: map[string]string{
"BSN": "299792458",
},
}, {
}}
if keyshare {
request.Credentials = append(request.Credentials, &irma.CredentialRequest{
CredentialTypeID: irma.NewCredentialTypeIdentifier("test.test.mijnirma"),
Attributes: map[string]string{"email": "testusername"},
}}
})
}
request.Disclose = []*irma.AttributeDisjunction{{
Label: "foo",
Attributes: []irma.AttributeTypeIdentifier{attrid},
......
// +build !unit_tests
package sessiontest
import (
......@@ -119,16 +117,6 @@ func TestAttributeByteEncoding(t *testing.T) {
sessionHelper(t, request, "issue", 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)
defer test.ClearTestStorage(t)
keyshareSessions(t, client)
}
func TestDisclosureNewAttributeUpdateSchemeManager(t *testing.T) {
client := parseStorage(t)
defer test.ClearTestStorage(t)
......
// +build !local_tests
package irmaclient
import (
"testing"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/test"
"github.com/stretchr/testify/require"
)
// Test pinchange interaction
func TestKeyshareChangePin(t *testing.T) {
client := parseStorage(t)
defer test.ClearTestStorage(t)
require.NoError(t, client.keyshareChangePinWorker(irma.NewSchemeManagerIdentifier("test"), "12345", "54321"))
require.NoError(t, client.keyshareChangePinWorker(irma.NewSchemeManagerIdentifier("test"), "54321", "12345"))
}
// +build !unit_tests
package irmaclient
import (
......@@ -209,15 +207,6 @@ func TestWrongSchemeManager(t *testing.T) {
)
}
// Test pinchange interaction
func TestKeyshareChangePin(t *testing.T) {
client := parseStorage(t)
defer test.ClearTestStorage(t)
require.NoError(t, client.keyshareChangePinWorker(irma.NewSchemeManagerIdentifier("test"), "12345", "54321"))
require.NoError(t, client.keyshareChangePinWorker(irma.NewSchemeManagerIdentifier("test"), "54321", "12345"))
}
// ------
type TestClientHandler struct {
......
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