Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
woutslakhorst committed Sep 11, 2024
1 parent 83f7fe6 commit 6f10441
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
1 change: 1 addition & 0 deletions discovery/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ func TestModule_Search(t *testing.T) {
Fields: map[string]interface{}{
"auth_server_url_field": "https://example.com/oauth2/alice",
"issuer_field": authorityDID,
"type_field": []string{vc.VerifiableCredentialType, credential.DiscoveryRegistrationCredentialType},
},
Parameters: defaultRegistrationParams(aliceSubject),
},
Expand Down
40 changes: 34 additions & 6 deletions discovery/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
ssi "github.com/nuts-foundation/go-did"
"github.com/nuts-foundation/go-did/did"
"github.com/nuts-foundation/go-did/vc"
"github.com/nuts-foundation/nuts-node/core/to"
"github.com/nuts-foundation/nuts-node/test"
"github.com/nuts-foundation/nuts-node/vcr/credential"
"github.com/nuts-foundation/nuts-node/vcr/pe"
Expand All @@ -55,25 +56,44 @@ var unsupportedDID did.DID
var testServiceID = "usecase_v1"

func testDefinitions() map[string]ServiceDefinition {
issuerPattern := "did:example:authority"
issuerFieldID := "issuer_field"
authServerURLFieldID := "auth_server_url_field"
return map[string]ServiceDefinition{
testServiceID: {
ID: testServiceID,
Endpoint: "http://example.com/usecase",
PresentationDefinition: pe.PresentationDefinition{
Format: &pe.PresentationDefinitionClaimFormatDesignations{
"ldp_vc": {
"proof_type": []string{
"JsonWebSignature2020",
},
},
"ldp_vp": {
"proof_type": []string{
"JsonWebSignature2020",
},
},
"jwt_vc": {
"alg": []string{
"ES256",
},
},
"jwt_vp": {
"alg": []string{
"ES256",
},
},
},
InputDescriptors: []*pe.InputDescriptor{
{
Id: "1",
Constraints: &pe.Constraints{
Fields: []pe.Field{
{
Id: &issuerFieldID,
Id: to.Ptr("issuer_field"),
Path: []string{"$.issuer"},
Filter: &pe.Filter{
Type: "string",
Pattern: &issuerPattern,
Pattern: to.Ptr("did:example:authority"),
},
},
},
Expand All @@ -84,12 +104,20 @@ func testDefinitions() map[string]ServiceDefinition {
Constraints: &pe.Constraints{
Fields: []pe.Field{
{
Id: &authServerURLFieldID,
Id: to.Ptr("auth_server_url_field"),
Path: []string{"$.credentialSubject.authServerURL", "$.credentialSubject[0].authServerURL"},
Filter: &pe.Filter{
Type: "string",
},
},
{
Id: to.Ptr("type_field"),
Path: []string{"$.type"},
Filter: &pe.Filter{
Type: "string",
Const: to.Ptr(credential.DiscoveryRegistrationCredentialType),
},
},
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions vcr/pe/presentation_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ func matchFormat(format *PresentationDefinitionClaimFormatDesignations, credenti
return true
}

if credential.Format() == "" {
// holder credential
return true
}

asMap := map[string]map[string][]string(*format)
switch credential.Format() {
case vc.JSONLDCredentialProofFormat:
Expand Down

0 comments on commit 6f10441

Please sign in to comment.