diff --git a/component/credentialstatus/credentialstatus_service_test.go b/component/credentialstatus/credentialstatus_service_test.go index 2903badf6..3aab112a7 100644 --- a/component/credentialstatus/credentialstatus_service_test.go +++ b/component/credentialstatus/credentialstatus_service_test.go @@ -56,7 +56,7 @@ const ( eventTopic = "testEventTopic" ) -func validateVCStatus( +func validateVCStatusList2021Entry( t *testing.T, s *Service, statusID *credentialstatus.StatusListEntry, expectedListID credentialstatus.ListID) { t.Helper() @@ -94,6 +94,43 @@ func validateVCStatus( require.False(t, bitSet) } +func validateBitstringStatusListEntry( + t *testing.T, s *Service, statusID *credentialstatus.StatusListEntry, expectedListID credentialstatus.ListID) { + t.Helper() + + require.Equal(t, string(vc.BitstringStatusList), statusID.TypedID.Type) + require.Equal(t, "revocation", statusID.TypedID.CustomFields[statustype.StatusPurpose].(string)) + + existingStatusListVCID, ok := statusID.TypedID.CustomFields[statustype.StatusListCredential].(string) + require.True(t, ok) + + chunks := strings.Split(existingStatusListVCID, "/") + existingStatusVCListID := chunks[len(chunks)-1] + require.Equal(t, string(expectedListID), existingStatusVCListID) + + statusListVC, err := s.GetStatusListVC(context.Background(), externalProfileID, existingStatusVCListID) + require.NoError(t, err) + + statusListVCC := statusListVC.Contents() + + require.Equal(t, existingStatusListVCID, statusListVCC.ID) + require.Equal(t, "did:test:abc", statusListVCC.Issuer.ID) + require.Equal(t, verifiable.V2ContextURI, statusListVCC.Context[0]) + credSubject := statusListVCC.Subject + require.Equal(t, existingStatusListVCID+"#list", credSubject[0].ID) + require.Equal(t, statustype.StatusListBitstringVCSubjectType, credSubject[0].CustomFields["type"].(string)) + require.Equal(t, "revocation", credSubject[0].CustomFields[statustype.StatusPurpose].(string)) + require.NotEmpty(t, credSubject[0].CustomFields["encodedList"].(string)) + bitString, err := bitstring.DecodeBits(credSubject[0].CustomFields["encodedList"].(string)) + require.NoError(t, err) + + revocationListIndex, err := strconv.Atoi(statusID.TypedID.CustomFields[statustype.StatusListIndex].(string)) + require.NoError(t, err) + bitSet, err := bitString.Get(revocationListIndex) + require.NoError(t, err) + require.False(t, bitSet) +} + func TestCredentialStatusList_CreateStatusListEntry(t *testing.T) { t.Run("test success", func(t *testing.T) { loader := testutil.DocumentLoader(t) @@ -140,11 +177,104 @@ func TestCredentialStatusList_CreateStatusListEntry(t *testing.T) { statusID, err := s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) require.NoError(t, err) - validateVCStatus(t, s, statusID, listID) + validateVCStatusList2021Entry(t, s, statusID, listID) + + statusID, err = s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) + require.NoError(t, err) + validateVCStatusList2021Entry(t, s, statusID, listID) + + // List size equals 2, so after 2 issuances CSL encodedBitString is full and listID must be updated. + updatedListID, err := cslIndexStore.GetLatestListID(ctx) + require.NoError(t, err) + require.NotEqual(t, updatedListID, listID) + + statusID, err = s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) + require.NoError(t, err) + validateVCStatusList2021Entry(t, s, statusID, updatedListID) + + statusID, err = s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) + require.NoError(t, err) + validateVCStatusList2021Entry(t, s, statusID, updatedListID) + + // List size equals 2, so after 4 issuances CSL encodedBitString is full and listID must be updated. + updatedListIDSecond, err := cslIndexStore.GetLatestListID(ctx) + require.NoError(t, err) + require.NotEqual(t, updatedListID, updatedListIDSecond) + require.NotEqual(t, listID, updatedListIDSecond) + + statusID, err = s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) + require.NoError(t, err) + validateVCStatusList2021Entry(t, s, statusID, updatedListIDSecond) + }) + + t.Run("test error get profile service", func(t *testing.T) { + mockProfileSrv := NewMockProfileService(gomock.NewController(t)) + mockProfileSrv.EXPECT().GetProfile(profileID, profileVersion).Times(1).Return(nil, errors.New("some error")) + + s, err := New(&Config{ + ProfileService: mockProfileSrv, + }) + require.NoError(t, err) + + status, err := s.CreateStatusListEntry(context.Background(), profileID, profileVersion, credID) + require.Error(t, err) + require.Nil(t, status) + require.Contains(t, err.Error(), "get profile") + }) +} + +func TestCredentialStatusList_CreateStatusListEntry_Bitstring(t *testing.T) { + t.Run("test success", func(t *testing.T) { + loader := testutil.DocumentLoader(t) + mockProfileSrv := NewMockProfileService(gomock.NewController(t)) + mockProfileSrv.EXPECT().GetProfile(profileID, profileVersion).AnyTimes(). + Return(getTestProfileEx(vc.BitstringStatusList, vcsverifiable.Ed25519Signature2018), nil) + mockKMSRegistry := NewMockKMSRegistry(gomock.NewController(t)) + mockKMSRegistry.EXPECT().GetKeyManager(gomock.Any()).Times(5).Return(&vcskms.MockKMS{}, nil) + ctx := context.Background() + + cslVCStore := newMockCSLVCStore() + + cslIndexStore := newMockCSLIndexStore() + + listID, err := cslIndexStore.GetLatestListID(ctx) + require.NoError(t, err) + + vcStatusStore := newMockVCStatusStore() + + cslMgr, err := cslmanager.New( + &cslmanager.Config{ + CSLVCStore: cslVCStore, + CSLIndexStore: cslIndexStore, + VCStatusStore: vcStatusStore, + ListSize: 2, + KMSRegistry: mockKMSRegistry, + ExternalURL: "https://localhost:8080", + Crypto: vccrypto.New( + &vdrmock.VDRegistry{ResolveValue: createDIDDoc("did:test:abc")}, loader), + }) + require.NoError(t, err) + + s, err := New(&Config{ + DocumentLoader: loader, + CSLManager: cslMgr, + CSLVCStore: cslVCStore, + VCStatusStore: vcStatusStore, + ProfileService: mockProfileSrv, + KMSRegistry: mockKMSRegistry, + ExternalURL: "https://localhost:8080", + Crypto: vccrypto.New( + &vdrmock.VDRegistry{ResolveValue: createDIDDoc("did:test:abc")}, loader), + }) + require.NoError(t, err) + + statusID, err := s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) + require.NoError(t, err) + validateBitstringStatusListEntry(t, s, statusID, listID) statusID, err = s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) require.NoError(t, err) - validateVCStatus(t, s, statusID, listID) + validateBitstringStatusListEntry(t, s, statusID, listID) // List size equals 2, so after 2 issuances CSL encodedBitString is full and listID must be updated. updatedListID, err := cslIndexStore.GetLatestListID(ctx) @@ -153,11 +283,11 @@ func TestCredentialStatusList_CreateStatusListEntry(t *testing.T) { statusID, err = s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) require.NoError(t, err) - validateVCStatus(t, s, statusID, updatedListID) + validateBitstringStatusListEntry(t, s, statusID, updatedListID) statusID, err = s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) require.NoError(t, err) - validateVCStatus(t, s, statusID, updatedListID) + validateBitstringStatusListEntry(t, s, statusID, updatedListID) // List size equals 2, so after 4 issuances CSL encodedBitString is full and listID must be updated. updatedListIDSecond, err := cslIndexStore.GetLatestListID(ctx) @@ -167,7 +297,7 @@ func TestCredentialStatusList_CreateStatusListEntry(t *testing.T) { statusID, err = s.CreateStatusListEntry(ctx, profileID, profileVersion, credID) require.NoError(t, err) - validateVCStatus(t, s, statusID, updatedListIDSecond) + validateBitstringStatusListEntry(t, s, statusID, updatedListIDSecond) }) t.Run("test error get profile service", func(t *testing.T) { @@ -875,6 +1005,10 @@ func validateEvent(e *spi.Event) error { } func getTestProfile() *profileapi.Issuer { + return getTestProfileEx(vc.StatusList2021VCStatus, vcsverifiable.Ed25519Signature2018) +} + +func getTestProfileEx(statusListType vc.StatusType, sigType vcsverifiable.SignatureType) *profileapi.Issuer { return &profileapi.Issuer{ ID: profileID, Version: profileVersion, @@ -882,10 +1016,10 @@ func getTestProfile() *profileapi.Issuer { GroupID: "externalID", VCConfig: &profileapi.VCConfig{ Format: vcsverifiable.Ldp, - SigningAlgorithm: "Ed25519Signature2018", + SigningAlgorithm: sigType, KeyType: kms.ED25519Type, Status: profileapi.StatusConfig{ - Type: vc.StatusList2021VCStatus, + Type: statusListType, }, }, SigningDID: &profileapi.SigningDID{ diff --git a/pkg/cslmanager/cslmanager.go b/pkg/cslmanager/cslmanager.go index b57bf7abf..0ce619a3f 100644 --- a/pkg/cslmanager/cslmanager.go +++ b/pkg/cslmanager/cslmanager.go @@ -111,7 +111,7 @@ func (s *Manager) CreateCSLEntry( } statusListEntry := &credentialstatus.StatusListEntry{ - TypedID: vcStatusProcessor.CreateVCStatus(strconv.Itoa(statusBitIndex), cslURL), + TypedID: vcStatusProcessor.CreateVCStatus(strconv.Itoa(statusBitIndex), cslURL, statustype.StatusPurposeRevocation), Context: vcStatusProcessor.GetVCContext(), } @@ -290,6 +290,10 @@ func (s *Manager) createAndStoreVC(ctx context.Context, signer *vc.Signer, cslUR return fmt.Errorf("failed to marshal VC: %w", err) } + fmt.Println("----------------- Status List VC -----------------") + fmt.Println(string(vcBytes)) + fmt.Println("--------------------------------------------------") + vcWrapper := &credentialstatus.CSLVCWrapper{ VCByte: vcBytes, VC: vc, diff --git a/pkg/cslmanager/cslmanager_test.go b/pkg/cslmanager/cslmanager_test.go index ddce20dec..a7746e379 100644 --- a/pkg/cslmanager/cslmanager_test.go +++ b/pkg/cslmanager/cslmanager_test.go @@ -306,7 +306,7 @@ func TestCredentialStatusList_CreateCSLEntry(t *testing.T) { cslIndexStore := newMockCSLIndexStore() cslVCStore := newMockCSLVCStore() - statusProcessor, err := statustype.GetVCStatusProcessor(vc.StatusList2021VCStatus) + statusProcessor, err := statustype.GetVCStatusProcessor(vc.BitstringStatusList) require.NoError(t, err) listID, err := cslIndexStore.GetLatestListID(context.Background()) diff --git a/pkg/doc/vc/status.go b/pkg/doc/vc/status.go index 52f976018..2f0833190 100644 --- a/pkg/doc/vc/status.go +++ b/pkg/doc/vc/status.go @@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0 package vc import ( + "github.com/samber/lo" "github.com/trustbloc/vc-go/verifiable" ) @@ -29,6 +30,11 @@ const ( // VC > Status > Type // Doc: https://w3c-ccg.github.io/vc-status-rl-2020/ RevocationList2020VCStatus StatusType = "RevocationList2020Status" + + // BitstringStatusList represents the implementation of the Bitstring VC Status List. + // VC > Status > Type + // Doc: https://www.w3.org/TR/vc-bitstring-status-list/ + BitstringStatusList StatusType = "BitstringStatusListEntry" ) // StatusProcessor holds the list of methods required for processing different versions of Status(Revocation) List VC. @@ -37,7 +43,7 @@ type StatusProcessor interface { GetStatusVCURI(vcStatus *verifiable.TypedID) (string, error) GetStatusListIndex(vcStatus *verifiable.TypedID) (int, error) CreateVC(vcID string, listSize int, profile *Signer) (*verifiable.Credential, error) - CreateVCStatus(statusListIndex string, vcID string) *verifiable.TypedID + CreateVCStatus(index string, vcID string, purpose string, additionalFields ...lo.Tuple2[string, any]) *verifiable.TypedID GetVCContext() string } diff --git a/pkg/doc/vc/statustype/common.go b/pkg/doc/vc/statustype/common.go index 58471da24..73ae7ce61 100644 --- a/pkg/doc/vc/statustype/common.go +++ b/pkg/doc/vc/statustype/common.go @@ -8,6 +8,28 @@ package statustype import "github.com/trustbloc/vc-go/verifiable" +const ( + vcType = "VerifiableCredential" + + // StatusListIndex identifies the bit position of the status value of the VC. + // VC > Status > CustomFields key. + StatusListIndex = "statusListIndex" + // StatusListCredential stores the link to the status list VC. + // VC > Status > CustomFields key. + StatusListCredential = "statusListCredential" + // StatusPurpose for StatusList2021. + // VC > Status > CustomFields key. Only "revocation" value is supported. + StatusPurpose = "statusPurpose" + + StatusPurposeRevocation = "revocation" + StatusPurposeSuspension = "suspension" + StatusPurposeMessage = "statusMessage" + + StatusMessage = "statusMessage" + StatusSize = "statusSize" + StatusReference = "statusReference" +) + type credentialSubject struct { ID string `json:"id"` Type string `json:"type"` @@ -24,7 +46,7 @@ func toVerifiableSubject(subject credentialSubject) []verifiable.Subject { }, } if subject.StatusPurpose != "" { - vcSub.CustomFields["statusPurpose"] = subject.StatusPurpose + vcSub.CustomFields[StatusPurpose] = subject.StatusPurpose } return []verifiable.Subject{vcSub} diff --git a/pkg/doc/vc/statustype/revocationlist2020.go b/pkg/doc/vc/statustype/revocationlist2020.go index d7340b6a9..6bf45cc28 100644 --- a/pkg/doc/vc/statustype/revocationlist2020.go +++ b/pkg/doc/vc/statustype/revocationlist2020.go @@ -12,6 +12,7 @@ import ( "time" "github.com/google/uuid" + "github.com/samber/lo" utiltime "github.com/trustbloc/did-go/doc/util/time" "github.com/trustbloc/vc-go/verifiable" @@ -86,12 +87,12 @@ func (s *revocationList2020Processor) ValidateStatus(vcStatus *verifiable.TypedI } // CreateVCStatus creates verifiable.TypedID. -func (s *revocationList2020Processor) CreateVCStatus(revocationListIndex, vcID string) *verifiable.TypedID { +func (s *revocationList2020Processor) CreateVCStatus(index string, vcID string, purpose string, additionalFields ...lo.Tuple2[string, any]) *verifiable.TypedID { return &verifiable.TypedID{ ID: uuid.New().URN(), Type: string(vcapi.RevocationList2020VCStatus), CustomFields: verifiable.CustomFields{ - RevocationListIndex: revocationListIndex, + RevocationListIndex: index, RevocationListCredential: vcID, }, } diff --git a/pkg/doc/vc/statustype/revocationlist2020_test.go b/pkg/doc/vc/statustype/revocationlist2020_test.go index ed7c2e56d..2c423dc92 100644 --- a/pkg/doc/vc/statustype/revocationlist2020_test.go +++ b/pkg/doc/vc/statustype/revocationlist2020_test.go @@ -119,7 +119,7 @@ func Test_revocationList2020Processor_CreateVC(t *testing.T) { func Test_revocationList2020Processor_CreateVCStatus(t *testing.T) { s := NewRevocationList2020Processor() - statusID := s.CreateVCStatus("1", "vcID2") + statusID := s.CreateVCStatus("1", "vcID2", "") require.Equal(t, string(vcapi.RevocationList2020VCStatus), statusID.Type) require.Equal(t, verifiable.CustomFields{ diff --git a/pkg/doc/vc/statustype/revocationlist2021.go b/pkg/doc/vc/statustype/revocationlist2021.go index eda5ec0e8..48a241a3b 100644 --- a/pkg/doc/vc/statustype/revocationlist2021.go +++ b/pkg/doc/vc/statustype/revocationlist2021.go @@ -12,6 +12,7 @@ import ( "time" "github.com/google/uuid" + "github.com/samber/lo" utiltime "github.com/trustbloc/did-go/doc/util/time" "github.com/trustbloc/vc-go/verifiable" @@ -90,12 +91,12 @@ func (s *revocationList2021Processor) ValidateStatus(vcStatus *verifiable.TypedI // CreateVCStatus creates verifiable.TypedID. // Doc: https://github.com/w3c-ccg/vc-status-list-2021/releases/tag/v0.0.1 -func (s *revocationList2021Processor) CreateVCStatus(statusListIndex, vcID string) *verifiable.TypedID { +func (s *revocationList2021Processor) CreateVCStatus(index string, vcID string, purpose string, additionalFields ...lo.Tuple2[string, any]) *verifiable.TypedID { return &verifiable.TypedID{ ID: uuid.New().URN(), Type: string(vcapi.RevocationList2021VCStatus), CustomFields: verifiable.CustomFields{ - StatusListIndex: statusListIndex, + StatusListIndex: index, StatusListCredential: vcID, }, } diff --git a/pkg/doc/vc/statustype/revocationlist2021_test.go b/pkg/doc/vc/statustype/revocationlist2021_test.go index dc2f7aedb..9fc29bd4a 100644 --- a/pkg/doc/vc/statustype/revocationlist2021_test.go +++ b/pkg/doc/vc/statustype/revocationlist2021_test.go @@ -120,7 +120,7 @@ func Test_revocationList2021Processor_CreateVC(t *testing.T) { func Test_revocationList2021Processor_CreateVCStatus(t *testing.T) { s := NewRevocationList2021Processor() - statusID := s.CreateVCStatus("1", "vcID2") + statusID := s.CreateVCStatus("1", "vcID2", "") require.Equal(t, string(vcapi.RevocationList2021VCStatus), statusID.Type) require.Equal(t, verifiable.CustomFields{ diff --git a/pkg/doc/vc/statustype/statuslist2021.go b/pkg/doc/vc/statustype/statuslist2021.go index 2e72f6117..78d81bde7 100644 --- a/pkg/doc/vc/statustype/statuslist2021.go +++ b/pkg/doc/vc/statustype/statuslist2021.go @@ -12,6 +12,7 @@ import ( "time" "github.com/google/uuid" + "github.com/samber/lo" utiltime "github.com/trustbloc/did-go/doc/util/time" "github.com/trustbloc/vc-go/verifiable" @@ -27,20 +28,10 @@ const ( // StatusList2021VCSubjectType is the subject type of status list VC. // status list VC > Subject > Type StatusList2021VCSubjectType = "StatusList2021" - // StatusListIndex identifies the bit position of the status value of the VC. - // VC > Status > CustomFields key. - StatusListIndex = "statusListIndex" - // StatusListCredential stores the link to the status list VC. - // VC > Status > CustomFields key. - StatusListCredential = "statusListCredential" - // StatusPurpose for StatusList2021. - // VC > Status > CustomFields key. Only "revocation" value is supported. - StatusPurpose = "statusPurpose" // StatusList2021Context for StatusList2021. StatusList2021Context = "https://w3id.org/vc/status-list/2021/v1" // bitStringSize represents the size of compressed bitstring. bitStringSize = 128000 - vcType = "VerifiableCredential" ) // statusList2021Processor implements f Status List 2021. @@ -83,28 +74,28 @@ func (s *statusList2021Processor) ValidateStatus(vcStatus *verifiable.TypedID) e } if vcStatus.CustomFields[StatusListIndex] == nil { - return fmt.Errorf("statusListIndex field not exist in vc status") + return fmt.Errorf("%s field not exist in vc status", StatusListIndex) } if vcStatus.CustomFields[StatusListCredential] == nil { - return fmt.Errorf("statusListCredential field not exist in vc status") + return fmt.Errorf("%s field not exist in vc status", StatusListCredential) } if vcStatus.CustomFields[StatusPurpose] == nil { - return fmt.Errorf("statusPurpose field not exist in vc status") + return fmt.Errorf("%s field not exist in vc status", StatusPurpose) } return nil } // CreateVCStatus creates verifiable.TypedID. -func (s *statusList2021Processor) CreateVCStatus(statusListIndex, vcID string) *verifiable.TypedID { +func (s *statusList2021Processor) CreateVCStatus(index string, vcID string, purpose string, additionalFields ...lo.Tuple2[string, any]) *verifiable.TypedID { return &verifiable.TypedID{ ID: uuid.New().URN(), Type: string(vcapi.StatusList2021VCStatus), CustomFields: verifiable.CustomFields{ - StatusPurpose: "revocation", - StatusListIndex: statusListIndex, + StatusPurpose: purpose, + StatusListIndex: index, StatusListCredential: vcID, }, } @@ -142,7 +133,7 @@ func (s *statusList2021Processor) CreateVC(vcID string, listSize int, vcc.Subject = toVerifiableSubject(credentialSubject{ ID: vcc.ID + "#list", Type: StatusList2021VCSubjectType, - StatusPurpose: "revocation", + StatusPurpose: StatusPurposeRevocation, EncodedList: encodeBits, }) diff --git a/pkg/doc/vc/statustype/statuslist2021_test.go b/pkg/doc/vc/statustype/statuslist2021_test.go index 0be02726e..5900bbc03 100644 --- a/pkg/doc/vc/statustype/statuslist2021_test.go +++ b/pkg/doc/vc/statustype/statuslist2021_test.go @@ -138,7 +138,7 @@ func Test_statusList2021Processor_CreateVC(t *testing.T) { func Test_statusList2021Processor_CreateVCStatus(t *testing.T) { s := NewStatusList2021Processor() - statusID := s.CreateVCStatus("1", "vcID2") + statusID := s.CreateVCStatus("1", "vcID2", StatusPurposeRevocation) require.Equal(t, string(vcapi.StatusList2021VCStatus), statusID.Type) require.Equal(t, verifiable.CustomFields{ diff --git a/pkg/doc/vc/statustype/statuslist_bitstring.go b/pkg/doc/vc/statustype/statuslist_bitstring.go new file mode 100644 index 000000000..adfb577a8 --- /dev/null +++ b/pkg/doc/vc/statustype/statuslist_bitstring.go @@ -0,0 +1,226 @@ +/* +Copyright Gen Digital Inc. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package statustype + +import ( + "encoding/json" + "fmt" + "math" + "strconv" + "time" + + "github.com/google/uuid" + "github.com/samber/lo" + utiltime "github.com/trustbloc/did-go/doc/util/time" + "github.com/trustbloc/vc-go/verifiable" + + vcapi "github.com/trustbloc/vcs/pkg/doc/vc" + "github.com/trustbloc/vcs/pkg/doc/vc/bitstring" + "github.com/trustbloc/vcs/pkg/doc/vc/vcutil" +) + +const ( + // StatusListBitstringVCType is the type for status list VC. + // status list VC > Type + StatusListBitstringVCType = "BitstringStatusListCredential" + + // StatusListBitstringEntryType is the subject type of status list entry. + // status list entry VC > Type + StatusListBitstringEntryType = "BitstringStatusListEntry" + + // StatusListBitstringVCSubjectType is the subject type of status list VC. + // status list VC > Subject > Type + StatusListBitstringVCSubjectType = "BitstringStatusList" +) + +// BitstringStatusListProcessor implements the Bitstring Status List Entry. +// Spec: https://www.w3.org/TR/vc-bitstring-status-list/ +type BitstringStatusListProcessor struct{} + +// NewBitstringStatusListProcessor returns new BitstringStatusListProcessor. +func NewBitstringStatusListProcessor() *BitstringStatusListProcessor { + return &BitstringStatusListProcessor{} +} + +// GetStatusVCURI returns the ID (URL) of status VC. +func (s *BitstringStatusListProcessor) GetStatusVCURI(vcStatus *verifiable.TypedID) (string, error) { + statusListVC, ok := vcStatus.CustomFields[StatusListCredential].(string) + if !ok { + return "", fmt.Errorf("failed to cast URI of statusListCredential") + } + + return statusListVC, nil +} + +// GetStatusListIndex returns the bit position of the status value of the VC. +func (s *BitstringStatusListProcessor) GetStatusListIndex(vcStatus *verifiable.TypedID) (int, error) { + revocationListIndex, err := strconv.Atoi(vcStatus.CustomFields[StatusListIndex].(string)) + if err != nil { + return -1, fmt.Errorf("unable to get statusListIndex: %w", err) + } + + return revocationListIndex, nil +} + +type statusMessage struct { + Status string `json:"status"` + Message string `json:"message"` +} + +type statusFields struct { + StatusListCredential string `json:"statusListCredential"` + StatusPurpose string `json:"statusPurpose"` + StatusListIndex string `json:"statusListIndex"` + StatusSize string `json:"statusSize,omitempty"` + StatusMessage []statusMessage `json:"statusMessage,omitempty"` + StatusReference string `json:"statusReference,omitempty"` +} + +// ValidateStatus validates the status of vc. +func (s *BitstringStatusListProcessor) ValidateStatus(vcStatus *verifiable.TypedID) error { + if vcStatus == nil { + return fmt.Errorf("vc status not found") + } + + if vcStatus.Type != string(StatusListBitstringEntryType) { + return fmt.Errorf("vc status %s not supported", vcStatus.Type) + } + + customFieldsBytes, err := json.Marshal(vcStatus.CustomFields) + if err != nil { + return fmt.Errorf("failed to marshal custom fields: %w", err) + } + + fields := &statusFields{} + if err := json.Unmarshal(customFieldsBytes, fields); err != nil { + return fmt.Errorf("failed to unmarshal custom fields: %w", err) + } + + if fields.StatusListIndex == "" { + return fmt.Errorf("%s field not found in vc status", StatusListIndex) + } + + if fields.StatusListCredential == "" { + return fmt.Errorf("%s field not found in vc status", StatusListCredential) + } + + if fields.StatusPurpose == "" { + return fmt.Errorf("%s field not found in vc status", StatusPurpose) + } + + switch fields.StatusPurpose { + case StatusPurposeRevocation, StatusPurposeSuspension: + break + case StatusPurposeMessage: + if err := validateStatusMessage(fields); err != nil { + return err + } + default: + return fmt.Errorf("%s is an unsupported statusPurpose", fields.StatusPurpose) + } + + return nil +} + +// CreateVCStatus creates verifiable.TypedID. +func (s *BitstringStatusListProcessor) CreateVCStatus(index string, vcID string, purpose string, additionalFields ...lo.Tuple2[string, any]) *verifiable.TypedID { + vcStatus := &verifiable.TypedID{ + ID: uuid.New().URN(), + Type: StatusListBitstringEntryType, + CustomFields: verifiable.CustomFields{ + StatusPurpose: purpose, + StatusListIndex: index, + StatusListCredential: vcID, + }, + } + + for _, field := range additionalFields { + vcStatus.CustomFields[field.A] = field.B + } + + customFieldsBytes, err := json.Marshal(vcStatus.CustomFields) + if err != nil { + return nil + } + + fields := &statusFields{} + if err := json.Unmarshal(customFieldsBytes, fields); err != nil { + return nil + } + + return vcStatus +} + +// GetVCContext returns VC.Context value appropriate for BitStringStatusList. +func (s *BitstringStatusListProcessor) GetVCContext() string { + return verifiable.V2ContextURI +} + +// CreateVC returns *verifiable.Credential appropriate for BitStringStatusList. +func (s *BitstringStatusListProcessor) CreateVC(vcID string, listSize int, + profile *vcapi.Signer) (*verifiable.Credential, error) { + vcc := verifiable.CredentialContents{} + + vcc.Context = vcutil.AppendSignatureTypeContext([]string{verifiable.V2ContextURI}, profile.SignatureType) + vcc.ID = vcID + vcc.Types = []string{vcType, StatusListBitstringVCType} + vcc.Issuer = &verifiable.Issuer{ID: profile.DID} + vcc.Issued = utiltime.NewTime(time.Now().UTC()) + + size := listSize + + if size < bitStringSize { + size = bitStringSize + } + + encodeBits, err := bitstring.NewBitString(size).EncodeBits() + if err != nil { + return nil, err + } + + vcc.Subject = toVerifiableSubject(credentialSubject{ + ID: vcc.ID + "#list", + Type: StatusListBitstringVCSubjectType, + StatusPurpose: StatusPurposeRevocation, + EncodedList: encodeBits, + }) + + return verifiable.CreateCredential(vcc, nil) +} + +func validateStatusMessage(fields *statusFields) error { + size := 2 + + if fields.StatusSize != "" { + intSize, err := strconv.Atoi(fields.StatusSize) + if err != nil { + return fmt.Errorf("unable to get statusSize: %w", err) + } + + size = int(math.Pow(2, float64(intSize))) //nolint:gomnd + } + + if len(fields.StatusMessage) != size { + return fmt.Errorf("statusMessage array size must be %d", size) + } + + for _, message := range fields.StatusMessage { + if message.Message == "" { + return fmt.Errorf("message field not found") + } + + if message.Status == "" { + return fmt.Errorf("status field not found") + } + + if len(message.Status) < 3 || message.Status[0:2] != "0x" { + return fmt.Errorf("status field must be a hex string") + } + } + + return nil +} diff --git a/pkg/doc/vc/statustype/statuslist_bitstring_test.go b/pkg/doc/vc/statustype/statuslist_bitstring_test.go new file mode 100644 index 000000000..793886fd5 --- /dev/null +++ b/pkg/doc/vc/statustype/statuslist_bitstring_test.go @@ -0,0 +1,405 @@ +/* +Copyright Gen Digital Inc. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package statustype + +import ( + "testing" + + "github.com/samber/lo" + "github.com/stretchr/testify/require" + "github.com/trustbloc/vc-go/verifiable" + + vcapi "github.com/trustbloc/vcs/pkg/doc/vc" + "github.com/trustbloc/vcs/pkg/doc/vc/bitstring" + vcsverifiable "github.com/trustbloc/vcs/pkg/doc/verifiable" +) + +func Test_BitstringStatusListProcessor_ValidateStatus(t *testing.T) { + type args struct { + vcStatus *verifiable.TypedID + } + tests := []struct { + name string + args args + wantErr string + }{ + { + name: "status purpose revocation -> OK", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusListCredential": "https://example.com/credentials/status/8", + "statusPurpose": StatusPurposeRevocation, + }, + }, + }, + }, + { + name: "Error not exist", + args: args{ + vcStatus: nil, + }, + wantErr: "vc status not found", + }, + { + name: "Error status not supported", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "statusPurpose", + }, + }, + wantErr: "vc status statusPurpose not supported", + }, + { + name: "Error statusListIndex empty", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListCredential": "https://example.com/credentials/status/8", + "statusPurpose": StatusPurposeRevocation, + }, + }, + }, + wantErr: "statusListIndex field not found in vc status", + }, + { + name: "Error statusListCredential empty", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusPurpose": StatusPurposeRevocation, + }, + }, + }, + wantErr: "statusListCredential field not found in vc status", + }, + { + name: "Error statusPurpose empty", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusListCredential": "https://example.com/credentials/status/8", + }, + }, + }, + wantErr: "statusPurpose field not found in vc status", + }, + { + name: "Unsupported statusPurpose error", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusListCredential": "https://example.com/credentials/status/8", + "statusPurpose": "some-purpose", + }, + }, + }, + wantErr: "some-purpose is an unsupported statusPurpose", + }, + { + name: "statusPurpose statusMessage -> statusMessage array size must be 2", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusListCredential": "https://example.com/credentials/status/8", + "statusPurpose": StatusPurposeMessage, + }, + }, + }, + wantErr: "statusMessage array size must be 2", + }, + { + name: "statusPurpose statusMessage -> status field not found", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusListCredential": "https://example.com/credentials/status/8", + "statusPurpose": StatusPurposeMessage, + "statusMessage": []interface{}{ + map[string]interface{}{ + "message": "value", + }, + map[string]interface{}{ + "message": "value", + }, + }, + }, + }, + }, + wantErr: "status field not found", + }, + { + name: "statusPurpose statusMessage -> message field not found", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusListCredential": "https://example.com/credentials/status/8", + "statusPurpose": StatusPurposeMessage, + "statusMessage": []interface{}{ + map[string]interface{}{ + "status": "value", + }, + map[string]interface{}{ + "status": "value", + }, + }, + }, + }, + }, + wantErr: "message field not found", + }, + { + name: "statusPurpose statusMessage > status field must be a hex string", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusListCredential": "https://example.com/credentials/status/8", + "statusPurpose": StatusPurposeMessage, + "statusMessage": []interface{}{ + map[string]interface{}{ + "status": "1", + "message": "message_1", + }, + map[string]interface{}{ + "status": "2", + "message": "message_2", + }, + }, + }, + }, + }, + wantErr: "status field must be a hex string", + }, + { + name: "statusPurpose statusMessage > default statusSize -> OK", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusListCredential": "https://example.com/credentials/status/8", + "statusPurpose": StatusPurposeMessage, + "statusMessage": []interface{}{ + map[string]interface{}{ + "status": "0x1", + "message": "message_1", + }, + map[string]interface{}{ + "status": "0x2", + "message": "message_2", + }, + }, + }, + }, + }, + wantErr: "", + }, + { + name: "statusPurpose statusMessage > statusSize 2 -> OK", + args: args{ + vcStatus: &verifiable.TypedID{ + Type: "BitstringStatusListEntry", + CustomFields: map[string]interface{}{ + "statusListIndex": "1", + "statusListCredential": "https://example.com/credentials/status/8", + "statusPurpose": StatusPurposeMessage, + "statusSize": "2", + "statusMessage": []interface{}{ + map[string]interface{}{ + "status": "0x1", + "message": "message_1", + }, + map[string]interface{}{ + "status": "0x2", + "message": "message_2", + }, + map[string]interface{}{ + "status": "0x3", + "message": "message_3", + }, + map[string]interface{}{ + "status": "0x4", + "message": "message_4", + }, + }, + }, + }, + }, + wantErr: "", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + s := NewBitstringStatusListProcessor() + err := s.ValidateStatus(tt.args.vcStatus) + if err != nil { + if err.Error() != tt.wantErr { + t.Errorf("validateVCStatus() error = %v, wantErr %s", err, tt.wantErr) + } + } else if tt.wantErr != "" { + t.Errorf("validateVCStatus() error = %v, wantErr %s", err, tt.wantErr) + } + }) + } +} + +func Test_BitstringStatusListProcessor_CreateVC(t *testing.T) { + s := NewBitstringStatusListProcessor() + vc, err := s.CreateVC("vcID1", 10, &vcapi.Signer{ + DID: "did:example:123", + SignatureType: vcsverifiable.Ed25519Signature2018, + }) + require.NoError(t, err) + + vcc := vc.Contents() + + require.NoError(t, err) + require.Equal(t, "vcID1", vcc.ID) + require.Equal(t, []string{ + verifiable.V2ContextURI, + "https://w3id.org/security/suites/ed25519-2018/v1"}, vcc.Context) + require.Equal(t, []string{vcType, StatusListBitstringVCType}, vcc.Types) + require.Equal(t, &verifiable.Issuer{ID: "did:example:123"}, vcc.Issuer) + encodeBits, err := bitstring.NewBitString(bitStringSize).EncodeBits() + require.NotEmpty(t, vc.ToRawClaimsMap()["validFrom"]) + require.NoError(t, err) + require.Equal(t, []verifiable.Subject{{ + ID: "vcID1#list", + CustomFields: map[string]interface{}{ + "type": "BitstringStatusList", + "statusPurpose": "revocation", + "encodedList": encodeBits, + }, + }}, vcc.Subject) +} + +func Test_BitstringStatusListProcessor_CreateVCStatus(t *testing.T) { + s := NewBitstringStatusListProcessor() + + t.Run("status purpose revocation", func(t *testing.T) { + statusID := s.CreateVCStatus("1", "vcID2", StatusPurposeRevocation) + + require.Equal(t, StatusListBitstringEntryType, statusID.Type) + require.Equal(t, verifiable.CustomFields{ + StatusPurpose: "revocation", + StatusListIndex: "1", + StatusListCredential: "vcID2", + }, statusID.CustomFields) + }) + + t.Run("status purpose suspension", func(t *testing.T) { + statusID := s.CreateVCStatus("1", "vcID2", StatusPurposeSuspension) + + require.Equal(t, StatusListBitstringEntryType, statusID.Type) + require.Equal(t, verifiable.CustomFields{ + StatusPurpose: "suspension", + StatusListIndex: "1", + StatusListCredential: "vcID2", + }, statusID.CustomFields) + }) + + t.Run("status purpose statusMessage", func(t *testing.T) { + statusID := s.CreateVCStatus("1", "vcID2", StatusPurposeMessage, + lo.Tuple2[string, any]{StatusReference, "https://example.org/status-dictionary/"}, + lo.Tuple2[string, any]{A: "statusSize", B: "1"}, + lo.Tuple2[string, any]{A: "statusMessage", B: []interface{}{ + map[string]interface{}{ + "status": "0x1", + "message": "message_1", + }, + map[string]interface{}{ + "status": "0x2", + "message": "message_2", + }, + }}, + ) + require.Equal(t, StatusListBitstringEntryType, statusID.Type) + require.Equal(t, verifiable.CustomFields{ + StatusPurpose: "statusMessage", + StatusListIndex: "1", + StatusListCredential: "vcID2", + StatusSize: "1", + StatusReference: "https://example.org/status-dictionary/", + StatusMessage: []interface{}{ + map[string]interface{}{ + "status": "0x1", + "message": "message_1", + }, + map[string]interface{}{ + "status": "0x2", + "message": "message_2", + }, + }, + }, statusID.CustomFields) + + require.NoError(t, s.ValidateStatus(statusID)) + }) +} + +func Test_BitstringStatusListProcessor_GetStatusListIndex(t *testing.T) { + vcStatus := &verifiable.TypedID{ + CustomFields: map[string]interface{}{ + StatusListIndex: "abc", + }, + } + + s := NewBitstringStatusListProcessor() + index, err := s.GetStatusListIndex(vcStatus) + require.Error(t, err) + require.ErrorContains(t, err, "unable to get statusListIndex") + require.Equal(t, -1, index) + + vcStatus.CustomFields[StatusListIndex] = "1" + index, err = s.GetStatusListIndex(vcStatus) + require.NoError(t, err) + + require.Equal(t, 1, index) +} + +func Test_BitstringStatusListProcessor_GetStatusVCURI(t *testing.T) { + vcStatus := &verifiable.TypedID{ + CustomFields: map[string]interface{}{ + StatusListCredential: 1, + }, + } + + s := NewBitstringStatusListProcessor() + vcURI, err := s.GetStatusVCURI(vcStatus) + require.Error(t, err) + require.ErrorContains(t, err, "failed to cast URI of statusListCredential") + require.Empty(t, vcURI) + + vcStatus.CustomFields[StatusListCredential] = "https://example.com/1" + vcURI, err = s.GetStatusVCURI(vcStatus) + require.NoError(t, err) + + require.Equal(t, "https://example.com/1", vcURI) +} + +func Test_BitstringStatusListProcessor_GetVCContext(t *testing.T) { + s := NewBitstringStatusListProcessor() + + require.Equal(t, "https://www.w3.org/ns/credentials/v2", s.GetVCContext()) +} diff --git a/pkg/doc/vc/statustype/statusprocessor.go b/pkg/doc/vc/statustype/statusprocessor.go index e5011d2ae..128253e4d 100644 --- a/pkg/doc/vc/statustype/statusprocessor.go +++ b/pkg/doc/vc/statustype/statusprocessor.go @@ -17,6 +17,8 @@ func GetVCStatusProcessor(vcStatusListType vcapi.StatusType) (vcapi.StatusProces switch vcStatusListType { case vcapi.StatusList2021VCStatus: return NewStatusList2021Processor(), nil + case vcapi.BitstringStatusList: + return NewBitstringStatusListProcessor(), nil case vcapi.RevocationList2021VCStatus: return NewRevocationList2021Processor(), nil case vcapi.RevocationList2020VCStatus: diff --git a/pkg/doc/vc/statustype/statusprocessor_test.go b/pkg/doc/vc/statustype/statusprocessor_test.go new file mode 100644 index 000000000..ac3625e54 --- /dev/null +++ b/pkg/doc/vc/statustype/statusprocessor_test.go @@ -0,0 +1,51 @@ +/* +Copyright Gen Digital Inc. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package statustype + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/trustbloc/vc-go/verifiable" + + vcapi "github.com/trustbloc/vcs/pkg/doc/vc" +) + +func TestGetVCStatusProcessor_StatusList2021VCStatus(t *testing.T) { + processor, err := GetVCStatusProcessor(vcapi.StatusList2021VCStatus) + require.NoError(t, err) + require.NotNil(t, processor) + require.Equal(t, StatusList2021Context, processor.GetVCContext()) +} + +func TestGetVCStatusProcessor_BitstringStatusListEntry(t *testing.T) { + processor, err := GetVCStatusProcessor(vcapi.BitstringStatusList) + require.NoError(t, err) + require.NotNil(t, processor) + require.Equal(t, verifiable.V2ContextURI, processor.GetVCContext()) +} + +func TestGetVCStatusProcessor_RevocationList2021VCStatus(t *testing.T) { + processor, err := GetVCStatusProcessor(vcapi.RevocationList2021VCStatus) + require.NoError(t, err) + require.NotNil(t, processor) + require.Equal(t, RevocationList2021Context, processor.GetVCContext()) +} + +func TestGetVCStatusProcessor_RevocationList2020VCStatus(t *testing.T) { + processor, err := GetVCStatusProcessor(vcapi.RevocationList2020VCStatus) + require.NoError(t, err) + require.NotNil(t, processor) + require.Equal(t, RevocationList2020Context, processor.GetVCContext()) +} + +func TestGetVCStatusProcessor_UnsupportedVCStatusListType(t *testing.T) { + processor, err := GetVCStatusProcessor(vcapi.StatusType("unsupported")) + require.Error(t, err) + require.Nil(t, processor) + require.Contains(t, err.Error(), "unsupported VCStatusListType") +} diff --git a/pkg/doc/vc/vcutil/vcutil.go b/pkg/doc/vc/vcutil/vcutil.go index c3664c730..af68b3ee7 100644 --- a/pkg/doc/vc/vcutil/vcutil.go +++ b/pkg/doc/vc/vcutil/vcutil.go @@ -22,6 +22,9 @@ const ( DefVCContext = "https://www.w3.org/2018/credentials/v1" jsonWebSignature2020Context = "https://w3c-ccg.github.io/lds-jws2020/contexts/lds-jws2020-v1.json" bbsBlsSignature2020Context = "https://w3id.org/security/bbs/v1" + + Ed25519Signature2018Context = "https://w3id.org/security/suites/ed25519-2018/v1" + Ed25519Signature2020Context = "https://w3id.org/security/suites/ed25519-2020/v1" ) // GetContextsFromJSONRaw reads contexts from raw JSON. @@ -107,6 +110,10 @@ func AppendSignatureTypeContext( context []string, signatureType vcsverifiable.SignatureType, ) []string { + if signatureType == vcsverifiable.Ed25519Signature2020 { + return appendIfMissing(context, Ed25519Signature2020Context) + } + if signatureType == vcsverifiable.JSONWebSignature2020 { return appendIfMissing(context, jsonWebSignature2020Context) } @@ -115,6 +122,10 @@ func AppendSignatureTypeContext( return appendIfMissing(context, bbsBlsSignature2020Context) } + if signatureType == vcsverifiable.Ed25519Signature2018 && !lo.Contains(context, DefVCContext) { + return appendIfMissing(context, Ed25519Signature2018Context) + } + return context } diff --git a/pkg/internal/mock/status/status.go b/pkg/internal/mock/status/status.go index 49258eb8c..94b855773 100644 --- a/pkg/internal/mock/status/status.go +++ b/pkg/internal/mock/status/status.go @@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0 package status import ( + "github.com/samber/lo" "github.com/trustbloc/vc-go/verifiable" "github.com/trustbloc/vcs/pkg/doc/vc" @@ -49,7 +50,7 @@ func (m *MockVCStatusProcessor) CreateVC(_ string, _ int, _ *vc.Signer) (*verifi return m.VC, m.CreateVCErr } -func (m *MockVCStatusProcessor) CreateVCStatus(_ string, _ string) *verifiable.TypedID { +func (m *MockVCStatusProcessor) CreateVCStatus(string, string, string, ...lo.Tuple2[string, any]) *verifiable.TypedID { return m.VCStatus } diff --git a/pkg/kms/aws/service_mocks.go b/pkg/kms/aws/service_mocks.go index 077cf94be..3973e662b 100644 --- a/pkg/kms/aws/service_mocks.go +++ b/pkg/kms/aws/service_mocks.go @@ -50,34 +50,10 @@ func (m *MockawsClient) CreateAlias(ctx context.Context, params *kms.CreateAlias } // CreateAlias indicates an expected call of CreateAlias. -func (mr *MockawsClientMockRecorder) CreateAlias(ctx, params interface{}, optFns ...interface{}) *awsClientCreateAliasCall { +func (mr *MockawsClientMockRecorder) CreateAlias(ctx, params interface{}, optFns ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, params}, optFns...) - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAlias", reflect.TypeOf((*MockawsClient)(nil).CreateAlias), varargs...) - return &awsClientCreateAliasCall{Call: call} -} - -// awsClientCreateAliasCall wrap *gomock.Call -type awsClientCreateAliasCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *awsClientCreateAliasCall) Return(arg0 *kms.CreateAliasOutput, arg1 error) *awsClientCreateAliasCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *awsClientCreateAliasCall) Do(f func(context.Context, *kms.CreateAliasInput, ...func(*kms.Options)) (*kms.CreateAliasOutput, error)) *awsClientCreateAliasCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *awsClientCreateAliasCall) DoAndReturn(f func(context.Context, *kms.CreateAliasInput, ...func(*kms.Options)) (*kms.CreateAliasOutput, error)) *awsClientCreateAliasCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAlias", reflect.TypeOf((*MockawsClient)(nil).CreateAlias), varargs...) } // CreateKey mocks base method. @@ -94,34 +70,10 @@ func (m *MockawsClient) CreateKey(ctx context.Context, params *kms.CreateKeyInpu } // CreateKey indicates an expected call of CreateKey. -func (mr *MockawsClientMockRecorder) CreateKey(ctx, params interface{}, optFns ...interface{}) *awsClientCreateKeyCall { +func (mr *MockawsClientMockRecorder) CreateKey(ctx, params interface{}, optFns ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, params}, optFns...) - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateKey", reflect.TypeOf((*MockawsClient)(nil).CreateKey), varargs...) - return &awsClientCreateKeyCall{Call: call} -} - -// awsClientCreateKeyCall wrap *gomock.Call -type awsClientCreateKeyCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *awsClientCreateKeyCall) Return(arg0 *kms.CreateKeyOutput, arg1 error) *awsClientCreateKeyCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *awsClientCreateKeyCall) Do(f func(context.Context, *kms.CreateKeyInput, ...func(*kms.Options)) (*kms.CreateKeyOutput, error)) *awsClientCreateKeyCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *awsClientCreateKeyCall) DoAndReturn(f func(context.Context, *kms.CreateKeyInput, ...func(*kms.Options)) (*kms.CreateKeyOutput, error)) *awsClientCreateKeyCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateKey", reflect.TypeOf((*MockawsClient)(nil).CreateKey), varargs...) } // Decrypt mocks base method. @@ -138,34 +90,10 @@ func (m *MockawsClient) Decrypt(ctx context.Context, params *kms.DecryptInput, o } // Decrypt indicates an expected call of Decrypt. -func (mr *MockawsClientMockRecorder) Decrypt(ctx, params interface{}, optFns ...interface{}) *awsClientDecryptCall { +func (mr *MockawsClientMockRecorder) Decrypt(ctx, params interface{}, optFns ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, params}, optFns...) - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Decrypt", reflect.TypeOf((*MockawsClient)(nil).Decrypt), varargs...) - return &awsClientDecryptCall{Call: call} -} - -// awsClientDecryptCall wrap *gomock.Call -type awsClientDecryptCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *awsClientDecryptCall) Return(arg0 *kms.DecryptOutput, arg1 error) *awsClientDecryptCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *awsClientDecryptCall) Do(f func(context.Context, *kms.DecryptInput, ...func(*kms.Options)) (*kms.DecryptOutput, error)) *awsClientDecryptCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *awsClientDecryptCall) DoAndReturn(f func(context.Context, *kms.DecryptInput, ...func(*kms.Options)) (*kms.DecryptOutput, error)) *awsClientDecryptCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Decrypt", reflect.TypeOf((*MockawsClient)(nil).Decrypt), varargs...) } // DescribeKey mocks base method. @@ -182,34 +110,10 @@ func (m *MockawsClient) DescribeKey(ctx context.Context, params *kms.DescribeKey } // DescribeKey indicates an expected call of DescribeKey. -func (mr *MockawsClientMockRecorder) DescribeKey(ctx, params interface{}, optFns ...interface{}) *awsClientDescribeKeyCall { +func (mr *MockawsClientMockRecorder) DescribeKey(ctx, params interface{}, optFns ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, params}, optFns...) - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeKey", reflect.TypeOf((*MockawsClient)(nil).DescribeKey), varargs...) - return &awsClientDescribeKeyCall{Call: call} -} - -// awsClientDescribeKeyCall wrap *gomock.Call -type awsClientDescribeKeyCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *awsClientDescribeKeyCall) Return(arg0 *kms.DescribeKeyOutput, arg1 error) *awsClientDescribeKeyCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *awsClientDescribeKeyCall) Do(f func(context.Context, *kms.DescribeKeyInput, ...func(*kms.Options)) (*kms.DescribeKeyOutput, error)) *awsClientDescribeKeyCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *awsClientDescribeKeyCall) DoAndReturn(f func(context.Context, *kms.DescribeKeyInput, ...func(*kms.Options)) (*kms.DescribeKeyOutput, error)) *awsClientDescribeKeyCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeKey", reflect.TypeOf((*MockawsClient)(nil).DescribeKey), varargs...) } // Encrypt mocks base method. @@ -226,34 +130,10 @@ func (m *MockawsClient) Encrypt(ctx context.Context, params *kms.EncryptInput, o } // Encrypt indicates an expected call of Encrypt. -func (mr *MockawsClientMockRecorder) Encrypt(ctx, params interface{}, optFns ...interface{}) *awsClientEncryptCall { +func (mr *MockawsClientMockRecorder) Encrypt(ctx, params interface{}, optFns ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, params}, optFns...) - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Encrypt", reflect.TypeOf((*MockawsClient)(nil).Encrypt), varargs...) - return &awsClientEncryptCall{Call: call} -} - -// awsClientEncryptCall wrap *gomock.Call -type awsClientEncryptCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *awsClientEncryptCall) Return(arg0 *kms.EncryptOutput, arg1 error) *awsClientEncryptCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *awsClientEncryptCall) Do(f func(context.Context, *kms.EncryptInput, ...func(*kms.Options)) (*kms.EncryptOutput, error)) *awsClientEncryptCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *awsClientEncryptCall) DoAndReturn(f func(context.Context, *kms.EncryptInput, ...func(*kms.Options)) (*kms.EncryptOutput, error)) *awsClientEncryptCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Encrypt", reflect.TypeOf((*MockawsClient)(nil).Encrypt), varargs...) } // GetPublicKey mocks base method. @@ -270,34 +150,10 @@ func (m *MockawsClient) GetPublicKey(ctx context.Context, params *kms.GetPublicK } // GetPublicKey indicates an expected call of GetPublicKey. -func (mr *MockawsClientMockRecorder) GetPublicKey(ctx, params interface{}, optFns ...interface{}) *awsClientGetPublicKeyCall { +func (mr *MockawsClientMockRecorder) GetPublicKey(ctx, params interface{}, optFns ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, params}, optFns...) - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPublicKey", reflect.TypeOf((*MockawsClient)(nil).GetPublicKey), varargs...) - return &awsClientGetPublicKeyCall{Call: call} -} - -// awsClientGetPublicKeyCall wrap *gomock.Call -type awsClientGetPublicKeyCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *awsClientGetPublicKeyCall) Return(arg0 *kms.GetPublicKeyOutput, arg1 error) *awsClientGetPublicKeyCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *awsClientGetPublicKeyCall) Do(f func(context.Context, *kms.GetPublicKeyInput, ...func(*kms.Options)) (*kms.GetPublicKeyOutput, error)) *awsClientGetPublicKeyCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *awsClientGetPublicKeyCall) DoAndReturn(f func(context.Context, *kms.GetPublicKeyInput, ...func(*kms.Options)) (*kms.GetPublicKeyOutput, error)) *awsClientGetPublicKeyCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPublicKey", reflect.TypeOf((*MockawsClient)(nil).GetPublicKey), varargs...) } // ScheduleKeyDeletion mocks base method. @@ -314,34 +170,10 @@ func (m *MockawsClient) ScheduleKeyDeletion(ctx context.Context, params *kms.Sch } // ScheduleKeyDeletion indicates an expected call of ScheduleKeyDeletion. -func (mr *MockawsClientMockRecorder) ScheduleKeyDeletion(ctx, params interface{}, optFns ...interface{}) *awsClientScheduleKeyDeletionCall { +func (mr *MockawsClientMockRecorder) ScheduleKeyDeletion(ctx, params interface{}, optFns ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, params}, optFns...) - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScheduleKeyDeletion", reflect.TypeOf((*MockawsClient)(nil).ScheduleKeyDeletion), varargs...) - return &awsClientScheduleKeyDeletionCall{Call: call} -} - -// awsClientScheduleKeyDeletionCall wrap *gomock.Call -type awsClientScheduleKeyDeletionCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *awsClientScheduleKeyDeletionCall) Return(arg0 *kms.ScheduleKeyDeletionOutput, arg1 error) *awsClientScheduleKeyDeletionCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *awsClientScheduleKeyDeletionCall) Do(f func(context.Context, *kms.ScheduleKeyDeletionInput, ...func(*kms.Options)) (*kms.ScheduleKeyDeletionOutput, error)) *awsClientScheduleKeyDeletionCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *awsClientScheduleKeyDeletionCall) DoAndReturn(f func(context.Context, *kms.ScheduleKeyDeletionInput, ...func(*kms.Options)) (*kms.ScheduleKeyDeletionOutput, error)) *awsClientScheduleKeyDeletionCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScheduleKeyDeletion", reflect.TypeOf((*MockawsClient)(nil).ScheduleKeyDeletion), varargs...) } // Sign mocks base method. @@ -358,34 +190,10 @@ func (m *MockawsClient) Sign(ctx context.Context, params *kms.SignInput, optFns } // Sign indicates an expected call of Sign. -func (mr *MockawsClientMockRecorder) Sign(ctx, params interface{}, optFns ...interface{}) *awsClientSignCall { +func (mr *MockawsClientMockRecorder) Sign(ctx, params interface{}, optFns ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, params}, optFns...) - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sign", reflect.TypeOf((*MockawsClient)(nil).Sign), varargs...) - return &awsClientSignCall{Call: call} -} - -// awsClientSignCall wrap *gomock.Call -type awsClientSignCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *awsClientSignCall) Return(arg0 *kms.SignOutput, arg1 error) *awsClientSignCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *awsClientSignCall) Do(f func(context.Context, *kms.SignInput, ...func(*kms.Options)) (*kms.SignOutput, error)) *awsClientSignCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *awsClientSignCall) DoAndReturn(f func(context.Context, *kms.SignInput, ...func(*kms.Options)) (*kms.SignOutput, error)) *awsClientSignCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sign", reflect.TypeOf((*MockawsClient)(nil).Sign), varargs...) } // Verify mocks base method. @@ -402,34 +210,10 @@ func (m *MockawsClient) Verify(ctx context.Context, params *kms.VerifyInput, opt } // Verify indicates an expected call of Verify. -func (mr *MockawsClientMockRecorder) Verify(ctx, params interface{}, optFns ...interface{}) *awsClientVerifyCall { +func (mr *MockawsClientMockRecorder) Verify(ctx, params interface{}, optFns ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, params}, optFns...) - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Verify", reflect.TypeOf((*MockawsClient)(nil).Verify), varargs...) - return &awsClientVerifyCall{Call: call} -} - -// awsClientVerifyCall wrap *gomock.Call -type awsClientVerifyCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *awsClientVerifyCall) Return(arg0 *kms.VerifyOutput, arg1 error) *awsClientVerifyCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *awsClientVerifyCall) Do(f func(context.Context, *kms.VerifyInput, ...func(*kms.Options)) (*kms.VerifyOutput, error)) *awsClientVerifyCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *awsClientVerifyCall) DoAndReturn(f func(context.Context, *kms.VerifyInput, ...func(*kms.Options)) (*kms.VerifyOutput, error)) *awsClientVerifyCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Verify", reflect.TypeOf((*MockawsClient)(nil).Verify), varargs...) } // MockmetricsProvider is a mock of metricsProvider interface. @@ -462,33 +246,9 @@ func (m *MockmetricsProvider) DecryptCount() { } // DecryptCount indicates an expected call of DecryptCount. -func (mr *MockmetricsProviderMockRecorder) DecryptCount() *metricsProviderDecryptCountCall { +func (mr *MockmetricsProviderMockRecorder) DecryptCount() *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptCount", reflect.TypeOf((*MockmetricsProvider)(nil).DecryptCount)) - return &metricsProviderDecryptCountCall{Call: call} -} - -// metricsProviderDecryptCountCall wrap *gomock.Call -type metricsProviderDecryptCountCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderDecryptCountCall) Return() *metricsProviderDecryptCountCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderDecryptCountCall) Do(f func()) *metricsProviderDecryptCountCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderDecryptCountCall) DoAndReturn(f func()) *metricsProviderDecryptCountCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptCount", reflect.TypeOf((*MockmetricsProvider)(nil).DecryptCount)) } // DecryptTime mocks base method. @@ -498,33 +258,9 @@ func (m *MockmetricsProvider) DecryptTime(value time.Duration) { } // DecryptTime indicates an expected call of DecryptTime. -func (mr *MockmetricsProviderMockRecorder) DecryptTime(value interface{}) *metricsProviderDecryptTimeCall { +func (mr *MockmetricsProviderMockRecorder) DecryptTime(value interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptTime", reflect.TypeOf((*MockmetricsProvider)(nil).DecryptTime), value) - return &metricsProviderDecryptTimeCall{Call: call} -} - -// metricsProviderDecryptTimeCall wrap *gomock.Call -type metricsProviderDecryptTimeCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderDecryptTimeCall) Return() *metricsProviderDecryptTimeCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderDecryptTimeCall) Do(f func(time.Duration)) *metricsProviderDecryptTimeCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderDecryptTimeCall) DoAndReturn(f func(time.Duration)) *metricsProviderDecryptTimeCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptTime", reflect.TypeOf((*MockmetricsProvider)(nil).DecryptTime), value) } // EncryptCount mocks base method. @@ -534,33 +270,9 @@ func (m *MockmetricsProvider) EncryptCount() { } // EncryptCount indicates an expected call of EncryptCount. -func (mr *MockmetricsProviderMockRecorder) EncryptCount() *metricsProviderEncryptCountCall { +func (mr *MockmetricsProviderMockRecorder) EncryptCount() *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EncryptCount", reflect.TypeOf((*MockmetricsProvider)(nil).EncryptCount)) - return &metricsProviderEncryptCountCall{Call: call} -} - -// metricsProviderEncryptCountCall wrap *gomock.Call -type metricsProviderEncryptCountCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderEncryptCountCall) Return() *metricsProviderEncryptCountCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderEncryptCountCall) Do(f func()) *metricsProviderEncryptCountCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderEncryptCountCall) DoAndReturn(f func()) *metricsProviderEncryptCountCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EncryptCount", reflect.TypeOf((*MockmetricsProvider)(nil).EncryptCount)) } // EncryptTime mocks base method. @@ -570,33 +282,9 @@ func (m *MockmetricsProvider) EncryptTime(value time.Duration) { } // EncryptTime indicates an expected call of EncryptTime. -func (mr *MockmetricsProviderMockRecorder) EncryptTime(value interface{}) *metricsProviderEncryptTimeCall { +func (mr *MockmetricsProviderMockRecorder) EncryptTime(value interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EncryptTime", reflect.TypeOf((*MockmetricsProvider)(nil).EncryptTime), value) - return &metricsProviderEncryptTimeCall{Call: call} -} - -// metricsProviderEncryptTimeCall wrap *gomock.Call -type metricsProviderEncryptTimeCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderEncryptTimeCall) Return() *metricsProviderEncryptTimeCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderEncryptTimeCall) Do(f func(time.Duration)) *metricsProviderEncryptTimeCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderEncryptTimeCall) DoAndReturn(f func(time.Duration)) *metricsProviderEncryptTimeCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EncryptTime", reflect.TypeOf((*MockmetricsProvider)(nil).EncryptTime), value) } // ExportPublicKeyCount mocks base method. @@ -606,33 +294,9 @@ func (m *MockmetricsProvider) ExportPublicKeyCount() { } // ExportPublicKeyCount indicates an expected call of ExportPublicKeyCount. -func (mr *MockmetricsProviderMockRecorder) ExportPublicKeyCount() *metricsProviderExportPublicKeyCountCall { +func (mr *MockmetricsProviderMockRecorder) ExportPublicKeyCount() *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportPublicKeyCount", reflect.TypeOf((*MockmetricsProvider)(nil).ExportPublicKeyCount)) - return &metricsProviderExportPublicKeyCountCall{Call: call} -} - -// metricsProviderExportPublicKeyCountCall wrap *gomock.Call -type metricsProviderExportPublicKeyCountCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderExportPublicKeyCountCall) Return() *metricsProviderExportPublicKeyCountCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderExportPublicKeyCountCall) Do(f func()) *metricsProviderExportPublicKeyCountCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderExportPublicKeyCountCall) DoAndReturn(f func()) *metricsProviderExportPublicKeyCountCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportPublicKeyCount", reflect.TypeOf((*MockmetricsProvider)(nil).ExportPublicKeyCount)) } // ExportPublicKeyTime mocks base method. @@ -642,33 +306,9 @@ func (m *MockmetricsProvider) ExportPublicKeyTime(value time.Duration) { } // ExportPublicKeyTime indicates an expected call of ExportPublicKeyTime. -func (mr *MockmetricsProviderMockRecorder) ExportPublicKeyTime(value interface{}) *metricsProviderExportPublicKeyTimeCall { +func (mr *MockmetricsProviderMockRecorder) ExportPublicKeyTime(value interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportPublicKeyTime", reflect.TypeOf((*MockmetricsProvider)(nil).ExportPublicKeyTime), value) - return &metricsProviderExportPublicKeyTimeCall{Call: call} -} - -// metricsProviderExportPublicKeyTimeCall wrap *gomock.Call -type metricsProviderExportPublicKeyTimeCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderExportPublicKeyTimeCall) Return() *metricsProviderExportPublicKeyTimeCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderExportPublicKeyTimeCall) Do(f func(time.Duration)) *metricsProviderExportPublicKeyTimeCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderExportPublicKeyTimeCall) DoAndReturn(f func(time.Duration)) *metricsProviderExportPublicKeyTimeCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExportPublicKeyTime", reflect.TypeOf((*MockmetricsProvider)(nil).ExportPublicKeyTime), value) } // SignCount mocks base method. @@ -678,33 +318,9 @@ func (m *MockmetricsProvider) SignCount() { } // SignCount indicates an expected call of SignCount. -func (mr *MockmetricsProviderMockRecorder) SignCount() *metricsProviderSignCountCall { +func (mr *MockmetricsProviderMockRecorder) SignCount() *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignCount", reflect.TypeOf((*MockmetricsProvider)(nil).SignCount)) - return &metricsProviderSignCountCall{Call: call} -} - -// metricsProviderSignCountCall wrap *gomock.Call -type metricsProviderSignCountCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderSignCountCall) Return() *metricsProviderSignCountCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderSignCountCall) Do(f func()) *metricsProviderSignCountCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderSignCountCall) DoAndReturn(f func()) *metricsProviderSignCountCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignCount", reflect.TypeOf((*MockmetricsProvider)(nil).SignCount)) } // SignTime mocks base method. @@ -714,33 +330,9 @@ func (m *MockmetricsProvider) SignTime(value time.Duration) { } // SignTime indicates an expected call of SignTime. -func (mr *MockmetricsProviderMockRecorder) SignTime(value interface{}) *metricsProviderSignTimeCall { +func (mr *MockmetricsProviderMockRecorder) SignTime(value interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignTime", reflect.TypeOf((*MockmetricsProvider)(nil).SignTime), value) - return &metricsProviderSignTimeCall{Call: call} -} - -// metricsProviderSignTimeCall wrap *gomock.Call -type metricsProviderSignTimeCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderSignTimeCall) Return() *metricsProviderSignTimeCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderSignTimeCall) Do(f func(time.Duration)) *metricsProviderSignTimeCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderSignTimeCall) DoAndReturn(f func(time.Duration)) *metricsProviderSignTimeCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignTime", reflect.TypeOf((*MockmetricsProvider)(nil).SignTime), value) } // VerifyCount mocks base method. @@ -750,33 +342,9 @@ func (m *MockmetricsProvider) VerifyCount() { } // VerifyCount indicates an expected call of VerifyCount. -func (mr *MockmetricsProviderMockRecorder) VerifyCount() *metricsProviderVerifyCountCall { +func (mr *MockmetricsProviderMockRecorder) VerifyCount() *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyCount", reflect.TypeOf((*MockmetricsProvider)(nil).VerifyCount)) - return &metricsProviderVerifyCountCall{Call: call} -} - -// metricsProviderVerifyCountCall wrap *gomock.Call -type metricsProviderVerifyCountCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderVerifyCountCall) Return() *metricsProviderVerifyCountCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderVerifyCountCall) Do(f func()) *metricsProviderVerifyCountCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderVerifyCountCall) DoAndReturn(f func()) *metricsProviderVerifyCountCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyCount", reflect.TypeOf((*MockmetricsProvider)(nil).VerifyCount)) } // VerifyTime mocks base method. @@ -786,31 +354,7 @@ func (m *MockmetricsProvider) VerifyTime(value time.Duration) { } // VerifyTime indicates an expected call of VerifyTime. -func (mr *MockmetricsProviderMockRecorder) VerifyTime(value interface{}) *metricsProviderVerifyTimeCall { +func (mr *MockmetricsProviderMockRecorder) VerifyTime(value interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyTime", reflect.TypeOf((*MockmetricsProvider)(nil).VerifyTime), value) - return &metricsProviderVerifyTimeCall{Call: call} -} - -// metricsProviderVerifyTimeCall wrap *gomock.Call -type metricsProviderVerifyTimeCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *metricsProviderVerifyTimeCall) Return() *metricsProviderVerifyTimeCall { - c.Call = c.Call.Return() - return c -} - -// Do rewrite *gomock.Call.Do -func (c *metricsProviderVerifyTimeCall) Do(f func(time.Duration)) *metricsProviderVerifyTimeCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *metricsProviderVerifyTimeCall) DoAndReturn(f func(time.Duration)) *metricsProviderVerifyTimeCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyTime", reflect.TypeOf((*MockmetricsProvider)(nil).VerifyTime), value) } diff --git a/pkg/kms/mocks/kms_mocks.go b/pkg/kms/mocks/kms_mocks.go index 455d902b3..8ca0def08 100644 --- a/pkg/kms/mocks/kms_mocks.go +++ b/pkg/kms/mocks/kms_mocks.go @@ -48,33 +48,9 @@ func (m *MockVCSKeyManager) CreateCryptoKey(keyType kms.KeyType) (string, interf } // CreateCryptoKey indicates an expected call of CreateCryptoKey. -func (mr *MockVCSKeyManagerMockRecorder) CreateCryptoKey(keyType interface{}) *VCSKeyManagerCreateCryptoKeyCall { +func (mr *MockVCSKeyManagerMockRecorder) CreateCryptoKey(keyType interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCryptoKey", reflect.TypeOf((*MockVCSKeyManager)(nil).CreateCryptoKey), keyType) - return &VCSKeyManagerCreateCryptoKeyCall{Call: call} -} - -// VCSKeyManagerCreateCryptoKeyCall wrap *gomock.Call -type VCSKeyManagerCreateCryptoKeyCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *VCSKeyManagerCreateCryptoKeyCall) Return(arg0 string, arg1 interface{}, arg2 error) *VCSKeyManagerCreateCryptoKeyCall { - c.Call = c.Call.Return(arg0, arg1, arg2) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *VCSKeyManagerCreateCryptoKeyCall) Do(f func(kms.KeyType) (string, interface{}, error)) *VCSKeyManagerCreateCryptoKeyCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *VCSKeyManagerCreateCryptoKeyCall) DoAndReturn(f func(kms.KeyType) (string, interface{}, error)) *VCSKeyManagerCreateCryptoKeyCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCryptoKey", reflect.TypeOf((*MockVCSKeyManager)(nil).CreateCryptoKey), keyType) } // CreateJWKKey mocks base method. @@ -88,33 +64,9 @@ func (m *MockVCSKeyManager) CreateJWKKey(keyType kms.KeyType) (string, *jwk.JWK, } // CreateJWKKey indicates an expected call of CreateJWKKey. -func (mr *MockVCSKeyManagerMockRecorder) CreateJWKKey(keyType interface{}) *VCSKeyManagerCreateJWKKeyCall { +func (mr *MockVCSKeyManagerMockRecorder) CreateJWKKey(keyType interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateJWKKey", reflect.TypeOf((*MockVCSKeyManager)(nil).CreateJWKKey), keyType) - return &VCSKeyManagerCreateJWKKeyCall{Call: call} -} - -// VCSKeyManagerCreateJWKKeyCall wrap *gomock.Call -type VCSKeyManagerCreateJWKKeyCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *VCSKeyManagerCreateJWKKeyCall) Return(arg0 string, arg1 *jwk.JWK, arg2 error) *VCSKeyManagerCreateJWKKeyCall { - c.Call = c.Call.Return(arg0, arg1, arg2) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *VCSKeyManagerCreateJWKKeyCall) Do(f func(kms.KeyType) (string, *jwk.JWK, error)) *VCSKeyManagerCreateJWKKeyCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *VCSKeyManagerCreateJWKKeyCall) DoAndReturn(f func(kms.KeyType) (string, *jwk.JWK, error)) *VCSKeyManagerCreateJWKKeyCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateJWKKey", reflect.TypeOf((*MockVCSKeyManager)(nil).CreateJWKKey), keyType) } // NewVCSigner mocks base method. @@ -127,33 +79,9 @@ func (m *MockVCSKeyManager) NewVCSigner(creator string, signatureType verifiable } // NewVCSigner indicates an expected call of NewVCSigner. -func (mr *MockVCSKeyManagerMockRecorder) NewVCSigner(creator, signatureType interface{}) *VCSKeyManagerNewVCSignerCall { +func (mr *MockVCSKeyManagerMockRecorder) NewVCSigner(creator, signatureType interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewVCSigner", reflect.TypeOf((*MockVCSKeyManager)(nil).NewVCSigner), creator, signatureType) - return &VCSKeyManagerNewVCSignerCall{Call: call} -} - -// VCSKeyManagerNewVCSignerCall wrap *gomock.Call -type VCSKeyManagerNewVCSignerCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *VCSKeyManagerNewVCSignerCall) Return(arg0 vc.SignerAlgorithm, arg1 error) *VCSKeyManagerNewVCSignerCall { - c.Call = c.Call.Return(arg0, arg1) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *VCSKeyManagerNewVCSignerCall) Do(f func(string, verifiable.SignatureType) (vc.SignerAlgorithm, error)) *VCSKeyManagerNewVCSignerCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *VCSKeyManagerNewVCSignerCall) DoAndReturn(f func(string, verifiable.SignatureType) (vc.SignerAlgorithm, error)) *VCSKeyManagerNewVCSignerCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewVCSigner", reflect.TypeOf((*MockVCSKeyManager)(nil).NewVCSigner), creator, signatureType) } // SupportedKeyTypes mocks base method. @@ -165,31 +93,7 @@ func (m *MockVCSKeyManager) SupportedKeyTypes() []kms.KeyType { } // SupportedKeyTypes indicates an expected call of SupportedKeyTypes. -func (mr *MockVCSKeyManagerMockRecorder) SupportedKeyTypes() *VCSKeyManagerSupportedKeyTypesCall { +func (mr *MockVCSKeyManagerMockRecorder) SupportedKeyTypes() *gomock.Call { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SupportedKeyTypes", reflect.TypeOf((*MockVCSKeyManager)(nil).SupportedKeyTypes)) - return &VCSKeyManagerSupportedKeyTypesCall{Call: call} -} - -// VCSKeyManagerSupportedKeyTypesCall wrap *gomock.Call -type VCSKeyManagerSupportedKeyTypesCall struct { - *gomock.Call -} - -// Return rewrite *gomock.Call.Return -func (c *VCSKeyManagerSupportedKeyTypesCall) Return(arg0 []kms.KeyType) *VCSKeyManagerSupportedKeyTypesCall { - c.Call = c.Call.Return(arg0) - return c -} - -// Do rewrite *gomock.Call.Do -func (c *VCSKeyManagerSupportedKeyTypesCall) Do(f func() []kms.KeyType) *VCSKeyManagerSupportedKeyTypesCall { - c.Call = c.Call.Do(f) - return c -} - -// DoAndReturn rewrite *gomock.Call.DoAndReturn -func (c *VCSKeyManagerSupportedKeyTypesCall) DoAndReturn(f func() []kms.KeyType) *VCSKeyManagerSupportedKeyTypesCall { - c.Call = c.Call.DoAndReturn(f) - return c + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SupportedKeyTypes", reflect.TypeOf((*MockVCSKeyManager)(nil).SupportedKeyTypes)) } diff --git a/pkg/service/issuecredential/issuecredential_service.go b/pkg/service/issuecredential/issuecredential_service.go index e7cab065a..b8a49e957 100644 --- a/pkg/service/issuecredential/issuecredential_service.go +++ b/pkg/service/issuecredential/issuecredential_service.go @@ -10,11 +10,11 @@ package issuecredential import ( "context" + "encoding/json" "fmt" "github.com/samber/lo" "github.com/trustbloc/vc-go/verifiable" - "github.com/trustbloc/vcs/pkg/doc/vc" "github.com/trustbloc/vcs/pkg/doc/vc/crypto" "github.com/trustbloc/vcs/pkg/doc/vc/vcutil" @@ -165,6 +165,11 @@ func (s *Service) IssueCredential( return nil, fmt.Errorf("sign credential: %w", err) } + vcBytes, _ := json.Marshal(signedVC) + fmt.Println("----------------- Signed VC -----------------") + fmt.Println(string(vcBytes)) + fmt.Println("--------------------------------------------------") + credentialMetadata := &credentialstatus.CredentialMetadata{ CredentialID: credential.Contents().ID, Issuer: credential.Contents().Issuer.ID, diff --git a/test/bdd/fixtures/profile/profiles.json b/test/bdd/fixtures/profile/profiles.json index 25d1ef3b7..05c2d06e2 100644 --- a/test/bdd/fixtures/profile/profiles.json +++ b/test/bdd/fixtures/profile/profiles.json @@ -943,7 +943,7 @@ "format": "jwt", "didMethod": "ion", "status": { - "type": "StatusList2021Entry" + "type": "BitstringStatusListEntry" } }, "oidcConfig": { @@ -1889,7 +1889,7 @@ "format": "jwt", "didMethod": "ion", "status": { - "type": "StatusList2021Entry" + "type": "BitstringStatusListEntry" }, "sdjwt": { "enable": true,