Skip to content

Commit

Permalink
remove types
Browse files Browse the repository at this point in the history
  • Loading branch information
reinkrul committed Sep 26, 2023
1 parent d0ef024 commit dcc57e6
Show file tree
Hide file tree
Showing 25 changed files with 129 additions and 191 deletions.
6 changes: 3 additions & 3 deletions auth/api/iam/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"github.com/nuts-foundation/nuts-node/core"
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vcr/openid4vci"
vdr2 "github.com/nuts-foundation/nuts-node/vdr"
"github.com/nuts-foundation/nuts-node/vdr/resolver"
vdr "github.com/nuts-foundation/nuts-node/vdr/types"
"html/template"
"net/http"
"sync"
Expand All @@ -49,13 +49,13 @@ var assets embed.FS
// Wrapper handles OAuth2 flows.
type Wrapper struct {
vcr vcr.VCR
vdr vdr.VDR
vdr vdr2.VDR
auth auth.AuthenticationServices
sessions *SessionManager
templates *template.Template
}

func New(authInstance auth.AuthenticationServices, vcrInstance vcr.VCR, vdrInstance vdr.VDR) *Wrapper {
func New(authInstance auth.AuthenticationServices, vcrInstance vcr.VCR, vdrInstance vdr2.VDR) *Wrapper {
templates := template.New("oauth2 templates")
_, err := templates.ParseFS(assets, "assets/*.html")
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions auth/api/iam/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/nuts-foundation/nuts-node/audit"
"github.com/nuts-foundation/nuts-node/auth"
"github.com/nuts-foundation/nuts-node/core"
vdr2 "github.com/nuts-foundation/nuts-node/vdr"
"github.com/nuts-foundation/nuts-node/vdr/resolver"
vdr "github.com/nuts-foundation/nuts-node/vdr/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
Expand Down Expand Up @@ -168,7 +168,7 @@ func statusCodeFrom(err error) int {
type testCtx struct {
client *Wrapper
authnServices *auth.MockAuthenticationServices
vdr *vdr.MockVDR
vdr *vdr2.MockVDR
resolver *resolver.MockDIDResolver
}

Expand All @@ -179,7 +179,7 @@ func newTestClient(t testing.TB) *testCtx {
authnServices := auth.NewMockAuthenticationServices(ctrl)
authnServices.EXPECT().PublicURL().Return(publicURL).AnyTimes()
resolver := resolver.NewMockDIDResolver(ctrl)
vdr := vdr.NewMockVDR(ctrl)
vdr := vdr2.NewMockVDR(ctrl)
vdr.EXPECT().Resolver().Return(resolver).AnyTimes()
return &testCtx{
authnServices: authnServices,
Expand Down
4 changes: 2 additions & 2 deletions auth/api/iam/openid4vp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/nuts-foundation/nuts-node/vcr/credential"
"github.com/nuts-foundation/nuts-node/vcr/holder"
"github.com/nuts-foundation/nuts-node/vcr/pe"
"github.com/nuts-foundation/nuts-node/vdr/types"
"github.com/nuts-foundation/nuts-node/vdr"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestWrapper_handlePresentationRequest(t *testing.T) {
ctrl := gomock.NewController(t)
peStore := &pe.DefinitionResolver{}
_ = peStore.LoadFromFile("test/presentation_definition_mapping.json")
mockVDR := types.NewMockVDR(ctrl)
mockVDR := vdr.NewMockVDR(ctrl)
mockVCR := vcr.NewMockVCR(ctrl)
mockWallet := holder.NewMockWallet(ctrl)
mockVCR.EXPECT().Wallet().Return(mockWallet)
Expand Down
6 changes: 3 additions & 3 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"errors"
"fmt"
"github.com/nuts-foundation/nuts-node/vcr/pe"
"github.com/nuts-foundation/nuts-node/vdr"
"github.com/nuts-foundation/nuts-node/vdr/resolver"
"github.com/nuts-foundation/nuts-node/vdr/types"
"net/url"
"path"
"time"
Expand Down Expand Up @@ -55,7 +55,7 @@ type Auth struct {
vcr vcr.VCR
pkiProvider pki.Provider
shutdownFunc func()
vdrInstance types.VDR
vdrInstance vdr.VDR
publicURL *url.URL
presentationDefinitions *pe.DefinitionResolver
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func (auth *Auth) PresentationDefinitions() *pe.DefinitionResolver {
}

// NewAuthInstance accepts a Config with several Nuts Engines and returns an instance of Auth
func NewAuthInstance(config Config, vdrInstance types.VDR, vcr vcr.VCR, keyStore crypto.KeyStore, serviceResolver didman.CompoundServiceResolver, jsonldManager jsonld.JSONLD, pkiProvider pki.Provider) *Auth {
func NewAuthInstance(config Config, vdrInstance vdr.VDR, vcr vcr.VCR, keyStore crypto.KeyStore, serviceResolver didman.CompoundServiceResolver, jsonldManager jsonld.JSONLD, pkiProvider pki.Provider) *Auth {
return &Auth{
config: config,
jsonldManager: jsonldManager,
Expand Down
4 changes: 2 additions & 2 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/nuts-foundation/nuts-node/crypto"
"github.com/nuts-foundation/nuts-node/pki"
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vdr/types"
"github.com/nuts-foundation/nuts-node/vdr"
"go.uber.org/mock/gomock"
"testing"

Expand All @@ -45,7 +45,7 @@ func TestAuth_Configure(t *testing.T) {
pkiMock := pki.NewMockProvider(ctrl)
pkiMock.EXPECT().AddTruststore(gomock.Any()) // uzi
pkiMock.EXPECT().CreateTLSConfig(gomock.Any()) // tlsConfig
vdrInstance := types.NewMockVDR(ctrl)
vdrInstance := vdr.NewMockVDR(ctrl)
vdrInstance.EXPECT().Resolver().AnyTimes()

i := NewAuthInstance(config, vdrInstance, vcr.NewTestVCRInstance(t), crypto.NewMemoryCryptoInstance(), nil, nil, pkiMock)
Expand Down
4 changes: 2 additions & 2 deletions auth/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package auth

import (
"github.com/nuts-foundation/nuts-node/vdr/types"
"github.com/nuts-foundation/nuts-node/vdr"
"testing"

"github.com/nuts-foundation/nuts-node/crypto"
Expand All @@ -42,7 +42,7 @@ func testInstance(t *testing.T, cfg Config) *Auth {
pkiMock := pki.NewMockProvider(ctrl)
pkiMock.EXPECT().AddTruststore(gomock.Any()).AnyTimes()
pkiMock.EXPECT().CreateTLSConfig(gomock.Any()).AnyTimes()
vdrInstance := types.NewMockVDR(ctrl)
vdrInstance := vdr.NewMockVDR(ctrl)
vdrInstance.EXPECT().Resolver().AnyTimes()
return NewAuthInstance(cfg, vdrInstance, vcrInstance, cryptoInstance, nil, nil, pkiMock)
}
6 changes: 3 additions & 3 deletions didman/didman.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"encoding/json"
"errors"
"fmt"
vdr2 "github.com/nuts-foundation/nuts-node/vdr"
"github.com/nuts-foundation/nuts-node/vdr/resolver"
"net/url"
"sync"
Expand All @@ -37,7 +38,6 @@ import (
"github.com/nuts-foundation/nuts-node/jsonld"
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vcr/credential"
"github.com/nuts-foundation/nuts-node/vdr/types"
"github.com/shengdoushi/base58"
)

Expand Down Expand Up @@ -87,14 +87,14 @@ func (e ErrReferencedServiceNotAnEndpoint) Is(other error) bool {

type didman struct {
jsonldManager jsonld.JSONLD
vdr types.VDR
vdr vdr2.VDR
vcr vcr.Finder
// callSerializer can be used to (un)lock a resource such as a DID to prevent parallel updates
callSerializer keyedMutex
}

// NewDidmanInstance creates a new didman instance with services set
func NewDidmanInstance(vdr types.VDR, vcr vcr.Finder, jsonldManager jsonld.JSONLD) Didman {
func NewDidmanInstance(vdr vdr2.VDR, vcr vcr.Finder, jsonldManager jsonld.JSONLD) Didman {
return &didman{
vdr: vdr,
vcr: vcr,
Expand Down
5 changes: 2 additions & 3 deletions didman/didman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/nuts-foundation/nuts-node/jsonld"
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vdr"
"github.com/nuts-foundation/nuts-node/vdr/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
Expand Down Expand Up @@ -972,7 +971,7 @@ func TestReferencedService(t *testing.T) {

type mockContext struct {
ctrl *gomock.Controller
vdr *types.MockVDR
vdr *vdr.MockVDR
vcr *vcr.MockFinder
didResolver *resolver.MockDIDResolver
instance Didman
Expand All @@ -982,7 +981,7 @@ type mockContext struct {
func newMockContext(t *testing.T) mockContext {
ctrl := gomock.NewController(t)
didResolver := resolver.NewMockDIDResolver(ctrl)
mockVDR := types.NewMockVDR(ctrl)
mockVDR := vdr.NewMockVDR(ctrl)
mockVDR.EXPECT().Resolver().Return(didResolver).AnyTimes()
mockVCR := vcr.NewMockFinder(ctrl)
instance := NewDidmanInstance(mockVDR, mockVCR, jsonld.NewTestJSONLDManager(t)).(*didman)
Expand Down
6 changes: 3 additions & 3 deletions golden_hammer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"github.com/nuts-foundation/nuts-node/network/transport"
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vcr/openid4vci"
"github.com/nuts-foundation/nuts-node/vdr"
"github.com/nuts-foundation/nuts-node/vdr/resolver"
"github.com/nuts-foundation/nuts-node/vdr/types"
"net/url"
"sort"
"strings"
Expand All @@ -43,7 +43,7 @@ var _ core.Named = (*GoldenHammer)(nil)
var _ core.Configurable = (*GoldenHammer)(nil)
var _ core.Injectable = (*GoldenHammer)(nil)

func New(vdrInstance types.VDR, didmanAPI didman.Didman) *GoldenHammer {
func New(vdrInstance vdr.VDR, didmanAPI didman.Didman) *GoldenHammer {
return &GoldenHammer{
routines: &sync.WaitGroup{},
vdrInstance: vdrInstance,
Expand All @@ -62,7 +62,7 @@ type GoldenHammer struct {
cancelFunc context.CancelFunc
routines *sync.WaitGroup
didmanAPI didman.Didman
vdrInstance types.VDR
vdrInstance vdr.VDR
fixedDocumentDIDs map[string]bool
tlsConfig *tls.Config
}
Expand Down
14 changes: 7 additions & 7 deletions golden_hammer/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"github.com/nuts-foundation/nuts-node/test"
"github.com/nuts-foundation/nuts-node/test/pki"
"github.com/nuts-foundation/nuts-node/vcr/openid4vci"
vdr2 "github.com/nuts-foundation/nuts-node/vdr"
"github.com/nuts-foundation/nuts-node/vdr/didnuts/didstore"
"github.com/nuts-foundation/nuts-node/vdr/resolver"
"github.com/nuts-foundation/nuts-node/vdr/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestGoldenHammer_Fix(t *testing.T) {
didResolver.EXPECT().Resolve(vendorDID, gomock.Any()).Return(&vendorDocumentWithBaseURL, nil, nil).MinTimes(1)
didResolver.EXPECT().Resolve(clientADID, gomock.Any()).Return(&clientDocumentWithBaseURL, nil, nil).MinTimes(1)
didResolver.EXPECT().Resolve(clientBDID, gomock.Any()).Return(&clientDocumentWithBaseURL, nil, nil).MinTimes(1)
vdr := types.NewMockVDR(ctrl)
vdr := vdr2.NewMockVDR(ctrl)
vdr.EXPECT().Resolver().Return(didResolver).MinTimes(1)
vdr.EXPECT().ListOwned(gomock.Any()).Return([]did.DID{vendorDID, clientADID, clientBDID}, nil)
service := New(vdr, nil)
Expand All @@ -138,7 +138,7 @@ func TestGoldenHammer_Fix(t *testing.T) {
docClientB := clientDocumentWithoutBaseURL
docClientB.ID = clientBDID

vdr := types.NewMockVDR(ctrl)
vdr := vdr2.NewMockVDR(ctrl)
vdr.EXPECT().Resolver().Return(didResolver).MinTimes(1)
// Order DIDs such that care organization DID is first, to test ordering
vdr.EXPECT().ListOwned(gomock.Any()).Return([]did.DID{clientADID, vendorDID, clientBDID}, nil)
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestGoldenHammer_Fix(t *testing.T) {
ctrl := gomock.NewController(t)
didResolver := didstore.NewMockStore(ctrl)
didResolver.EXPECT().Resolve(vendorDID, gomock.Any()).Return(&vendorDocumentWithoutBaseURL, nil, nil).MinTimes(1)
vdr := types.NewMockVDR(ctrl)
vdr := vdr2.NewMockVDR(ctrl)
vdr.EXPECT().Resolver().Return(didResolver).MinTimes(1)
vdr.EXPECT().ListOwned(gomock.Any()).Return([]did.DID{vendorDID}, nil)
service := New(vdr, nil)
Expand All @@ -199,7 +199,7 @@ func TestGoldenHammer_Fix(t *testing.T) {
didResolver.EXPECT().Resolve(clientBDID, gomock.Any()).Return(&docClientB, nil, nil).MinTimes(1)
// Client C is owned, but not linked to the vendor (via NutsComm service), so do not register the service on that one
didResolver.EXPECT().Resolve(clientCDID, gomock.Any()).Return(&did.Document{ID: clientCDID}, nil, nil).MinTimes(1)
vdr := types.NewMockVDR(ctrl)
vdr := vdr2.NewMockVDR(ctrl)
vdr.EXPECT().Resolver().Return(didResolver).MinTimes(1)
vdr.EXPECT().ListOwned(gomock.Any()).Return([]did.DID{vendorDID, clientADID, clientBDID, clientCDID}, nil)
didmanAPI := didman.NewMockDidman(ctrl)
Expand All @@ -220,7 +220,7 @@ func TestGoldenHammer_Fix(t *testing.T) {
ctrl := gomock.NewController(t)
didResolver := resolver.NewMockDIDResolver(ctrl)
didResolver.EXPECT().Resolve(vendorDID, gomock.Any()).Return(nil, nil, fmt.Errorf("resolve error"))
vdr := types.NewMockVDR(ctrl)
vdr := vdr2.NewMockVDR(ctrl)
vdr.EXPECT().Resolver().Return(didResolver)
vdr.EXPECT().ListOwned(gomock.Any()).Return([]did.DID{vendorDID}, nil)
service := New(vdr, nil)
Expand All @@ -241,7 +241,7 @@ func TestGoldenHammer_Lifecycle(t *testing.T) {

fixCalled := &atomic.Int64{}
ctrl := gomock.NewController(t)
vdr := types.NewMockVDR(ctrl)
vdr := vdr2.NewMockVDR(ctrl)
vdr.EXPECT().ListOwned(gomock.Any()).DoAndReturn(func(_ context.Context) ([]did.DID, error) {
fixCalled.Add(1)
return []did.DID{}, nil
Expand Down
1 change: 1 addition & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ gen-mocks:
mockgen -destination=vcr/verifier/mock.go -package=verifier -source=vcr/verifier/interface.go
mockgen -destination=vdr/didnuts/ambassador_mock.go -package=didnuts -source=vdr/didnuts/ambassador.go
mockgen -destination=vdr/didnuts/didstore/mock.go -package=didstore -source=vdr/didnuts/didstore/interface.go
mockgen -destination=vdr/mock.go -package=vdr -source=vdr/interface.go
mockgen -destination=vdr/resolver/did_mock.go -package=resolver -source=vdr/resolver/did.go
mockgen -destination=vdr/resolver/service_mock.go -package=resolver -source=vdr/resolver/service.go
mockgen -destination=vdr/resolver/key_mock.go -package=resolver -source=vdr/resolver/key.go
Expand Down
10 changes: 5 additions & 5 deletions vcr/api/openid4vci/v0/holder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vcr/holder"
"github.com/nuts-foundation/nuts-node/vcr/openid4vci"
"github.com/nuts-foundation/nuts-node/vdr/types"
"github.com/nuts-foundation/nuts-node/vdr/management"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
Expand All @@ -41,7 +41,7 @@ func TestWrapper_GetOAuth2ClientMetadata(t *testing.T) {
ctrl := gomock.NewController(t)
wallet := holder.NewMockOpenIDHandler(ctrl)
wallet.EXPECT().Metadata().Return(openid4vci.OAuth2ClientMetadata{CredentialOfferEndpoint: "endpoint"})
documentOwner := types.NewMockDocumentOwner(ctrl)
documentOwner := management.NewMockDocumentOwner(ctrl)
documentOwner.EXPECT().IsOwner(gomock.Any(), gomock.Any()).Return(true, nil)
service := vcr.NewMockVCR(ctrl)
service.EXPECT().GetOpenIDHolder(gomock.Any(), holderDID).Return(wallet, nil)
Expand All @@ -57,7 +57,7 @@ func TestWrapper_GetOAuth2ClientMetadata(t *testing.T) {
})
t.Run("unknown tenant", func(t *testing.T) {
ctrl := gomock.NewController(t)
documentOwner := types.NewMockDocumentOwner(ctrl)
documentOwner := management.NewMockDocumentOwner(ctrl)
documentOwner.EXPECT().IsOwner(gomock.Any(), gomock.Any()).Return(false, nil)
api := Wrapper{DocumentOwner: documentOwner}

Expand All @@ -74,7 +74,7 @@ func TestWrapper_HandleCredentialOffer(t *testing.T) {
ctrl := gomock.NewController(t)
wallet := holder.NewMockOpenIDHandler(ctrl)
wallet.EXPECT().HandleCredentialOffer(gomock.Any(), gomock.Any())
documentOwner := types.NewMockDocumentOwner(ctrl)
documentOwner := management.NewMockDocumentOwner(ctrl)
documentOwner.EXPECT().IsOwner(gomock.Any(), gomock.Any()).Return(true, nil)
service := vcr.NewMockVCR(ctrl)
service.EXPECT().GetOpenIDHolder(gomock.Any(), holderDID).Return(wallet, nil)
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestWrapper_HandleCredentialOffer(t *testing.T) {

t.Run("unknown tenant", func(t *testing.T) {
ctrl := gomock.NewController(t)
documentOwner := types.NewMockDocumentOwner(ctrl)
documentOwner := management.NewMockDocumentOwner(ctrl)
documentOwner.EXPECT().IsOwner(gomock.Any(), gomock.Any()).Return(false, nil)
api := Wrapper{DocumentOwner: documentOwner}

Expand Down
Loading

0 comments on commit dcc57e6

Please sign in to comment.