From 839cdb42b6068eeeb0a2a584d204ac49b31099c8 Mon Sep 17 00:00:00 2001 From: Roland Groen Date: Thu, 25 Jan 2024 11:27:52 +0100 Subject: [PATCH] Refactor keyResolver creation in IAM module Moved the creation and configuration of keyResolver instances from the constructor to each method where it's used in the IAM module. This refactor allows for greater flexibility by enabling different configurations of keyResolver within each method. --- auth/api/iam/openid4vp_test.go | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/auth/api/iam/openid4vp_test.go b/auth/api/iam/openid4vp_test.go index f4a97b0751..874ee16073 100644 --- a/auth/api/iam/openid4vp_test.go +++ b/auth/api/iam/openid4vp_test.go @@ -33,8 +33,8 @@ import ( "github.com/nuts-foundation/go-did/vc" "github.com/nuts-foundation/nuts-node/auth" "github.com/nuts-foundation/nuts-node/auth/oauth" - "github.com/nuts-foundation/nuts-node/crypto" oauth2 "github.com/nuts-foundation/nuts-node/auth/services/oauth" + "github.com/nuts-foundation/nuts-node/crypto" "github.com/nuts-foundation/nuts-node/policy" "github.com/nuts-foundation/nuts-node/storage" "github.com/nuts-foundation/nuts-node/test" @@ -626,7 +626,7 @@ func TestWrapper_sendAndHandleDirectPostError(t *testing.T) { } func TestWrapper_sendPresentationRequest(t *testing.T) { - instance := New(nil, nil, nil, nil, nil) + instance := New(nil, nil, nil, nil, nil, nil) redirectURI, _ := url.Parse("https://example.com/redirect") verifierID, _ := url.Parse("https://example.com/verifier") @@ -702,28 +702,8 @@ func TestWrapper_handlePresentationRequest(t *testing.T) { require.Equal(t, http.StatusOK, httpResponse.statusCode) assert.Contains(t, httpResponse.body.String(), "") }) - t.Run("unsupported scope", func(t *testing.T) { - ctrl := gomock.NewController(t) - peStore := &pe.DefinitionResolver{} - _ = peStore.LoadFromFile("test/presentation_definition_mapping.json") - mockAuth := auth.NewMockAuthenticationServices(ctrl) - mockAuth.EXPECT().PresentationDefinitions().Return(peStore) - instance := New(mockAuth, nil, nil, nil, nil) - - params := map[string]string{ - "scope": "unsupported", - "response_type": "code", - "response_mode": "direct_post", - "client_metadata_uri": "https://example.com/client_metadata.xml", - } - - response, err := instance.handlePresentationRequest(params, createSession(params, holderDID)) - - requireOAuthError(t, err, oauth.InvalidRequest, "unsupported scope for presentation exchange: unsupported") - assert.Nil(t, response) - }) t.Run("invalid response_mode", func(t *testing.T) { - instance := New(nil, nil, nil, nil, nil) + instance := New(nil, nil, nil, nil, nil, nil) params := map[string]string{ "scope": "eOverdracht-overdrachtsbericht", "response_type": "code",