Skip to content

Commit

Permalink
Refactor keyResolver creation in IAM module
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rolandgroen committed Jan 25, 2024
1 parent 7fa9414 commit 839cdb4
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions auth/api/iam/openid4vp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -702,28 +702,8 @@ func TestWrapper_handlePresentationRequest(t *testing.T) {
require.Equal(t, http.StatusOK, httpResponse.statusCode)
assert.Contains(t, httpResponse.body.String(), "</html>")
})
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",
Expand Down

0 comments on commit 839cdb4

Please sign in to comment.