From d0ef024938ec719cbec4860890b3bb4a66380012 Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Tue, 26 Sep 2023 10:20:58 +0200 Subject: [PATCH] w --- auth/api/iam/api_test.go | 4 +- auth/services/notary/notary_test.go | 5 +- auth/services/oauth/authz_server_test.go | 9 +- auth/services/oauth/relying_party_test.go | 9 +- crypto/api/v1/api_test.go | 5 +- didman/didman_test.go | 4 +- golden_hammer/module_test.go | 4 +- makefile | 6 +- network/dag/keys_test.go | 3 +- network/dag/pal_test.go | 9 +- network/dag/verifier_test.go | 3 +- network/network_test.go | 14 +- network/transport/grpc/authenticator_test.go | 11 +- network/transport/v2/protocol_test.go | 6 +- vcr/holder/openid_test.go | 5 +- vcr/holder/wallet_test.go | 17 +- vcr/issuer/keyresolver_test.go | 7 +- vcr/issuer/network_publisher_test.go | 25 +- vcr/issuer/openid_test.go | 5 +- vcr/openid4vci/identifiers_test.go | 11 +- vcr/test.go | 4 +- vcr/vcr_test.go | 2 +- vcr/verifier/verifier_test.go | 9 +- vdr/api/v1/api_test.go | 8 +- vdr/did_owner_test.go | 18 +- vdr/didnuts/ambassador_test.go | 11 +- vdr/didnuts/manipulator_test.go | 9 +- vdr/didnuts/resolver_test.go | 21 +- vdr/didnuts/validators_test.go | 3 +- vdr/management/finder_mock.go | 92 ++++ vdr/management/management_mock.go | 247 ++++++++++ vdr/resolver/did_mock.go | 51 +++ vdr/resolver/did_test.go | 9 +- vdr/resolver/key_mock.go | 108 +++++ vdr/resolver/key_test.go | 5 +- vdr/resolver/service_mock.go | 66 +++ vdr/resolver/service_test.go | 13 +- vdr/types/mock.go | 452 +------------------ 38 files changed, 695 insertions(+), 595 deletions(-) create mode 100644 vdr/management/finder_mock.go create mode 100644 vdr/management/management_mock.go create mode 100644 vdr/resolver/did_mock.go create mode 100644 vdr/resolver/key_mock.go create mode 100644 vdr/resolver/service_mock.go diff --git a/auth/api/iam/api_test.go b/auth/api/iam/api_test.go index c948f0f53f..34e94bf629 100644 --- a/auth/api/iam/api_test.go +++ b/auth/api/iam/api_test.go @@ -169,7 +169,7 @@ type testCtx struct { client *Wrapper authnServices *auth.MockAuthenticationServices vdr *vdr.MockVDR - resolver *vdr.MockDIDResolver + resolver *resolver.MockDIDResolver } func newTestClient(t testing.TB) *testCtx { @@ -178,7 +178,7 @@ func newTestClient(t testing.TB) *testCtx { ctrl := gomock.NewController(t) authnServices := auth.NewMockAuthenticationServices(ctrl) authnServices.EXPECT().PublicURL().Return(publicURL).AnyTimes() - resolver := vdr.NewMockDIDResolver(ctrl) + resolver := resolver.NewMockDIDResolver(ctrl) vdr := vdr.NewMockVDR(ctrl) vdr.EXPECT().Resolver().Return(resolver).AnyTimes() return &testCtx{ diff --git a/auth/services/notary/notary_test.go b/auth/services/notary/notary_test.go index 1c022224d4..baaadc33f5 100644 --- a/auth/services/notary/notary_test.go +++ b/auth/services/notary/notary_test.go @@ -35,7 +35,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" irma "github.com/privacybydesign/irmago" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -372,7 +371,7 @@ type testContext struct { signerMock *contract.MockSigner vcr *vcr.MockVCR - keyResolver *types.MockKeyResolver + keyResolver *resolver.MockKeyResolver keyStore *crypto.MockKeyStore notary notary } @@ -388,7 +387,7 @@ func buildContext(t *testing.T) *testContext { ctx := &testContext{ ctrl: ctrl, vcr: vcr.NewMockVCR(ctrl), - keyResolver: types.NewMockKeyResolver(ctrl), + keyResolver: resolver.NewMockKeyResolver(ctrl), keyStore: crypto.NewMockKeyStore(ctrl), signerMock: signerMock, } diff --git a/auth/services/oauth/authz_server_test.go b/auth/services/oauth/authz_server_test.go index ae68a14b59..33c06ce382 100644 --- a/auth/services/oauth/authz_server_test.go +++ b/auth/services/oauth/authz_server_test.go @@ -48,7 +48,6 @@ import ( vcrTypes "github.com/nuts-foundation/nuts-node/vcr/types" verifier2 "github.com/nuts-foundation/nuts-node/vcr/verifier" "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" @@ -855,8 +854,8 @@ type testContext struct { contractNotary *services.MockContractNotary keyStore *crypto.MockKeyStore nameResolver *vcr.MockFinder - didResolver *types.MockDIDResolver - keyResolver *types.MockKeyResolver + didResolver *resolver.MockDIDResolver + keyResolver *resolver.MockKeyResolver serviceResolver *didman.MockCompoundServiceResolver oauthService *authzServer verifier *verifier2.MockVerifier @@ -869,9 +868,9 @@ var createContext = func(t *testing.T) *testContext { contractNotaryMock := services.NewMockContractNotary(ctrl) privateKeyStore := crypto.NewMockKeyStore(ctrl) nameResolver := vcr.NewMockFinder(ctrl) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) serviceResolver := didman.NewMockCompoundServiceResolver(ctrl) - didResolver := types.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) verifier := verifier2.NewMockVerifier(ctrl) return &testContext{ diff --git a/auth/services/oauth/relying_party_test.go b/auth/services/oauth/relying_party_test.go index f4e48dc792..7cd31b6837 100644 --- a/auth/services/oauth/relying_party_test.go +++ b/auth/services/oauth/relying_party_test.go @@ -40,7 +40,6 @@ import ( "github.com/nuts-foundation/nuts-node/didman" "github.com/nuts-foundation/nuts-node/vcr/credential" "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" @@ -252,8 +251,8 @@ func TestRelyingParty_Configure(t *testing.T) { type rpTestContext struct { ctrl *gomock.Controller keyStore *crypto.MockKeyStore - didResolver *types.MockDIDResolver - keyResolver *types.MockKeyResolver + didResolver *resolver.MockDIDResolver + keyResolver *resolver.MockKeyResolver serviceResolver *didman.MockCompoundServiceResolver relyingParty *relyingParty audit context.Context @@ -263,9 +262,9 @@ var createRPContext = func(t *testing.T) *rpTestContext { ctrl := gomock.NewController(t) privateKeyStore := crypto.NewMockKeyStore(ctrl) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) serviceResolver := didman.NewMockCompoundServiceResolver(ctrl) - didResolver := types.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) return &rpTestContext{ ctrl: ctrl, diff --git a/crypto/api/v1/api_test.go b/crypto/api/v1/api_test.go index 1d928ff49a..969fd80bb1 100644 --- a/crypto/api/v1/api_test.go +++ b/crypto/api/v1/api_test.go @@ -25,7 +25,6 @@ import ( "github.com/nuts-foundation/nuts-node/audit" "github.com/nuts-foundation/nuts-node/core" "github.com/nuts-foundation/nuts-node/vdr/resolver" - "github.com/nuts-foundation/nuts-node/vdr/types" "net/http" "testing" @@ -475,14 +474,14 @@ func TestWrapper_DecryptJwe(t *testing.T) { type mockContext struct { ctrl *gomock.Controller keyStore *crypto.MockKeyStore - keyResolver *types.MockKeyResolver + keyResolver *resolver.MockKeyResolver client *Wrapper } func newMockContext(t *testing.T) mockContext { ctrl := gomock.NewController(t) keyStore := crypto.NewMockKeyStore(ctrl) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) client := &Wrapper{C: keyStore, K: keyResolver} return mockContext{ diff --git a/didman/didman_test.go b/didman/didman_test.go index a4f50560c1..01e16f353f 100644 --- a/didman/didman_test.go +++ b/didman/didman_test.go @@ -974,14 +974,14 @@ type mockContext struct { ctrl *gomock.Controller vdr *types.MockVDR vcr *vcr.MockFinder - didResolver *types.MockDIDResolver + didResolver *resolver.MockDIDResolver instance Didman audit context.Context } func newMockContext(t *testing.T) mockContext { ctrl := gomock.NewController(t) - didResolver := types.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) mockVDR := types.NewMockVDR(ctrl) mockVDR.EXPECT().Resolver().Return(didResolver).AnyTimes() mockVCR := vcr.NewMockFinder(ctrl) diff --git a/golden_hammer/module_test.go b/golden_hammer/module_test.go index 861a96240f..cc331e29e9 100644 --- a/golden_hammer/module_test.go +++ b/golden_hammer/module_test.go @@ -109,7 +109,7 @@ func TestGoldenHammer_Fix(t *testing.T) { t.Run("nothing to fix", func(t *testing.T) { // vendor and care organization DIDs already have the required service, so there's nothing to fix ctrl := gomock.NewController(t) - didResolver := types.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) 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) @@ -218,7 +218,7 @@ func TestGoldenHammer_Fix(t *testing.T) { }) t.Run("resolve error", func(t *testing.T) { ctrl := gomock.NewController(t) - didResolver := types.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) didResolver.EXPECT().Resolve(vendorDID, gomock.Any()).Return(nil, nil, fmt.Errorf("resolve error")) vdr := types.NewMockVDR(ctrl) vdr.EXPECT().Resolver().Return(didResolver) diff --git a/makefile b/makefile index 505d59b9ec..3506359ee0 100644 --- a/makefile +++ b/makefile @@ -48,7 +48,11 @@ 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/types/mock.go -package=types -source=vdr/types/interface.go -self_package github.com/nuts-foundation/nuts-node/vdr/types --imports did=github.com/nuts-foundation/go-did/did + 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 + mockgen -destination=vdr/management/management_mock.go -package=management -source=vdr/management/management.go + mockgen -destination=vdr/management/finder_mock.go -package=management -source=vdr/management/finder.go gen-api: oapi-codegen --config codegen/configs/common_ssi_types.yaml docs/_static/common/ssi_types.yaml | gofmt > api/ssi_types.go diff --git a/network/dag/keys_test.go b/network/dag/keys_test.go index aa8828952f..89d8bf56e3 100644 --- a/network/dag/keys_test.go +++ b/network/dag/keys_test.go @@ -25,7 +25,6 @@ import ( "github.com/nuts-foundation/go-did/did" "github.com/nuts-foundation/nuts-node/crypto/hash" "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/mock/gomock" @@ -34,7 +33,7 @@ import ( func TestNutsKeyResolver_ResolvePublicKey(t *testing.T) { ctrl := gomock.NewController(t) - didResolver := types.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) keyResolver := SourceTXKeyResolver{Resolver: didResolver} pk, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) doc := &did.Document{ diff --git a/network/dag/pal_test.go b/network/dag/pal_test.go index c4a21da9b5..97ca7a5d97 100644 --- a/network/dag/pal_test.go +++ b/network/dag/pal_test.go @@ -31,7 +31,6 @@ import ( "github.com/nuts-foundation/go-did/did" "github.com/nuts-foundation/nuts-node/crypto" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" ) @@ -47,7 +46,7 @@ func TestEncryptPal(t *testing.T) { // Encrypt ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKey(*pA, nil, resolver.KeyAgreement).Return(ssi.URI{}, pkA.Public(), nil) keyResolver.EXPECT().ResolveKey(*pB, nil, resolver.KeyAgreement).Return(ssi.URI{}, pkB.Public(), nil) expected := PAL{*pA, *pB} @@ -64,14 +63,14 @@ func TestEncryptPal(t *testing.T) { }) t.Run("ok - empty input yields empty output", func(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) pal, err := PAL{}.Encrypt(keyResolver) assert.Nil(t, pal) assert.NoError(t, err) }) t.Run("error - keyAgreement key type is not supported", func(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKey(*pA, nil, resolver.KeyAgreement).Return(ssi.URI{}, &rsa.PublicKey{}, nil) pal, err := PAL{*pA}.Encrypt(keyResolver) assert.Nil(t, pal) @@ -79,7 +78,7 @@ func TestEncryptPal(t *testing.T) { }) t.Run("error - no keyAgreements", func(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKey(*pA, nil, resolver.KeyAgreement).Return(ssi.URI{}, nil, resolver.ErrKeyNotFound) pal, err := PAL{*pA}.Encrypt(keyResolver) assert.Nil(t, pal) diff --git a/network/dag/verifier_test.go b/network/dag/verifier_test.go index 16a6e445e7..867948d26e 100644 --- a/network/dag/verifier_test.go +++ b/network/dag/verifier_test.go @@ -34,7 +34,6 @@ import ( "github.com/nuts-foundation/go-stoabs" nutsCrypto "github.com/nuts-foundation/nuts-node/crypto" "github.com/nuts-foundation/nuts-node/crypto/hash" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" ) @@ -125,7 +124,7 @@ func TestTransactionSignatureVerifier(t *testing.T) { t.Run("unable to resolve key by hash", func(t *testing.T) { d := CreateSignedTestTransaction(1, time.Now(), nil, "foo/bar", false) ctrl := gomock.NewController(t) - keyResolver := types.NewMockNutsKeyResolver(ctrl) + keyResolver := resolver.NewMockNutsKeyResolver(ctrl) keyResolver.EXPECT().ResolvePublicKey(gomock.Any(), gomock.Any()).Return(nil, errors.New("failed")) err := NewTransactionSignatureVerifier(keyResolver)(nil, d) diff --git a/network/network_test.go b/network/network_test.go index 5cbe50013f..9bc73af825 100644 --- a/network/network_test.go +++ b/network/network_test.go @@ -30,6 +30,7 @@ import ( ssi "github.com/nuts-foundation/go-did" testPKI "github.com/nuts-foundation/nuts-node/test/pki" "github.com/nuts-foundation/nuts-node/vdr/didnuts/didstore" + "github.com/nuts-foundation/nuts-node/vdr/management" "github.com/nuts-foundation/nuts-node/vdr/resolver" "math" "net/http" @@ -54,7 +55,6 @@ import ( "github.com/nuts-foundation/nuts-node/pki" "github.com/nuts-foundation/nuts-node/storage" "github.com/nuts-foundation/nuts-node/test/io" - vdrTypes "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" @@ -69,9 +69,9 @@ type networkTestContext struct { didStore *didstore.MockStore keyStore crypto.KeyStore keyStorage spi.Storage - keyResolver *vdrTypes.MockKeyResolver + keyResolver *resolver.MockKeyResolver protocol *transport.MockProtocol - docFinder *vdrTypes.MockDocFinder + docFinder *management.MockDocFinder eventPublisher *events.MockEvent pkiValidator *pki.MockValidator } @@ -1082,7 +1082,7 @@ func Test_connectToKnownNodes(t *testing.T) { // Use actual test instance because the unit test's createNetwork mocks too much for us network := NewTestNetworkInstance(t) - docFinder := vdrTypes.NewMockDocFinder(ctrl) + docFinder := management.NewMockDocFinder(ctrl) network.didDocumentFinder = docFinder network.config.EnableDiscovery = true @@ -1107,7 +1107,7 @@ func Test_connectToKnownNodes(t *testing.T) { // Use actual test instance because the unit test's createNetwork mocks too much for us network := NewTestNetworkInstance(t) - docFinder := vdrTypes.NewMockDocFinder(ctrl) + docFinder := management.NewMockDocFinder(ctrl) network.didDocumentFinder = docFinder network.config.EnableDiscovery = true connectionManager := transport.NewMockConnectionManager(ctrl) @@ -1319,8 +1319,8 @@ func createNetwork(t *testing.T, ctrl *gomock.Controller, cfgFn ...func(config * } keyStorage := crypto.NewMemoryStorage() keyStore := crypto.NewTestCryptoInstance(keyStorage) - keyResolver := vdrTypes.NewMockKeyResolver(ctrl) - docFinder := vdrTypes.NewMockDocFinder(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) + docFinder := management.NewMockDocFinder(ctrl) didStore := didstore.NewMockStore(ctrl) eventPublisher := events.NewMockEvent(ctrl) storageEngine := storage.NewTestStorageEngine(t) diff --git a/network/transport/grpc/authenticator_test.go b/network/transport/grpc/authenticator_test.go index 819b02c052..889c25fedf 100644 --- a/network/transport/grpc/authenticator_test.go +++ b/network/transport/grpc/authenticator_test.go @@ -28,7 +28,6 @@ import ( ssi "github.com/nuts-foundation/go-did" "github.com/nuts-foundation/go-did/did" "github.com/nuts-foundation/nuts-node/network/transport" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" ) @@ -49,7 +48,7 @@ func Test_tlsAuthenticator_Authenticate(t *testing.T) { t.Run("ok", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(query, gomock.Any()).Return(did.Service{ServiceEndpoint: "grpc://nuts.nl:5555"}, nil) authenticator := NewTLSAuthenticator(serviceResolver) @@ -60,7 +59,7 @@ func Test_tlsAuthenticator_Authenticate(t *testing.T) { }) t.Run("ok - case insensitive comparison", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(query, gomock.Any()).Return(did.Service{ServiceEndpoint: "grpc://Nuts.nl:5555"}, nil) authenticator := NewTLSAuthenticator(serviceResolver) @@ -71,7 +70,7 @@ func Test_tlsAuthenticator_Authenticate(t *testing.T) { }) t.Run("ok - wildcard comparison", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(query, gomock.Any()).Return(did.Service{ServiceEndpoint: "grpc://node.nuts.nl:5555"}, nil) authenticator := NewTLSAuthenticator(serviceResolver) expectedPeer := transport.Peer{ @@ -89,7 +88,7 @@ func Test_tlsAuthenticator_Authenticate(t *testing.T) { transportPeer := transport.Peer{ID: "peer", Certificate: cert} t.Run("DNS names do not match", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(query, gomock.Any()).Return(did.Service{ServiceEndpoint: "grpc://nootjes.nl:5555"}, nil) authenticator := NewTLSAuthenticator(serviceResolver) @@ -106,7 +105,7 @@ func Test_tlsAuthenticator_Authenticate(t *testing.T) { }) t.Run("DID document not found", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(query, gomock.Any()).Return(did.Service{}, resolver.ErrNotFound) authenticator := NewTLSAuthenticator(serviceResolver) diff --git a/network/transport/v2/protocol_test.go b/network/transport/v2/protocol_test.go index 68f40993a7..1912e6b273 100644 --- a/network/transport/v2/protocol_test.go +++ b/network/transport/v2/protocol_test.go @@ -23,6 +23,7 @@ import ( "errors" "fmt" "github.com/nuts-foundation/go-stoabs" + "github.com/nuts-foundation/nuts-node/vdr/resolver" "github.com/stretchr/testify/require" "go.uber.org/goleak" "strings" @@ -43,14 +44,13 @@ import ( "github.com/nuts-foundation/nuts-node/network/dag" "github.com/nuts-foundation/nuts-node/network/transport" "github.com/nuts-foundation/nuts-node/network/transport/grpc" - vdr "github.com/nuts-foundation/nuts-node/vdr/types" ) type protocolMocks struct { Controller *gomock.Controller State *dag.MockState PayloadScheduler *dag.MockNotifier - DIDResolver *vdr.MockDIDResolver + DIDResolver *resolver.MockDIDResolver Decrypter *crypto.MockDecrypter Gossip *gossip.MockManager ConnectionList *grpc.MockConnectionList @@ -79,7 +79,7 @@ func newTestProtocol(t *testing.T, nodeDID *did.DID) (*protocol, protocolMocks) ctrl := gomock.NewController(t) dirname := io.TestDirectory(t) - didResolver := vdr.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) decrypter := crypto.NewMockDecrypter(ctrl) state := dag.NewMockState(ctrl) gMan := gossip.NewMockManager(ctrl) diff --git a/vcr/holder/openid_test.go b/vcr/holder/openid_test.go index 1c68607e3c..a7bca1967a 100644 --- a/vcr/holder/openid_test.go +++ b/vcr/holder/openid_test.go @@ -30,7 +30,6 @@ import ( "github.com/nuts-foundation/nuts-node/vcr/openid4vci" "github.com/nuts-foundation/nuts-node/vcr/types" "github.com/nuts-foundation/nuts-node/vdr/resolver" - vdrTypes "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" @@ -98,7 +97,7 @@ func Test_wallet_HandleCredentialOffer(t *testing.T) { "iat": int64(1735689600), "nonce": nonce, }, gomock.Any(), "key-id").Return("signed-jwt", nil) - keyResolver := vdrTypes.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKey(holderDID, nil, resolver.NutsSigningKeyType).Return(ssi.MustParseURI("key-id"), nil, nil) nowFunc = func() time.Time { @@ -238,7 +237,7 @@ func Test_wallet_HandleCredentialOffer(t *testing.T) { }, nil) jwtSigner := crypto.NewMockJWTSigner(ctrl) jwtSigner.EXPECT().SignJWT(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) - keyResolver := vdrTypes.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKey(holderDID, nil, resolver.NutsSigningKeyType) w := NewOpenIDHandler(holderDID, "https://holder.example.com", &http.Client{}, nil, jwtSigner, keyResolver).(*openidHandler) diff --git a/vcr/holder/wallet_test.go b/vcr/holder/wallet_test.go index 0139353ebb..a2b9dfca02 100644 --- a/vcr/holder/wallet_test.go +++ b/vcr/holder/wallet_test.go @@ -40,7 +40,6 @@ import ( "github.com/nuts-foundation/nuts-node/vcr/signature/proof" "github.com/nuts-foundation/nuts-node/vcr/verifier" "github.com/nuts-foundation/nuts-node/vdr" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" ) @@ -64,7 +63,7 @@ func TestWallet_BuildPresentation(t *testing.T) { t.Run("ok - one VC", func(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKey(testDID, nil, resolver.NutsSigningKeyType).Return(ssi.MustParseURI(kid), key.Public(), nil) w := New(keyResolver, keyStore, nil, jsonldManager, nil) @@ -84,7 +83,7 @@ func TestWallet_BuildPresentation(t *testing.T) { ProofPurpose: "authentication", }, } - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKey(testDID, nil, resolver.NutsSigningKeyType).Return(ssi.MustParseURI(kid), key.Public(), nil) @@ -103,7 +102,7 @@ func TestWallet_BuildPresentation(t *testing.T) { t.Run("ok - multiple VCs", func(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKey(testDID, nil, resolver.NutsSigningKeyType).Return(vdr.TestMethodDIDA.URI(), key.Public(), nil) @@ -121,7 +120,7 @@ func TestWallet_BuildPresentation(t *testing.T) { t.Run("ok", func(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) mockVerifier := verifier.NewMockVerifier(ctrl) mockVerifier.EXPECT().Validate(testCredential, &created) @@ -137,7 +136,7 @@ func TestWallet_BuildPresentation(t *testing.T) { t.Run("error", func(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) mockVerifier := verifier.NewMockVerifier(ctrl) mockVerifier.EXPECT().Validate(testCredential, &created).Return(errors.New("failed")) @@ -157,7 +156,7 @@ func TestWallet_BuildPresentation(t *testing.T) { t.Run("ok", func(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKey(testDID, nil, resolver.NutsSigningKeyType).Return(ssi.MustParseURI(kid), key.Public(), nil) @@ -174,7 +173,7 @@ func TestWallet_BuildPresentation(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) w := New(keyResolver, keyStore, nil, jsonldManager, nil) @@ -189,7 +188,7 @@ func TestWallet_BuildPresentation(t *testing.T) { ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) w := New(keyResolver, keyStore, nil, jsonldManager, nil) diff --git a/vcr/issuer/keyresolver_test.go b/vcr/issuer/keyresolver_test.go index 98b326b744..2353aff38c 100644 --- a/vcr/issuer/keyresolver_test.go +++ b/vcr/issuer/keyresolver_test.go @@ -25,7 +25,6 @@ import ( "github.com/nuts-foundation/go-did/did" "github.com/nuts-foundation/nuts-node/crypto" "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/mock/gomock" @@ -45,7 +44,7 @@ func Test_vdrKeyResolver_ResolveAssertionKey(t *testing.T) { t.Run("ok", func(t *testing.T) { ctrl := gomock.NewController(t) - mockPubKeyResolver := types.NewMockKeyResolver(ctrl) + mockPubKeyResolver := resolver.NewMockKeyResolver(ctrl) mockPubKeyResolver.EXPECT().ResolveKey(*issuerDID, nil, resolver.NutsSigningKeyType).Return(methodID.URI(), publicKey, nil) mockPrivKeyResolver := crypto.NewMockKeyResolver(ctrl) mockPrivKeyResolver.EXPECT().Resolve(ctx, methodID.String()).Return(crypto.NewTestKey(methodID.String()), nil) @@ -64,7 +63,7 @@ func Test_vdrKeyResolver_ResolveAssertionKey(t *testing.T) { t.Run("document for issuer not found in vdr", func(t *testing.T) { ctrl := gomock.NewController(t) - mockPubKeyResolver := types.NewMockKeyResolver(ctrl) + mockPubKeyResolver := resolver.NewMockKeyResolver(ctrl) mockPubKeyResolver.EXPECT().ResolveKey(*issuerDID, nil, resolver.NutsSigningKeyType).Return(ssi.URI{}, nil, errors.New("not found")) mockPrivKeyResolver := crypto.NewMockKeyResolver(ctrl) @@ -81,7 +80,7 @@ func Test_vdrKeyResolver_ResolveAssertionKey(t *testing.T) { t.Run("key not found in crypto", func(t *testing.T) { ctrl := gomock.NewController(t) - mockPubKeyResolver := types.NewMockKeyResolver(ctrl) + mockPubKeyResolver := resolver.NewMockKeyResolver(ctrl) mockPubKeyResolver.EXPECT().ResolveKey(*issuerDID, nil, resolver.NutsSigningKeyType).Return(methodID.URI(), publicKey, nil) mockPrivKeyResolver := crypto.NewMockKeyResolver(ctrl) mockPrivKeyResolver.EXPECT().Resolve(ctx, methodID.String()).Return(nil, errors.New("not found")) diff --git a/vcr/issuer/network_publisher_test.go b/vcr/issuer/network_publisher_test.go index 6ba56bec02..e0199471c6 100644 --- a/vcr/issuer/network_publisher_test.go +++ b/vcr/issuer/network_publisher_test.go @@ -32,7 +32,6 @@ import ( types "github.com/nuts-foundation/nuts-node/vcr/types" "github.com/nuts-foundation/nuts-node/vdr" "github.com/nuts-foundation/nuts-node/vdr/resolver" - vdrTypes "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" @@ -49,7 +48,7 @@ func Test_networkPublisher_resolveNutsCommServiceOwner(t *testing.T) { ctrl := gomock.NewController(t) sut := networkPublisher{} - mockServiceResolver := vdrTypes.NewMockServiceResolver(ctrl) + mockServiceResolver := resolver.NewMockServiceResolver(ctrl) sut.serviceResolver = mockServiceResolver mockServiceResolver.EXPECT().Resolve(expectedURIA, 5).Return(service, nil) @@ -64,7 +63,7 @@ func Test_networkPublisher_resolveNutsCommServiceOwner(t *testing.T) { ctrl := gomock.NewController(t) sut := networkPublisher{} - mockServiceResolver := vdrTypes.NewMockServiceResolver(ctrl) + mockServiceResolver := resolver.NewMockServiceResolver(ctrl) sut.serviceResolver = mockServiceResolver service := did.Service{ID: serviceID, ServiceEndpoint: "https://foo"} @@ -80,7 +79,7 @@ func Test_networkPublisher_resolveNutsCommServiceOwner(t *testing.T) { ctrl := gomock.NewController(t) sut := networkPublisher{} - mockServiceResolver := vdrTypes.NewMockServiceResolver(ctrl) + mockServiceResolver := resolver.NewMockServiceResolver(ctrl) sut.serviceResolver = mockServiceResolver mockServiceResolver.EXPECT().Resolve(expectedURIA, 5).Return(did.Service{}, errors.New("b00m!")) @@ -101,7 +100,7 @@ func Test_networkPublisher_PublishCredential(t *testing.T) { ctrl := gomock.NewController(t) mockKeyResolver := NewMockkeyResolver(ctrl) - mockDidResolver := vdrTypes.NewMockDIDResolver(ctrl) + mockDidResolver := resolver.NewMockDIDResolver(ctrl) mockNetwork := network.NewMockTransactions(ctrl) sut := networkPublisher{keyResolver: mockKeyResolver, didResolver: mockDidResolver, networkTx: mockNetwork} @@ -135,9 +134,9 @@ func Test_networkPublisher_PublishCredential(t *testing.T) { ctrl := gomock.NewController(t) mockKeyResolver := NewMockkeyResolver(ctrl) - mockDidResolver := vdrTypes.NewMockDIDResolver(ctrl) + mockDidResolver := resolver.NewMockDIDResolver(ctrl) mockNetwork := network.NewMockTransactions(ctrl) - mockServiceResolver := vdrTypes.NewMockServiceResolver(ctrl) + mockServiceResolver := resolver.NewMockServiceResolver(ctrl) sut := networkPublisher{ keyResolver: mockKeyResolver, @@ -216,7 +215,7 @@ func Test_networkPublisher_PublishCredential(t *testing.T) { t.Run("missing NutsCommEndpoint", func(t *testing.T) { ctrl := gomock.NewController(t) - mockServiceResolver := vdrTypes.NewMockServiceResolver(ctrl) + mockServiceResolver := resolver.NewMockServiceResolver(ctrl) sut := networkPublisher{ serviceResolver: mockServiceResolver, @@ -254,7 +253,7 @@ func Test_networkPublisher_PublishCredential(t *testing.T) { ctrl := gomock.NewController(t) mockKeyResolver := NewMockkeyResolver(ctrl) - mockDidResolver := vdrTypes.NewMockDIDResolver(ctrl) + mockDidResolver := resolver.NewMockDIDResolver(ctrl) mockNetwork := network.NewMockTransactions(ctrl) sut := networkPublisher{keyResolver: mockKeyResolver, didResolver: mockDidResolver, networkTx: mockNetwork} @@ -303,7 +302,7 @@ func Test_networkPublisher_PublishRevocation(t *testing.T) { ctrl := gomock.NewController(t) mockKeyResolver := NewMockkeyResolver(ctrl) - mockDidResolver := vdrTypes.NewMockDIDResolver(ctrl) + mockDidResolver := resolver.NewMockDIDResolver(ctrl) mockNetwork := network.NewMockTransactions(ctrl) mockKeyResolver.EXPECT().ResolveAssertionKey(ctx, *issuerDID).Return(testKey, nil) @@ -345,7 +344,7 @@ func Test_networkPublisher_PublishRevocation(t *testing.T) { ctrl := gomock.NewController(t) mockKeyResolver := NewMockkeyResolver(ctrl) - mockDidResolver := vdrTypes.NewMockDIDResolver(ctrl) + mockDidResolver := resolver.NewMockDIDResolver(ctrl) mockNetwork := network.NewMockTransactions(ctrl) mockKeyResolver.EXPECT().ResolveAssertionKey(ctx, *issuerDID).Return(nil, errors.New("not found")) @@ -365,7 +364,7 @@ func Test_networkPublisher_PublishRevocation(t *testing.T) { ctrl := gomock.NewController(t) mockKeyResolver := NewMockkeyResolver(ctrl) - mockDidResolver := vdrTypes.NewMockDIDResolver(ctrl) + mockDidResolver := resolver.NewMockDIDResolver(ctrl) mockNetwork := network.NewMockTransactions(ctrl) mockKeyResolver.EXPECT().ResolveAssertionKey(ctx, *issuerDID).Return(testKey, nil) @@ -385,7 +384,7 @@ func Test_networkPublisher_PublishRevocation(t *testing.T) { ctrl := gomock.NewController(t) mockKeyResolver := NewMockkeyResolver(ctrl) - mockDidResolver := vdrTypes.NewMockDIDResolver(ctrl) + mockDidResolver := resolver.NewMockDIDResolver(ctrl) mockNetwork := network.NewMockTransactions(ctrl) mockKeyResolver.EXPECT().ResolveAssertionKey(ctx, *issuerDID).Return(testKey, nil) diff --git a/vcr/issuer/openid_test.go b/vcr/issuer/openid_test.go index cca2834cb3..c19199c7e5 100644 --- a/vcr/issuer/openid_test.go +++ b/vcr/issuer/openid_test.go @@ -30,7 +30,6 @@ import ( "github.com/nuts-foundation/nuts-node/crypto" "github.com/nuts-foundation/nuts-node/vcr/openid4vci" "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/mock/gomock" @@ -123,7 +122,7 @@ func Test_memoryIssuer_HandleCredentialRequest(t *testing.T) { return keyID, nil }) ctrl := gomock.NewController(t) - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKeyByID(keyID, nil, resolver.NutsSigningKeyType).AnyTimes().Return(signerKey.Public(), nil) createHeaders := func() map[string]interface{} { @@ -265,7 +264,7 @@ func Test_memoryIssuer_HandleCredentialRequest(t *testing.T) { assert.Nil(t, response) }) t.Run("signing key is unknown", func(t *testing.T) { - keyResolver := types.NewMockKeyResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) keyResolver.EXPECT().ResolveKeyByID(keyID, nil, resolver.NutsSigningKeyType).AnyTimes().Return(nil, resolver.ErrKeyNotFound) service := requireNewTestHandler(t, keyResolver) _, err := service.createOffer(ctx, issuedVC, preAuthCode) diff --git a/vcr/openid4vci/identifiers_test.go b/vcr/openid4vci/identifiers_test.go index 6629db5893..cd94cec5f1 100644 --- a/vcr/openid4vci/identifiers_test.go +++ b/vcr/openid4vci/identifiers_test.go @@ -26,7 +26,6 @@ import ( "github.com/nuts-foundation/nuts-node/jsonld" "github.com/nuts-foundation/nuts-node/test/pki" resolver2 "github.com/nuts-foundation/nuts-node/vdr/resolver" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" @@ -55,7 +54,7 @@ var holderService = did.Service{ func TestDIDIdentifierResolver_Resolve(t *testing.T) { t.Run("found", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver2.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(issuerQuery, resolver2.DefaultMaxServiceReferenceDepth).Return(issuerService, nil) resolver := DIDIdentifierResolver{ServiceResolver: serviceResolver} @@ -66,7 +65,7 @@ func TestDIDIdentifierResolver_Resolve(t *testing.T) { }) t.Run("DID not found", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver2.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(issuerQuery, resolver2.DefaultMaxServiceReferenceDepth).Return(did.Service{}, resolver2.ErrNotFound) resolver := DIDIdentifierResolver{ServiceResolver: serviceResolver} @@ -77,7 +76,7 @@ func TestDIDIdentifierResolver_Resolve(t *testing.T) { }) t.Run("service not found", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver2.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(issuerQuery, resolver2.DefaultMaxServiceReferenceDepth).Return(did.Service{}, resolver2.ErrServiceNotFound) resolver := DIDIdentifierResolver{ServiceResolver: serviceResolver} @@ -88,7 +87,7 @@ func TestDIDIdentifierResolver_Resolve(t *testing.T) { }) t.Run("invalid service", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver2.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(issuerQuery, resolver2.DefaultMaxServiceReferenceDepth). Return(did.Service{ServiceEndpoint: map[string]string{"foo": "bar"}}, nil) resolver := DIDIdentifierResolver{ServiceResolver: serviceResolver} @@ -100,7 +99,7 @@ func TestDIDIdentifierResolver_Resolve(t *testing.T) { }) t.Run("other error", func(t *testing.T) { ctrl := gomock.NewController(t) - serviceResolver := types.NewMockServiceResolver(ctrl) + serviceResolver := resolver2.NewMockServiceResolver(ctrl) serviceResolver.EXPECT().Resolve(issuerQuery, resolver2.DefaultMaxServiceReferenceDepth).Return(did.Service{}, errors.New("b00m!")) resolver := DIDIdentifierResolver{ServiceResolver: serviceResolver} diff --git a/vcr/test.go b/vcr/test.go index 0a45b59377..2fd174d9ed 100644 --- a/vcr/test.go +++ b/vcr/test.go @@ -153,7 +153,7 @@ func NewTestVCRInstanceInDir(t *testing.T, testDirectory string) *vcr { type mockContext struct { ctrl *gomock.Controller vcr *vcr - didResolver *types.MockDIDResolver + didResolver *resolver.MockDIDResolver crypto *crypto.Crypto vdr *types.MockVDR } @@ -166,7 +166,7 @@ func newMockContext(t *testing.T) mockContext { tx.EXPECT().Subscribe("vcr_vcs", gomock.Any(), gomock.Any()) tx.EXPECT().Subscribe("vcr_revocations", gomock.Any(), gomock.Any()) tx.EXPECT().CleanupSubscriberEvents("vcr_vcs", gomock.Any()) - didResolver := types.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) vdrInstance := types.NewMockVDR(ctrl) vdrInstance.EXPECT().Resolver().Return(didResolver).AnyTimes() jsonldManager := jsonld.NewTestJSONLDManager(t) diff --git a/vcr/vcr_test.go b/vcr/vcr_test.go index bc84576510..1c6e1c2b16 100644 --- a/vcr/vcr_test.go +++ b/vcr/vcr_test.go @@ -357,7 +357,7 @@ func Test_vcr_GetOIDCWallet(t *testing.T) { func TestVcr_Untrusted(t *testing.T) { instance := NewTestVCRInstance(t) ctrl := gomock.NewController(t) - mockDidResolver := types.NewMockDIDResolver(ctrl) + mockDidResolver := resolver.NewMockDIDResolver(ctrl) vdrInstance := types.NewMockVDR(ctrl) vdrInstance.EXPECT().Resolver().Return(mockDidResolver).AnyTimes() instance.vdrInstance = vdrInstance diff --git a/vcr/verifier/verifier_test.go b/vcr/verifier/verifier_test.go index cebf4a66df..841d5ee383 100644 --- a/vcr/verifier/verifier_test.go +++ b/vcr/verifier/verifier_test.go @@ -41,7 +41,6 @@ import ( "github.com/nuts-foundation/nuts-node/vcr/trust" "github.com/nuts-foundation/nuts-node/vcr/types" "github.com/nuts-foundation/nuts-node/vdr" - vdrTypes "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" ) @@ -726,8 +725,8 @@ func TestVerificationError_Is(t *testing.T) { type mockContext struct { ctrl *gomock.Controller - didResolver *vdrTypes.MockDIDResolver - keyResolver *vdrTypes.MockKeyResolver + didResolver *resolver.MockDIDResolver + keyResolver *resolver.MockKeyResolver store *MockStore trustConfig *trust.Config verifier *verifier @@ -736,8 +735,8 @@ type mockContext struct { func newMockContext(t *testing.T) mockContext { t.Helper() ctrl := gomock.NewController(t) - didResolver := vdrTypes.NewMockDIDResolver(ctrl) - keyResolver := vdrTypes.NewMockKeyResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) + keyResolver := resolver.NewMockKeyResolver(ctrl) jsonldManager := jsonld.NewTestJSONLDManager(t) verifierStore := NewMockStore(ctrl) trustConfig := trust.NewConfig(path.Join(io.TestDirectory(t), "trust.yaml")) diff --git a/vdr/api/v1/api_test.go b/vdr/api/v1/api_test.go index 05db32c618..a7d7333f5f 100644 --- a/vdr/api/v1/api_test.go +++ b/vdr/api/v1/api_test.go @@ -467,8 +467,8 @@ func Test_ErrorStatusCodes(t *testing.T) { type mockContext struct { ctrl *gomock.Controller vdr *types.MockVDR - didResolver *types.MockDIDResolver - docUpdater *types.MockDocManipulator + didResolver *resolver.MockDIDResolver + docUpdater *management.MockDocManipulator client *Wrapper requestCtx context.Context } @@ -476,10 +476,10 @@ type mockContext struct { func newMockContext(t *testing.T) mockContext { t.Helper() ctrl := gomock.NewController(t) - didResolver := types.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) vdr := types.NewMockVDR(ctrl) vdr.EXPECT().Resolver().Return(didResolver).AnyTimes() - docManipulator := types.NewMockDocManipulator(ctrl) + docManipulator := management.NewMockDocManipulator(ctrl) client := &Wrapper{VDR: vdr, DocManipulator: docManipulator} requestCtx := audit.TestContext() diff --git a/vdr/did_owner_test.go b/vdr/did_owner_test.go index b7ca734424..ed78c40848 100644 --- a/vdr/did_owner_test.go +++ b/vdr/did_owner_test.go @@ -35,7 +35,7 @@ func Test_cachingDocumentOwner_IsOwner(t *testing.T) { id := did.MustParseDID("did:nuts:example.com") t.Run("owned, cached", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := resolver.NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(id, gomock.Any()).Return(nil, nil, nil) underlying := types.NewMockDocumentOwner(ctrl) underlying.EXPECT().IsOwner(gomock.Any(), gomock.Any()).Return(true, nil) @@ -51,7 +51,7 @@ func Test_cachingDocumentOwner_IsOwner(t *testing.T) { }) t.Run("not owned, cached", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := resolver.NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(id, gomock.Any()).Return(nil, nil, nil) underlying := types.NewMockDocumentOwner(ctrl) underlying.EXPECT().IsOwner(gomock.Any(), gomock.Any()).Return(false, nil) @@ -68,10 +68,10 @@ func Test_cachingDocumentOwner_IsOwner(t *testing.T) { t.Run("DID does not exist", func(t *testing.T) { ctrl := gomock.NewController(t) underlying := types.NewMockDocumentOwner(ctrl) - resolver := types.NewMockDIDResolver(ctrl) - resolver.EXPECT().Resolve(id, gomock.Any()).Return(nil, nil, resolver.ErrNotFound) + didResolver := resolver.NewMockDIDResolver(ctrl) + didResolver.EXPECT().Resolve(id, gomock.Any()).Return(nil, nil, resolver.ErrNotFound) - documentOwner := newCachingDocumentOwner(underlying, resolver) + documentOwner := newCachingDocumentOwner(underlying, didResolver) result, err := documentOwner.IsOwner(context.Background(), id) @@ -82,10 +82,10 @@ func Test_cachingDocumentOwner_IsOwner(t *testing.T) { t.Run("DID is deactivated", func(t *testing.T) { ctrl := gomock.NewController(t) underlying := types.NewMockDocumentOwner(ctrl) - resolver := types.NewMockDIDResolver(ctrl) - resolver.EXPECT().Resolve(id, gomock.Any()).Return(nil, nil, resolver.ErrDeactivated) + didResolver := resolver.NewMockDIDResolver(ctrl) + didResolver.EXPECT().Resolve(id, gomock.Any()).Return(nil, nil, resolver.ErrDeactivated) - documentOwner := newCachingDocumentOwner(underlying, resolver) + documentOwner := newCachingDocumentOwner(underlying, didResolver) result, err := documentOwner.IsOwner(context.Background(), id) @@ -95,7 +95,7 @@ func Test_cachingDocumentOwner_IsOwner(t *testing.T) { t.Run("error - DID resolve fails", func(t *testing.T) { ctrl := gomock.NewController(t) underlying := types.NewMockDocumentOwner(ctrl) - resolver := types.NewMockDIDResolver(ctrl) + resolver := resolver.NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(id, gomock.Any()).Return(nil, nil, errors.New("b00m")) documentOwner := newCachingDocumentOwner(underlying, resolver) diff --git a/vdr/didnuts/ambassador_test.go b/vdr/didnuts/ambassador_test.go index 88dd833779..02aff6b86e 100644 --- a/vdr/didnuts/ambassador_test.go +++ b/vdr/didnuts/ambassador_test.go @@ -43,7 +43,6 @@ import ( "github.com/nuts-foundation/nuts-node/events" "github.com/nuts-foundation/nuts-node/network/dag" "github.com/nuts-foundation/nuts-node/vdr/didnuts/didstore" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" @@ -625,7 +624,7 @@ func Test_handleUpdateDIDDocument(t *testing.T) { ctrl := gomock.NewController(t) didStoreMock := didstore.NewMockStore(ctrl) - keyStoreMock := types.NewMockNutsKeyResolver(ctrl) + keyStoreMock := resolver.NewMockNutsKeyResolver(ctrl) didResolver := &Resolver{Store: didStoreMock} am := ambassador{ @@ -828,8 +827,8 @@ func newDidDoc() (did.Document, jwk.Key, error) { type mockContext struct { ctrl *gomock.Controller didStore *didstore.MockStore - keyResolver *types.MockNutsKeyResolver - didResolver *types.MockDIDResolver + keyResolver *resolver.MockNutsKeyResolver + didResolver *resolver.MockDIDResolver eventManager *events.MockEvent network *network.MockTransactions ambassador ambassador @@ -838,8 +837,8 @@ type mockContext struct { func newMockContext(t *testing.T) mockContext { ctrl := gomock.NewController(t) storeMock := didstore.NewMockStore(ctrl) - keyResolverMock := types.NewMockNutsKeyResolver(ctrl) - resolverMock := types.NewMockDIDResolver(ctrl) + keyResolverMock := resolver.NewMockNutsKeyResolver(ctrl) + resolverMock := resolver.NewMockDIDResolver(ctrl) eventManager := events.NewMockEvent(ctrl) networkMock := network.NewMockTransactions(ctrl) am := ambassador{ diff --git a/vdr/didnuts/manipulator_test.go b/vdr/didnuts/manipulator_test.go index 0e0a7dd5cb..362561894d 100644 --- a/vdr/didnuts/manipulator_test.go +++ b/vdr/didnuts/manipulator_test.go @@ -28,7 +28,6 @@ import ( ssi "github.com/nuts-foundation/go-did" "github.com/nuts-foundation/go-did/did" "github.com/nuts-foundation/nuts-node/crypto" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" @@ -37,8 +36,8 @@ import ( // manipulatorTestContext contains the controller and mocks needed for testing the Manipulator type manipulatorTestContext struct { ctrl *gomock.Controller - mockUpdater *types.MockDocUpdater - mockResolver *types.MockDIDResolver + mockUpdater *management.MockDocUpdater + mockResolver *resolver.MockDIDResolver mockKeyCreator *mockKeyCreator manipulator *Manipulator audit context.Context @@ -47,8 +46,8 @@ type manipulatorTestContext struct { func newManipulatorTestContext(t *testing.T) manipulatorTestContext { t.Helper() ctrl := gomock.NewController(t) - updater := types.NewMockDocUpdater(ctrl) - resolver := types.NewMockDIDResolver(ctrl) + updater := management.NewMockDocUpdater(ctrl) + resolver := resolver.NewMockDIDResolver(ctrl) keyCreator := &mockKeyCreator{} return manipulatorTestContext{ ctrl: ctrl, diff --git a/vdr/didnuts/resolver_test.go b/vdr/didnuts/resolver_test.go index 45d98d8202..92bc9206c3 100644 --- a/vdr/didnuts/resolver_test.go +++ b/vdr/didnuts/resolver_test.go @@ -23,7 +23,6 @@ import ( "github.com/nuts-foundation/go-did/did" "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/mock/gomock" @@ -133,7 +132,7 @@ func TestResolveControllers(t *testing.T) { id456Method1, _ := did.ParseDIDURL("did:nuts:456#method-1") t.Run("emtpy input", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := resolver.NewMockDIDResolver(ctrl) docs, err := ResolveControllers(resolver, did.Document{}, nil) assert.NoError(t, err) assert.Len(t, docs, 0, @@ -142,7 +141,7 @@ func TestResolveControllers(t *testing.T) { t.Run("doc is its own controller", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := resolver.NewMockDIDResolver(ctrl) doc := did.Document{ID: *id123} doc.AddCapabilityInvocation(&did.VerificationMethod{ID: *id123Method1}) docs, err := ResolveControllers(resolver, doc, nil) @@ -154,7 +153,7 @@ func TestResolveControllers(t *testing.T) { t.Run("doc is deactivated", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := resolver.NewMockDIDResolver(ctrl) doc := did.Document{ID: *id123} docs, err := ResolveControllers(resolver, doc, nil) assert.NoError(t, err) @@ -164,7 +163,7 @@ func TestResolveControllers(t *testing.T) { t.Run("docA is controller of docB", func(t *testing.T) { ctrl := gomock.NewController(t) - nutsResolver := types.NewMockDIDResolver(ctrl) + nutsResolver := resolver.NewMockDIDResolver(ctrl) docA := did.Document{ID: *id123} docA.AddCapabilityInvocation(&did.VerificationMethod{ID: *id123Method1}) @@ -184,7 +183,7 @@ func TestResolveControllers(t *testing.T) { t.Run("docA is controller of docB and docA is deactivated", func(t *testing.T) { ctrl := gomock.NewController(t) - nutsResolver := types.NewMockDIDResolver(ctrl) + nutsResolver := resolver.NewMockDIDResolver(ctrl) docA := did.Document{ID: *id123} resolveTime := time.Date(2010, 1, 1, 1, 1, 1, 0, time.UTC) @@ -200,7 +199,7 @@ func TestResolveControllers(t *testing.T) { t.Run("docA and docB are both the controllers of docB", func(t *testing.T) { ctrl := gomock.NewController(t) - nutsResolver := types.NewMockDIDResolver(ctrl) + nutsResolver := resolver.NewMockDIDResolver(ctrl) docA := did.Document{ID: *id123} docA.AddCapabilityInvocation(&did.VerificationMethod{ID: *id123Method1}) @@ -218,7 +217,7 @@ func TestResolveControllers(t *testing.T) { t.Run("docA and docB are both the controllers of docB, resolve by source transaction", func(t *testing.T) { ctrl := gomock.NewController(t) - nutsResolver := types.NewMockDIDResolver(ctrl) + nutsResolver := resolver.NewMockDIDResolver(ctrl) docA := did.Document{ID: *id123} docA.AddCapabilityInvocation(&did.VerificationMethod{ID: *id123Method1}) @@ -237,7 +236,7 @@ func TestResolveControllers(t *testing.T) { t.Run("docA, docB and docC are controllers of docA, docB is deactivated", func(t *testing.T) { ctrl := gomock.NewController(t) - nutsResolver := types.NewMockDIDResolver(ctrl) + nutsResolver := resolver.NewMockDIDResolver(ctrl) // Doc B is deactivated docBID, _ := did.ParseDID("did:nuts:B") docB := did.Document{ID: *docBID} @@ -268,7 +267,7 @@ func TestResolveControllers(t *testing.T) { t.Run("docA is controller of docB, docA has explicit self link in Controllers", func(t *testing.T) { ctrl := gomock.NewController(t) - nutsResolver := types.NewMockDIDResolver(ctrl) + nutsResolver := resolver.NewMockDIDResolver(ctrl) docA := did.Document{ID: *id123, Controller: []did.DID{*id123}} docA.AddCapabilityInvocation(&did.VerificationMethod{ID: *id123Method1}) @@ -285,7 +284,7 @@ func TestResolveControllers(t *testing.T) { t.Run("ok - Resolve can not find the document", func(t *testing.T) { ctrl := gomock.NewController(t) - nutsResolver := types.NewMockDIDResolver(ctrl) + nutsResolver := resolver.NewMockDIDResolver(ctrl) nutsResolver.EXPECT().Resolve(*id123, gomock.Any()).Return(nil, nil, resolver.ErrNotFound) docB := did.Document{ID: *id456, Controller: []did.DID{*id123}} diff --git a/vdr/didnuts/validators_test.go b/vdr/didnuts/validators_test.go index 89c9c8d474..867527d34a 100644 --- a/vdr/didnuts/validators_test.go +++ b/vdr/didnuts/validators_test.go @@ -24,7 +24,6 @@ import ( "crypto/rand" "errors" "github.com/nuts-foundation/nuts-node/vdr/resolver" - "github.com/nuts-foundation/nuts-node/vdr/types" "testing" ssi "github.com/nuts-foundation/go-did" @@ -117,7 +116,7 @@ func Test_managedServiceValidator(t *testing.T) { referencedDocument.Service = append(referencedDocument.Service, service) ctrl := gomock.NewController(t) - didResolver := types.NewMockDIDResolver(ctrl) + didResolver := resolver.NewMockDIDResolver(ctrl) serviceResolver := resolver.DIDServiceResolver{Resolver: didResolver} t.Run("basic", func(t *testing.T) { diff --git a/vdr/management/finder_mock.go b/vdr/management/finder_mock.go new file mode 100644 index 0000000000..288aabe591 --- /dev/null +++ b/vdr/management/finder_mock.go @@ -0,0 +1,92 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: vdr/management/finder.go + +// Package management is a generated GoMock package. +package management + +import ( + reflect "reflect" + + did "github.com/nuts-foundation/go-did/did" + resolver "github.com/nuts-foundation/nuts-node/vdr/resolver" + gomock "go.uber.org/mock/gomock" +) + +// MockDocFinder is a mock of DocFinder interface. +type MockDocFinder struct { + ctrl *gomock.Controller + recorder *MockDocFinderMockRecorder +} + +// MockDocFinderMockRecorder is the mock recorder for MockDocFinder. +type MockDocFinderMockRecorder struct { + mock *MockDocFinder +} + +// NewMockDocFinder creates a new mock instance. +func NewMockDocFinder(ctrl *gomock.Controller) *MockDocFinder { + mock := &MockDocFinder{ctrl: ctrl} + mock.recorder = &MockDocFinderMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDocFinder) EXPECT() *MockDocFinderMockRecorder { + return m.recorder +} + +// Find mocks base method. +func (m *MockDocFinder) Find(arg0 ...Predicate) ([]did.Document, error) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range arg0 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Find", varargs...) + ret0, _ := ret[0].([]did.Document) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Find indicates an expected call of Find. +func (mr *MockDocFinderMockRecorder) Find(arg0 ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockDocFinder)(nil).Find), arg0...) +} + +// MockPredicate is a mock of Predicate interface. +type MockPredicate struct { + ctrl *gomock.Controller + recorder *MockPredicateMockRecorder +} + +// MockPredicateMockRecorder is the mock recorder for MockPredicate. +type MockPredicateMockRecorder struct { + mock *MockPredicate +} + +// NewMockPredicate creates a new mock instance. +func NewMockPredicate(ctrl *gomock.Controller) *MockPredicate { + mock := &MockPredicate{ctrl: ctrl} + mock.recorder = &MockPredicateMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPredicate) EXPECT() *MockPredicateMockRecorder { + return m.recorder +} + +// Match mocks base method. +func (m *MockPredicate) Match(arg0 did.Document, arg1 resolver.DocumentMetadata) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Match", arg0, arg1) + ret0, _ := ret[0].(bool) + return ret0 +} + +// Match indicates an expected call of Match. +func (mr *MockPredicateMockRecorder) Match(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Match", reflect.TypeOf((*MockPredicate)(nil).Match), arg0, arg1) +} diff --git a/vdr/management/management_mock.go b/vdr/management/management_mock.go new file mode 100644 index 0000000000..f56bb9b57a --- /dev/null +++ b/vdr/management/management_mock.go @@ -0,0 +1,247 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: vdr/management/management.go + +// Package management is a generated GoMock package. +package management + +import ( + context "context" + reflect "reflect" + + did "github.com/nuts-foundation/go-did/did" + crypto "github.com/nuts-foundation/nuts-node/crypto" + resolver "github.com/nuts-foundation/nuts-node/vdr/resolver" + gomock "go.uber.org/mock/gomock" +) + +// MockDocCreator is a mock of DocCreator interface. +type MockDocCreator struct { + ctrl *gomock.Controller + recorder *MockDocCreatorMockRecorder +} + +// MockDocCreatorMockRecorder is the mock recorder for MockDocCreator. +type MockDocCreatorMockRecorder struct { + mock *MockDocCreator +} + +// NewMockDocCreator creates a new mock instance. +func NewMockDocCreator(ctrl *gomock.Controller) *MockDocCreator { + mock := &MockDocCreator{ctrl: ctrl} + mock.recorder = &MockDocCreatorMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDocCreator) EXPECT() *MockDocCreatorMockRecorder { + return m.recorder +} + +// Create mocks base method. +func (m *MockDocCreator) Create(ctx context.Context, options DIDCreationOptions) (*did.Document, crypto.Key, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Create", ctx, options) + ret0, _ := ret[0].(*did.Document) + ret1, _ := ret[1].(crypto.Key) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// Create indicates an expected call of Create. +func (mr *MockDocCreatorMockRecorder) Create(ctx, options interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockDocCreator)(nil).Create), ctx, options) +} + +// MockDocWriter is a mock of DocWriter interface. +type MockDocWriter struct { + ctrl *gomock.Controller + recorder *MockDocWriterMockRecorder +} + +// MockDocWriterMockRecorder is the mock recorder for MockDocWriter. +type MockDocWriterMockRecorder struct { + mock *MockDocWriter +} + +// NewMockDocWriter creates a new mock instance. +func NewMockDocWriter(ctrl *gomock.Controller) *MockDocWriter { + mock := &MockDocWriter{ctrl: ctrl} + mock.recorder = &MockDocWriterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDocWriter) EXPECT() *MockDocWriterMockRecorder { + return m.recorder +} + +// Write mocks base method. +func (m *MockDocWriter) Write(document did.Document, metadata resolver.DocumentMetadata) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Write", document, metadata) + ret0, _ := ret[0].(error) + return ret0 +} + +// Write indicates an expected call of Write. +func (mr *MockDocWriterMockRecorder) Write(document, metadata interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockDocWriter)(nil).Write), document, metadata) +} + +// MockDocUpdater is a mock of DocUpdater interface. +type MockDocUpdater struct { + ctrl *gomock.Controller + recorder *MockDocUpdaterMockRecorder +} + +// MockDocUpdaterMockRecorder is the mock recorder for MockDocUpdater. +type MockDocUpdaterMockRecorder struct { + mock *MockDocUpdater +} + +// NewMockDocUpdater creates a new mock instance. +func NewMockDocUpdater(ctrl *gomock.Controller) *MockDocUpdater { + mock := &MockDocUpdater{ctrl: ctrl} + mock.recorder = &MockDocUpdaterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDocUpdater) EXPECT() *MockDocUpdaterMockRecorder { + return m.recorder +} + +// Update mocks base method. +func (m *MockDocUpdater) Update(ctx context.Context, id did.DID, next did.Document) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Update", ctx, id, next) + ret0, _ := ret[0].(error) + return ret0 +} + +// Update indicates an expected call of Update. +func (mr *MockDocUpdaterMockRecorder) Update(ctx, id, next interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockDocUpdater)(nil).Update), ctx, id, next) +} + +// MockDocManipulator is a mock of DocManipulator interface. +type MockDocManipulator struct { + ctrl *gomock.Controller + recorder *MockDocManipulatorMockRecorder +} + +// MockDocManipulatorMockRecorder is the mock recorder for MockDocManipulator. +type MockDocManipulatorMockRecorder struct { + mock *MockDocManipulator +} + +// NewMockDocManipulator creates a new mock instance. +func NewMockDocManipulator(ctrl *gomock.Controller) *MockDocManipulator { + mock := &MockDocManipulator{ctrl: ctrl} + mock.recorder = &MockDocManipulatorMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDocManipulator) EXPECT() *MockDocManipulatorMockRecorder { + return m.recorder +} + +// AddVerificationMethod mocks base method. +func (m *MockDocManipulator) AddVerificationMethod(ctx context.Context, id did.DID, keyUsage DIDKeyFlags) (*did.VerificationMethod, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddVerificationMethod", ctx, id, keyUsage) + ret0, _ := ret[0].(*did.VerificationMethod) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AddVerificationMethod indicates an expected call of AddVerificationMethod. +func (mr *MockDocManipulatorMockRecorder) AddVerificationMethod(ctx, id, keyUsage interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddVerificationMethod", reflect.TypeOf((*MockDocManipulator)(nil).AddVerificationMethod), ctx, id, keyUsage) +} + +// Deactivate mocks base method. +func (m *MockDocManipulator) Deactivate(ctx context.Context, id did.DID) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Deactivate", ctx, id) + ret0, _ := ret[0].(error) + return ret0 +} + +// Deactivate indicates an expected call of Deactivate. +func (mr *MockDocManipulatorMockRecorder) Deactivate(ctx, id interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deactivate", reflect.TypeOf((*MockDocManipulator)(nil).Deactivate), ctx, id) +} + +// RemoveVerificationMethod mocks base method. +func (m *MockDocManipulator) RemoveVerificationMethod(ctx context.Context, id, keyID did.DID) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveVerificationMethod", ctx, id, keyID) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemoveVerificationMethod indicates an expected call of RemoveVerificationMethod. +func (mr *MockDocManipulatorMockRecorder) RemoveVerificationMethod(ctx, id, keyID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveVerificationMethod", reflect.TypeOf((*MockDocManipulator)(nil).RemoveVerificationMethod), ctx, id, keyID) +} + +// MockDocumentOwner is a mock of DocumentOwner interface. +type MockDocumentOwner struct { + ctrl *gomock.Controller + recorder *MockDocumentOwnerMockRecorder +} + +// MockDocumentOwnerMockRecorder is the mock recorder for MockDocumentOwner. +type MockDocumentOwnerMockRecorder struct { + mock *MockDocumentOwner +} + +// NewMockDocumentOwner creates a new mock instance. +func NewMockDocumentOwner(ctrl *gomock.Controller) *MockDocumentOwner { + mock := &MockDocumentOwner{ctrl: ctrl} + mock.recorder = &MockDocumentOwnerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDocumentOwner) EXPECT() *MockDocumentOwnerMockRecorder { + return m.recorder +} + +// IsOwner mocks base method. +func (m *MockDocumentOwner) IsOwner(arg0 context.Context, arg1 did.DID) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsOwner", arg0, arg1) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsOwner indicates an expected call of IsOwner. +func (mr *MockDocumentOwnerMockRecorder) IsOwner(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOwner", reflect.TypeOf((*MockDocumentOwner)(nil).IsOwner), arg0, arg1) +} + +// ListOwned mocks base method. +func (m *MockDocumentOwner) ListOwned(ctx context.Context) ([]did.DID, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListOwned", ctx) + ret0, _ := ret[0].([]did.DID) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListOwned indicates an expected call of ListOwned. +func (mr *MockDocumentOwnerMockRecorder) ListOwned(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListOwned", reflect.TypeOf((*MockDocumentOwner)(nil).ListOwned), ctx) +} diff --git a/vdr/resolver/did_mock.go b/vdr/resolver/did_mock.go new file mode 100644 index 0000000000..98bedee2e7 --- /dev/null +++ b/vdr/resolver/did_mock.go @@ -0,0 +1,51 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: vdr/resolver/did.go + +// Package resolver is a generated GoMock package. +package resolver + +import ( + reflect "reflect" + + did "github.com/nuts-foundation/go-did/did" + gomock "go.uber.org/mock/gomock" +) + +// MockDIDResolver is a mock of DIDResolver interface. +type MockDIDResolver struct { + ctrl *gomock.Controller + recorder *MockDIDResolverMockRecorder +} + +// MockDIDResolverMockRecorder is the mock recorder for MockDIDResolver. +type MockDIDResolverMockRecorder struct { + mock *MockDIDResolver +} + +// NewMockDIDResolver creates a new mock instance. +func NewMockDIDResolver(ctrl *gomock.Controller) *MockDIDResolver { + mock := &MockDIDResolver{ctrl: ctrl} + mock.recorder = &MockDIDResolverMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDIDResolver) EXPECT() *MockDIDResolverMockRecorder { + return m.recorder +} + +// Resolve mocks base method. +func (m *MockDIDResolver) Resolve(id did.DID, metadata *ResolveMetadata) (*did.Document, *DocumentMetadata, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Resolve", id, metadata) + ret0, _ := ret[0].(*did.Document) + ret1, _ := ret[1].(*DocumentMetadata) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// Resolve indicates an expected call of Resolve. +func (mr *MockDIDResolverMockRecorder) Resolve(id, metadata interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Resolve", reflect.TypeOf((*MockDIDResolver)(nil).Resolve), id, metadata) +} diff --git a/vdr/resolver/did_test.go b/vdr/resolver/did_test.go index 434692ac0e..98cabb7a4e 100644 --- a/vdr/resolver/did_test.go +++ b/vdr/resolver/did_test.go @@ -26,7 +26,6 @@ import ( "github.com/nuts-foundation/go-did" "github.com/nuts-foundation/go-did/did" "github.com/nuts-foundation/nuts-node/crypto/hash" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" "io" @@ -112,7 +111,7 @@ func TestDIDResolverRouter_Resolve(t *testing.T) { doc := newDidDoc() t.Run("ok, 1 resolver", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(doc.ID, gomock.Any()).Return(&doc, nil, nil) router := &DIDResolverRouter{} router.Register(doc.ID.Method, resolver) @@ -123,8 +122,8 @@ func TestDIDResolverRouter_Resolve(t *testing.T) { }) t.Run("ok, 2 resolvers", func(t *testing.T) { ctrl := gomock.NewController(t) - otherResolver := types.NewMockDIDResolver(ctrl) - resolver := types.NewMockDIDResolver(ctrl) + otherResolver := NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(doc.ID, gomock.Any()).Return(&doc, nil, nil) router := &DIDResolverRouter{} router.Register(doc.ID.Method, resolver) @@ -136,7 +135,7 @@ func TestDIDResolverRouter_Resolve(t *testing.T) { }) t.Run("error - resolver not found", func(t *testing.T) { ctrl := gomock.NewController(t) - otherResolver := types.NewMockDIDResolver(ctrl) + otherResolver := NewMockDIDResolver(ctrl) router := &DIDResolverRouter{} router.Register("other", otherResolver) diff --git a/vdr/resolver/key_mock.go b/vdr/resolver/key_mock.go new file mode 100644 index 0000000000..67592904b5 --- /dev/null +++ b/vdr/resolver/key_mock.go @@ -0,0 +1,108 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: vdr/resolver/key.go + +// Package resolver is a generated GoMock package. +package resolver + +import ( + crypto "crypto" + reflect "reflect" + time "time" + + ssi "github.com/nuts-foundation/go-did" + did "github.com/nuts-foundation/go-did/did" + hash "github.com/nuts-foundation/nuts-node/crypto/hash" + gomock "go.uber.org/mock/gomock" +) + +// MockKeyResolver is a mock of KeyResolver interface. +type MockKeyResolver struct { + ctrl *gomock.Controller + recorder *MockKeyResolverMockRecorder +} + +// MockKeyResolverMockRecorder is the mock recorder for MockKeyResolver. +type MockKeyResolverMockRecorder struct { + mock *MockKeyResolver +} + +// NewMockKeyResolver creates a new mock instance. +func NewMockKeyResolver(ctrl *gomock.Controller) *MockKeyResolver { + mock := &MockKeyResolver{ctrl: ctrl} + mock.recorder = &MockKeyResolverMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockKeyResolver) EXPECT() *MockKeyResolverMockRecorder { + return m.recorder +} + +// ResolveKey mocks base method. +func (m *MockKeyResolver) ResolveKey(id did.DID, validAt *time.Time, relationType RelationType) (ssi.URI, crypto.PublicKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ResolveKey", id, validAt, relationType) + ret0, _ := ret[0].(ssi.URI) + ret1, _ := ret[1].(crypto.PublicKey) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// ResolveKey indicates an expected call of ResolveKey. +func (mr *MockKeyResolverMockRecorder) ResolveKey(id, validAt, relationType interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolveKey", reflect.TypeOf((*MockKeyResolver)(nil).ResolveKey), id, validAt, relationType) +} + +// ResolveKeyByID mocks base method. +func (m *MockKeyResolver) ResolveKeyByID(keyID string, validAt *time.Time, relationType RelationType) (crypto.PublicKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ResolveKeyByID", keyID, validAt, relationType) + ret0, _ := ret[0].(crypto.PublicKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ResolveKeyByID indicates an expected call of ResolveKeyByID. +func (mr *MockKeyResolverMockRecorder) ResolveKeyByID(keyID, validAt, relationType interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolveKeyByID", reflect.TypeOf((*MockKeyResolver)(nil).ResolveKeyByID), keyID, validAt, relationType) +} + +// MockNutsKeyResolver is a mock of NutsKeyResolver interface. +type MockNutsKeyResolver struct { + ctrl *gomock.Controller + recorder *MockNutsKeyResolverMockRecorder +} + +// MockNutsKeyResolverMockRecorder is the mock recorder for MockNutsKeyResolver. +type MockNutsKeyResolverMockRecorder struct { + mock *MockNutsKeyResolver +} + +// NewMockNutsKeyResolver creates a new mock instance. +func NewMockNutsKeyResolver(ctrl *gomock.Controller) *MockNutsKeyResolver { + mock := &MockNutsKeyResolver{ctrl: ctrl} + mock.recorder = &MockNutsKeyResolverMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockNutsKeyResolver) EXPECT() *MockNutsKeyResolverMockRecorder { + return m.recorder +} + +// ResolvePublicKey mocks base method. +func (m *MockNutsKeyResolver) ResolvePublicKey(kid string, sourceTransactionsRefs []hash.SHA256Hash) (crypto.PublicKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ResolvePublicKey", kid, sourceTransactionsRefs) + ret0, _ := ret[0].(crypto.PublicKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ResolvePublicKey indicates an expected call of ResolvePublicKey. +func (mr *MockNutsKeyResolverMockRecorder) ResolvePublicKey(kid, sourceTransactionsRefs interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolvePublicKey", reflect.TypeOf((*MockNutsKeyResolver)(nil).ResolvePublicKey), kid, sourceTransactionsRefs) +} diff --git a/vdr/resolver/key_test.go b/vdr/resolver/key_test.go index cbc5fda37e..a103ae0fdc 100644 --- a/vdr/resolver/key_test.go +++ b/vdr/resolver/key_test.go @@ -20,7 +20,6 @@ package resolver import ( "github.com/nuts-foundation/go-did/did" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" @@ -29,7 +28,7 @@ import ( func TestKeyResolver_ResolveKey(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) keyResolver := DIDKeyResolver{Resolver: resolver} doc := newDidDoc() @@ -68,7 +67,7 @@ func TestKeyResolver_ResolveKey(t *testing.T) { func TestKeyResolver_ResolveKeyByID(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) keyResolver := DIDKeyResolver{Resolver: resolver} doc := newDidDoc() resolver.EXPECT().Resolve(doc.ID, gomock.Any()).AnyTimes().Return(&doc, nil, nil) diff --git a/vdr/resolver/service_mock.go b/vdr/resolver/service_mock.go new file mode 100644 index 0000000000..33b5ac6206 --- /dev/null +++ b/vdr/resolver/service_mock.go @@ -0,0 +1,66 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: vdr/resolver/service.go + +// Package resolver is a generated GoMock package. +package resolver + +import ( + reflect "reflect" + + ssi "github.com/nuts-foundation/go-did" + did "github.com/nuts-foundation/go-did/did" + gomock "go.uber.org/mock/gomock" +) + +// MockServiceResolver is a mock of ServiceResolver interface. +type MockServiceResolver struct { + ctrl *gomock.Controller + recorder *MockServiceResolverMockRecorder +} + +// MockServiceResolverMockRecorder is the mock recorder for MockServiceResolver. +type MockServiceResolverMockRecorder struct { + mock *MockServiceResolver +} + +// NewMockServiceResolver creates a new mock instance. +func NewMockServiceResolver(ctrl *gomock.Controller) *MockServiceResolver { + mock := &MockServiceResolver{ctrl: ctrl} + mock.recorder = &MockServiceResolverMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockServiceResolver) EXPECT() *MockServiceResolverMockRecorder { + return m.recorder +} + +// Resolve mocks base method. +func (m *MockServiceResolver) Resolve(query ssi.URI, maxDepth int) (did.Service, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Resolve", query, maxDepth) + ret0, _ := ret[0].(did.Service) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Resolve indicates an expected call of Resolve. +func (mr *MockServiceResolverMockRecorder) Resolve(query, maxDepth interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Resolve", reflect.TypeOf((*MockServiceResolver)(nil).Resolve), query, maxDepth) +} + +// ResolveEx mocks base method. +func (m *MockServiceResolver) ResolveEx(endpoint ssi.URI, depth, maxDepth int, documentCache map[string]*did.Document) (did.Service, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ResolveEx", endpoint, depth, maxDepth, documentCache) + ret0, _ := ret[0].(did.Service) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ResolveEx indicates an expected call of ResolveEx. +func (mr *MockServiceResolverMockRecorder) ResolveEx(endpoint, depth, maxDepth, documentCache interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolveEx", reflect.TypeOf((*MockServiceResolver)(nil).ResolveEx), endpoint, depth, maxDepth, documentCache) +} diff --git a/vdr/resolver/service_test.go b/vdr/resolver/service_test.go index ecc7191170..ebce4f4737 100644 --- a/vdr/resolver/service_test.go +++ b/vdr/resolver/service_test.go @@ -23,7 +23,6 @@ import ( ssi "github.com/nuts-foundation/go-did" "github.com/nuts-foundation/go-did/did" "github.com/nuts-foundation/nuts-node/crypto/hash" - "github.com/nuts-foundation/nuts-node/vdr/types" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" "testing" @@ -116,7 +115,7 @@ func TestServiceResolver_Resolve(t *testing.T) { t.Run("ok", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(*didB, nil).MinTimes(1).Return(&docB, meta, nil) @@ -127,7 +126,7 @@ func TestServiceResolver_Resolve(t *testing.T) { }) t.Run("ok - external", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(*didB, nil).MinTimes(1).Return(&docB, meta, nil) resolver.EXPECT().Resolve(*didA, nil).MinTimes(1).Return(&docA, meta, nil) @@ -139,7 +138,7 @@ func TestServiceResolver_Resolve(t *testing.T) { }) t.Run("error - cyclic reference (yields refs too deep)", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(*didB, nil).MinTimes(1).Return(&docB, meta, nil) @@ -150,7 +149,7 @@ func TestServiceResolver_Resolve(t *testing.T) { }) t.Run("error - invalid ref", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(*didB, nil).MinTimes(1).Return(&docB, meta, nil) @@ -161,7 +160,7 @@ func TestServiceResolver_Resolve(t *testing.T) { }) t.Run("error - service not found", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(*didB, nil).MinTimes(1).Return(&docB, meta, nil) @@ -172,7 +171,7 @@ func TestServiceResolver_Resolve(t *testing.T) { }) t.Run("error - DID not found", func(t *testing.T) { ctrl := gomock.NewController(t) - resolver := types.NewMockDIDResolver(ctrl) + resolver := NewMockDIDResolver(ctrl) resolver.EXPECT().Resolve(*didB, nil).MinTimes(1).Return(nil, nil, ErrNotFound) diff --git a/vdr/types/mock.go b/vdr/types/mock.go index 634af3286a..934ea3717a 100644 --- a/vdr/types/mock.go +++ b/vdr/types/mock.go @@ -10,343 +10,15 @@ package types import ( context "context" - crypto "crypto" + did "github.com/nuts-foundation/go-did/did" + crypto0 "github.com/nuts-foundation/nuts-node/crypto" "github.com/nuts-foundation/nuts-node/vdr/management" "github.com/nuts-foundation/nuts-node/vdr/resolver" + gomock "go.uber.org/mock/gomock" url "net/url" reflect "reflect" - time "time" - - ssi "github.com/nuts-foundation/go-did" - did "github.com/nuts-foundation/go-did/did" - crypto0 "github.com/nuts-foundation/nuts-node/crypto" - hash "github.com/nuts-foundation/nuts-node/crypto/hash" - gomock "go.uber.org/mock/gomock" ) -// MockDIDResolver is a mock of DIDResolver interface. -type MockDIDResolver struct { - ctrl *gomock.Controller - recorder *MockDIDResolverMockRecorder -} - -// MockDIDResolverMockRecorder is the mock recorder for MockDIDResolver. -type MockDIDResolverMockRecorder struct { - mock *MockDIDResolver -} - -// NewMockDIDResolver creates a new mock instance. -func NewMockDIDResolver(ctrl *gomock.Controller) *MockDIDResolver { - mock := &MockDIDResolver{ctrl: ctrl} - mock.recorder = &MockDIDResolverMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockDIDResolver) EXPECT() *MockDIDResolverMockRecorder { - return m.recorder -} - -// Resolve mocks base method. -func (m *MockDIDResolver) Resolve(id did.DID, metadata *resolver.ResolveMetadata) (*did.Document, *resolver.DocumentMetadata, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Resolve", id, metadata) - ret0, _ := ret[0].(*did.Document) - ret1, _ := ret[1].(*resolver.DocumentMetadata) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// Resolve indicates an expected call of Resolve. -func (mr *MockDIDResolverMockRecorder) Resolve(id, metadata any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Resolve", reflect.TypeOf((*MockDIDResolver)(nil).Resolve), id, metadata) -} - -// MockPredicate is a mock of Predicate interface. -type MockPredicate struct { - ctrl *gomock.Controller - recorder *MockPredicateMockRecorder -} - -// MockPredicateMockRecorder is the mock recorder for MockPredicate. -type MockPredicateMockRecorder struct { - mock *MockPredicate -} - -// NewMockPredicate creates a new mock instance. -func NewMockPredicate(ctrl *gomock.Controller) *MockPredicate { - mock := &MockPredicate{ctrl: ctrl} - mock.recorder = &MockPredicateMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockPredicate) EXPECT() *MockPredicateMockRecorder { - return m.recorder -} - -// Match mocks base method. -func (m *MockPredicate) Match(arg0 did.Document, arg1 resolver.DocumentMetadata) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Match", arg0, arg1) - ret0, _ := ret[0].(bool) - return ret0 -} - -// Match indicates an expected call of Match. -func (mr *MockPredicateMockRecorder) Match(arg0, arg1 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Match", reflect.TypeOf((*MockPredicate)(nil).Match), arg0, arg1) -} - -// MockDocFinder is a mock of DocFinder interface. -type MockDocFinder struct { - ctrl *gomock.Controller - recorder *MockDocFinderMockRecorder -} - -// MockDocFinderMockRecorder is the mock recorder for MockDocFinder. -type MockDocFinderMockRecorder struct { - mock *MockDocFinder -} - -// NewMockDocFinder creates a new mock instance. -func NewMockDocFinder(ctrl *gomock.Controller) *MockDocFinder { - mock := &MockDocFinder{ctrl: ctrl} - mock.recorder = &MockDocFinderMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockDocFinder) EXPECT() *MockDocFinderMockRecorder { - return m.recorder -} - -// Find mocks base method. -func (m *MockDocFinder) Find(arg0 ...management.Predicate) ([]did.Document, error) { - m.ctrl.T.Helper() - varargs := []any{} - for _, a := range arg0 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Find", varargs...) - ret0, _ := ret[0].([]did.Document) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Find indicates an expected call of Find. -func (mr *MockDocFinderMockRecorder) Find(arg0 ...any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockDocFinder)(nil).Find), arg0...) -} - -// MockDocCreator is a mock of DocCreator interface. -type MockDocCreator struct { - ctrl *gomock.Controller - recorder *MockDocCreatorMockRecorder -} - -// MockDocCreatorMockRecorder is the mock recorder for MockDocCreator. -type MockDocCreatorMockRecorder struct { - mock *MockDocCreator -} - -// NewMockDocCreator creates a new mock instance. -func NewMockDocCreator(ctrl *gomock.Controller) *MockDocCreator { - mock := &MockDocCreator{ctrl: ctrl} - mock.recorder = &MockDocCreatorMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockDocCreator) EXPECT() *MockDocCreatorMockRecorder { - return m.recorder -} - -// Create mocks base method. -func (m *MockDocCreator) Create(ctx context.Context, options management.DIDCreationOptions) (*did.Document, crypto0.Key, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", ctx, options) - ret0, _ := ret[0].(*did.Document) - ret1, _ := ret[1].(crypto0.Key) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// Create indicates an expected call of Create. -func (mr *MockDocCreatorMockRecorder) Create(ctx, options any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockDocCreator)(nil).Create), ctx, options) -} - -// MockDocWriter is a mock of DocWriter interface. -type MockDocWriter struct { - ctrl *gomock.Controller - recorder *MockDocWriterMockRecorder -} - -// MockDocWriterMockRecorder is the mock recorder for MockDocWriter. -type MockDocWriterMockRecorder struct { - mock *MockDocWriter -} - -// NewMockDocWriter creates a new mock instance. -func NewMockDocWriter(ctrl *gomock.Controller) *MockDocWriter { - mock := &MockDocWriter{ctrl: ctrl} - mock.recorder = &MockDocWriterMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockDocWriter) EXPECT() *MockDocWriterMockRecorder { - return m.recorder -} - -// Write mocks base method. -func (m *MockDocWriter) Write(document did.Document, metadata resolver.DocumentMetadata) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Write", document, metadata) - ret0, _ := ret[0].(error) - return ret0 -} - -// Write indicates an expected call of Write. -func (mr *MockDocWriterMockRecorder) Write(document, metadata any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockDocWriter)(nil).Write), document, metadata) -} - -// MockDocUpdater is a mock of DocUpdater interface. -type MockDocUpdater struct { - ctrl *gomock.Controller - recorder *MockDocUpdaterMockRecorder -} - -// MockDocUpdaterMockRecorder is the mock recorder for MockDocUpdater. -type MockDocUpdaterMockRecorder struct { - mock *MockDocUpdater -} - -// NewMockDocUpdater creates a new mock instance. -func NewMockDocUpdater(ctrl *gomock.Controller) *MockDocUpdater { - mock := &MockDocUpdater{ctrl: ctrl} - mock.recorder = &MockDocUpdaterMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockDocUpdater) EXPECT() *MockDocUpdaterMockRecorder { - return m.recorder -} - -// Update mocks base method. -func (m *MockDocUpdater) Update(ctx context.Context, id did.DID, next did.Document) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", ctx, id, next) - ret0, _ := ret[0].(error) - return ret0 -} - -// Update indicates an expected call of Update. -func (mr *MockDocUpdaterMockRecorder) Update(ctx, id, next any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockDocUpdater)(nil).Update), ctx, id, next) -} - -// MockKeyResolver is a mock of KeyResolver interface. -type MockKeyResolver struct { - ctrl *gomock.Controller - recorder *MockKeyResolverMockRecorder -} - -// MockKeyResolverMockRecorder is the mock recorder for MockKeyResolver. -type MockKeyResolverMockRecorder struct { - mock *MockKeyResolver -} - -// NewMockKeyResolver creates a new mock instance. -func NewMockKeyResolver(ctrl *gomock.Controller) *MockKeyResolver { - mock := &MockKeyResolver{ctrl: ctrl} - mock.recorder = &MockKeyResolverMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockKeyResolver) EXPECT() *MockKeyResolverMockRecorder { - return m.recorder -} - -// ResolveKey mocks base method. -func (m *MockKeyResolver) ResolveKey(id did.DID, validAt *time.Time, relationType resolver.RelationType) (ssi.URI, crypto.PublicKey, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ResolveKey", id, validAt, relationType) - ret0, _ := ret[0].(ssi.URI) - ret1, _ := ret[1].(crypto.PublicKey) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// ResolveKey indicates an expected call of ResolveKey. -func (mr *MockKeyResolverMockRecorder) ResolveKey(id, validAt, relationType any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolveKey", reflect.TypeOf((*MockKeyResolver)(nil).ResolveKey), id, validAt, relationType) -} - -// ResolveKeyByID mocks base method. -func (m *MockKeyResolver) ResolveKeyByID(keyID string, validAt *time.Time, relationType resolver.RelationType) (crypto.PublicKey, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ResolveKeyByID", keyID, validAt, relationType) - ret0, _ := ret[0].(crypto.PublicKey) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ResolveKeyByID indicates an expected call of ResolveKeyByID. -func (mr *MockKeyResolverMockRecorder) ResolveKeyByID(keyID, validAt, relationType any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolveKeyByID", reflect.TypeOf((*MockKeyResolver)(nil).ResolveKeyByID), keyID, validAt, relationType) -} - -// MockNutsKeyResolver is a mock of NutsKeyResolver interface. -type MockNutsKeyResolver struct { - ctrl *gomock.Controller - recorder *MockNutsKeyResolverMockRecorder -} - -// MockNutsKeyResolverMockRecorder is the mock recorder for MockNutsKeyResolver. -type MockNutsKeyResolverMockRecorder struct { - mock *MockNutsKeyResolver -} - -// NewMockNutsKeyResolver creates a new mock instance. -func NewMockNutsKeyResolver(ctrl *gomock.Controller) *MockNutsKeyResolver { - mock := &MockNutsKeyResolver{ctrl: ctrl} - mock.recorder = &MockNutsKeyResolverMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockNutsKeyResolver) EXPECT() *MockNutsKeyResolverMockRecorder { - return m.recorder -} - -// ResolvePublicKey mocks base method. -func (m *MockNutsKeyResolver) ResolvePublicKey(kid string, sourceTransactionsRefs []hash.SHA256Hash) (crypto.PublicKey, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ResolvePublicKey", kid, sourceTransactionsRefs) - ret0, _ := ret[0].(crypto.PublicKey) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ResolvePublicKey indicates an expected call of ResolvePublicKey. -func (mr *MockNutsKeyResolverMockRecorder) ResolvePublicKey(kid, sourceTransactionsRefs any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolvePublicKey", reflect.TypeOf((*MockNutsKeyResolver)(nil).ResolvePublicKey), kid, sourceTransactionsRefs) -} - // MockVDR is a mock of VDR interface. type MockVDR struct { ctrl *gomock.Controller @@ -528,121 +200,3 @@ func (mr *MockDocumentOwnerMockRecorder) ListOwned(ctx any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListOwned", reflect.TypeOf((*MockDocumentOwner)(nil).ListOwned), ctx) } -// MockDocManipulator is a mock of DocManipulator interface. -type MockDocManipulator struct { - ctrl *gomock.Controller - recorder *MockDocManipulatorMockRecorder -} - -// MockDocManipulatorMockRecorder is the mock recorder for MockDocManipulator. -type MockDocManipulatorMockRecorder struct { - mock *MockDocManipulator -} - -// NewMockDocManipulator creates a new mock instance. -func NewMockDocManipulator(ctrl *gomock.Controller) *MockDocManipulator { - mock := &MockDocManipulator{ctrl: ctrl} - mock.recorder = &MockDocManipulatorMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockDocManipulator) EXPECT() *MockDocManipulatorMockRecorder { - return m.recorder -} - -// AddVerificationMethod mocks base method. -func (m *MockDocManipulator) AddVerificationMethod(ctx context.Context, id did.DID, keyUsage management.DIDKeyFlags) (*did.VerificationMethod, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddVerificationMethod", ctx, id, keyUsage) - ret0, _ := ret[0].(*did.VerificationMethod) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// AddVerificationMethod indicates an expected call of AddVerificationMethod. -func (mr *MockDocManipulatorMockRecorder) AddVerificationMethod(ctx, id, keyUsage any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddVerificationMethod", reflect.TypeOf((*MockDocManipulator)(nil).AddVerificationMethod), ctx, id, keyUsage) -} - -// Deactivate mocks base method. -func (m *MockDocManipulator) Deactivate(ctx context.Context, id did.DID) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Deactivate", ctx, id) - ret0, _ := ret[0].(error) - return ret0 -} - -// Deactivate indicates an expected call of Deactivate. -func (mr *MockDocManipulatorMockRecorder) Deactivate(ctx, id any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deactivate", reflect.TypeOf((*MockDocManipulator)(nil).Deactivate), ctx, id) -} - -// RemoveVerificationMethod mocks base method. -func (m *MockDocManipulator) RemoveVerificationMethod(ctx context.Context, id, keyID did.DID) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RemoveVerificationMethod", ctx, id, keyID) - ret0, _ := ret[0].(error) - return ret0 -} - -// RemoveVerificationMethod indicates an expected call of RemoveVerificationMethod. -func (mr *MockDocManipulatorMockRecorder) RemoveVerificationMethod(ctx, id, keyID any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveVerificationMethod", reflect.TypeOf((*MockDocManipulator)(nil).RemoveVerificationMethod), ctx, id, keyID) -} - -// MockServiceResolver is a mock of ServiceResolver interface. -type MockServiceResolver struct { - ctrl *gomock.Controller - recorder *MockServiceResolverMockRecorder -} - -// MockServiceResolverMockRecorder is the mock recorder for MockServiceResolver. -type MockServiceResolverMockRecorder struct { - mock *MockServiceResolver -} - -// NewMockServiceResolver creates a new mock instance. -func NewMockServiceResolver(ctrl *gomock.Controller) *MockServiceResolver { - mock := &MockServiceResolver{ctrl: ctrl} - mock.recorder = &MockServiceResolverMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockServiceResolver) EXPECT() *MockServiceResolverMockRecorder { - return m.recorder -} - -// Resolve mocks base method. -func (m *MockServiceResolver) Resolve(query ssi.URI, maxDepth int) (did.Service, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Resolve", query, maxDepth) - ret0, _ := ret[0].(did.Service) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Resolve indicates an expected call of Resolve. -func (mr *MockServiceResolverMockRecorder) Resolve(query, maxDepth any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Resolve", reflect.TypeOf((*MockServiceResolver)(nil).Resolve), query, maxDepth) -} - -// ResolveEx mocks base method. -func (m *MockServiceResolver) ResolveEx(endpoint ssi.URI, depth, maxDepth int, documentCache map[string]*did.Document) (did.Service, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ResolveEx", endpoint, depth, maxDepth, documentCache) - ret0, _ := ret[0].(did.Service) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ResolveEx indicates an expected call of ResolveEx. -func (mr *MockServiceResolverMockRecorder) ResolveEx(endpoint, depth, maxDepth, documentCache any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResolveEx", reflect.TypeOf((*MockServiceResolver)(nil).ResolveEx), endpoint, depth, maxDepth, documentCache) -}