vcr

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2022 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Package vcr is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestVCRInstance

func NewTestVCRInstance(t *testing.T) *vcr

NewTestVCRInstance returns a new vcr instance to be used for integration tests. Any data is stored in the specified test directory.

Types

type Ambassador

type Ambassador interface {
	// Configure instructs the ambassador to start receiving DID Documents from the network.
	Configure()
}

Ambassador registers a callback with the network for processing received Verifiable Credentials.

func NewAmbassador

func NewAmbassador(networkClient network.Transactions, writer Writer, verifier verifier.Verifier) Ambassador

NewAmbassador creates a new listener for the network that listens to Verifiable Credential transactions.

type ConceptFinder

type ConceptFinder interface {
	// Get returns the requested concept as concept.Concept for the subject or ErrNotFound
	// It also returns untrusted credentials when allowUntrusted == true
	Get(conceptName string, allowUntrusted bool, subject string) (concept.Concept, error)

	// SearchConcept returns matching concepts based upon a query. It returns an empty list if no matches have been found.
	// It also returns untrusted credentials when allowUntrusted == true
	// a context must be passed to prevent long-running queries
	SearchConcept(ctx context.Context, conceptName string, allowUntrusted bool, query map[string]string) ([]concept.Concept, error)
}

ConceptFinder can resolve VC backed concepts for a DID.

type Config

type Config struct {

	// OverrideAllPublic overrides the "Public" property of a credential when issuing credentials:
	// if set to true, all issued credentials are published as public credentials, regardless of whether they're actually marked as public.
	OverrideIssueAllPublic bool `koanf:"vcr.overrideissueallpublic"`
	// contains filtered or unexported fields
}

Config holds the config for the vcr engine

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a fresh Config filled with default values

type Finder

type Finder interface {
	// Search for matching VCs based upon a query. It returns an empty list if no matches have been found.
	// It also returns untrusted credentials when allowUntrusted == true
	// a context must be passed to prevent long-running queries
	Search(ctx context.Context, query concept.Query, allowUntrusted bool, resolveTime *time.Time) ([]vc.VerifiableCredential, error)
}

Finder is the VCR interface for searching VCs

type MockConceptFinder

type MockConceptFinder struct {
	// contains filtered or unexported fields
}

MockConceptFinder is a mock of ConceptFinder interface.

func NewMockConceptFinder

func NewMockConceptFinder(ctrl *gomock.Controller) *MockConceptFinder

NewMockConceptFinder creates a new mock instance.

func (*MockConceptFinder) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockConceptFinder) Get

func (m *MockConceptFinder) Get(conceptName string, allowUntrusted bool, subject string) (concept.Concept, error)

Get mocks base method.

func (*MockConceptFinder) SearchConcept

func (m *MockConceptFinder) SearchConcept(ctx context.Context, conceptName string, allowUntrusted bool, query map[string]string) ([]concept.Concept, error)

SearchConcept mocks base method.

type MockConceptFinderMockRecorder

type MockConceptFinderMockRecorder struct {
	// contains filtered or unexported fields
}

MockConceptFinderMockRecorder is the mock recorder for MockConceptFinder.

func (*MockConceptFinderMockRecorder) Get

func (mr *MockConceptFinderMockRecorder) Get(conceptName, allowUntrusted, subject interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockConceptFinderMockRecorder) SearchConcept

func (mr *MockConceptFinderMockRecorder) SearchConcept(ctx, conceptName, allowUntrusted, query interface{}) *gomock.Call

SearchConcept indicates an expected call of SearchConcept.

type MockFinder

type MockFinder struct {
	// contains filtered or unexported fields
}

MockFinder is a mock of Finder interface.

func NewMockFinder

func NewMockFinder(ctrl *gomock.Controller) *MockFinder

NewMockFinder creates a new mock instance.

func (*MockFinder) EXPECT

func (m *MockFinder) EXPECT() *MockFinderMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockFinder) Search

func (m *MockFinder) Search(ctx context.Context, query concept.Query, allowUntrusted bool, resolveTime *time.Time) ([]vc.VerifiableCredential, error)

Search mocks base method.

type MockFinderMockRecorder

type MockFinderMockRecorder struct {
	// contains filtered or unexported fields
}

MockFinderMockRecorder is the mock recorder for MockFinder.

func (*MockFinderMockRecorder) Search

func (mr *MockFinderMockRecorder) Search(ctx, query, allowUntrusted, resolveTime interface{}) *gomock.Call

Search indicates an expected call of Search.

type MockResolver

type MockResolver struct {
	// contains filtered or unexported fields
}

MockResolver is a mock of Resolver interface.

func NewMockResolver

func NewMockResolver(ctrl *gomock.Controller) *MockResolver

NewMockResolver creates a new mock instance.

func (*MockResolver) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockResolver) Registry

func (m *MockResolver) Registry() concept.Reader

Registry mocks base method.

func (*MockResolver) Resolve

func (m *MockResolver) Resolve(ID ssi.URI, resolveTime *time.Time) (*vc.VerifiableCredential, error)

Resolve mocks base method.

type MockResolverMockRecorder

type MockResolverMockRecorder struct {
	// contains filtered or unexported fields
}

MockResolverMockRecorder is the mock recorder for MockResolver.

func (*MockResolverMockRecorder) Registry

func (mr *MockResolverMockRecorder) Registry() *gomock.Call

Registry indicates an expected call of Registry.

func (*MockResolverMockRecorder) Resolve

func (mr *MockResolverMockRecorder) Resolve(ID, resolveTime interface{}) *gomock.Call

Resolve indicates an expected call of Resolve.

type MockTrustManager

type MockTrustManager struct {
	// contains filtered or unexported fields
}

MockTrustManager is a mock of TrustManager interface.

func NewMockTrustManager

func NewMockTrustManager(ctrl *gomock.Controller) *MockTrustManager

NewMockTrustManager creates a new mock instance.

func (*MockTrustManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTrustManager) Trust

func (m *MockTrustManager) Trust(credentialType, issuer ssi.URI) error

Trust mocks base method.

func (*MockTrustManager) Trusted

func (m *MockTrustManager) Trusted(credentialType ssi.URI) ([]ssi.URI, error)

Trusted mocks base method.

func (*MockTrustManager) Untrust

func (m *MockTrustManager) Untrust(credentialType, issuer ssi.URI) error

Untrust mocks base method.

func (*MockTrustManager) Untrusted

func (m *MockTrustManager) Untrusted(credentialType ssi.URI) ([]ssi.URI, error)

Untrusted mocks base method.

type MockTrustManagerMockRecorder

type MockTrustManagerMockRecorder struct {
	// contains filtered or unexported fields
}

MockTrustManagerMockRecorder is the mock recorder for MockTrustManager.

func (*MockTrustManagerMockRecorder) Trust

func (mr *MockTrustManagerMockRecorder) Trust(credentialType, issuer interface{}) *gomock.Call

Trust indicates an expected call of Trust.

func (*MockTrustManagerMockRecorder) Trusted

func (mr *MockTrustManagerMockRecorder) Trusted(credentialType interface{}) *gomock.Call

Trusted indicates an expected call of Trusted.

func (*MockTrustManagerMockRecorder) Untrust

func (mr *MockTrustManagerMockRecorder) Untrust(credentialType, issuer interface{}) *gomock.Call

Untrust indicates an expected call of Untrust.

func (*MockTrustManagerMockRecorder) Untrusted

func (mr *MockTrustManagerMockRecorder) Untrusted(credentialType interface{}) *gomock.Call

Untrusted indicates an expected call of Untrusted.

type MockVCR

type MockVCR struct {
	// contains filtered or unexported fields
}

MockVCR is a mock of VCR interface.

func NewMockVCR

func NewMockVCR(ctrl *gomock.Controller) *MockVCR

NewMockVCR creates a new mock instance.

func (*MockVCR) EXPECT

func (m *MockVCR) EXPECT() *MockVCRMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockVCR) Get

func (m *MockVCR) Get(conceptName string, allowUntrusted bool, subject string) (concept.Concept, error)

Get mocks base method.

func (*MockVCR) Holder

func (m *MockVCR) Holder() holder.Holder

Holder mocks base method.

func (*MockVCR) Issue

func (m *MockVCR) Issue(vcToIssue vc.VerifiableCredential) (*vc.VerifiableCredential, error)

Issue mocks base method.

func (*MockVCR) Issuer

func (m *MockVCR) Issuer() issuer.Issuer

Issuer mocks base method.

func (*MockVCR) Registry

func (m *MockVCR) Registry() concept.Reader

Registry mocks base method.

func (*MockVCR) Resolve

func (m *MockVCR) Resolve(ID ssi.URI, resolveTime *time.Time) (*vc.VerifiableCredential, error)

Resolve mocks base method.

func (*MockVCR) Revoke

func (m *MockVCR) Revoke(ID ssi.URI) (*credential.Revocation, error)

Revoke mocks base method.

func (*MockVCR) Search

func (m *MockVCR) Search(ctx context.Context, query concept.Query, allowUntrusted bool, resolveTime *time.Time) ([]vc.VerifiableCredential, error)

Search mocks base method.

func (*MockVCR) SearchConcept

func (m *MockVCR) SearchConcept(ctx context.Context, conceptName string, allowUntrusted bool, query map[string]string) ([]concept.Concept, error)

SearchConcept mocks base method.

func (*MockVCR) StoreCredential

func (m *MockVCR) StoreCredential(vc vc.VerifiableCredential, validAt *time.Time) error

StoreCredential mocks base method.

func (*MockVCR) StoreRevocation

func (m *MockVCR) StoreRevocation(r credential.Revocation) error

StoreRevocation mocks base method.

func (*MockVCR) Trust

func (m *MockVCR) Trust(credentialType, issuer ssi.URI) error

Trust mocks base method.

func (*MockVCR) Trusted

func (m *MockVCR) Trusted(credentialType ssi.URI) ([]ssi.URI, error)

Trusted mocks base method.

func (*MockVCR) Untrust

func (m *MockVCR) Untrust(credentialType, issuer ssi.URI) error

Untrust mocks base method.

func (*MockVCR) Untrusted

func (m *MockVCR) Untrusted(credentialType ssi.URI) ([]ssi.URI, error)

Untrusted mocks base method.

func (*MockVCR) Validate

func (m *MockVCR) Validate(credential vc.VerifiableCredential, allowUntrusted, checkSignature bool, validAt *time.Time) error

Validate mocks base method.

func (*MockVCR) Verifier

func (m *MockVCR) Verifier() verifier.Verifier

Verifier mocks base method.

type MockVCRMockRecorder

type MockVCRMockRecorder struct {
	// contains filtered or unexported fields
}

MockVCRMockRecorder is the mock recorder for MockVCR.

func (*MockVCRMockRecorder) Get

func (mr *MockVCRMockRecorder) Get(conceptName, allowUntrusted, subject interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockVCRMockRecorder) Holder

func (mr *MockVCRMockRecorder) Holder() *gomock.Call

Holder indicates an expected call of Holder.

func (*MockVCRMockRecorder) Issue

func (mr *MockVCRMockRecorder) Issue(vcToIssue interface{}) *gomock.Call

Issue indicates an expected call of Issue.

func (*MockVCRMockRecorder) Issuer

func (mr *MockVCRMockRecorder) Issuer() *gomock.Call

Issuer indicates an expected call of Issuer.

func (*MockVCRMockRecorder) Registry

func (mr *MockVCRMockRecorder) Registry() *gomock.Call

Registry indicates an expected call of Registry.

func (*MockVCRMockRecorder) Resolve

func (mr *MockVCRMockRecorder) Resolve(ID, resolveTime interface{}) *gomock.Call

Resolve indicates an expected call of Resolve.

func (*MockVCRMockRecorder) Revoke

func (mr *MockVCRMockRecorder) Revoke(ID interface{}) *gomock.Call

Revoke indicates an expected call of Revoke.

func (*MockVCRMockRecorder) Search

func (mr *MockVCRMockRecorder) Search(ctx, query, allowUntrusted, resolveTime interface{}) *gomock.Call

Search indicates an expected call of Search.

func (*MockVCRMockRecorder) SearchConcept

func (mr *MockVCRMockRecorder) SearchConcept(ctx, conceptName, allowUntrusted, query interface{}) *gomock.Call

SearchConcept indicates an expected call of SearchConcept.

func (*MockVCRMockRecorder) StoreCredential

func (mr *MockVCRMockRecorder) StoreCredential(vc, validAt interface{}) *gomock.Call

StoreCredential indicates an expected call of StoreCredential.

func (*MockVCRMockRecorder) StoreRevocation

func (mr *MockVCRMockRecorder) StoreRevocation(r interface{}) *gomock.Call

StoreRevocation indicates an expected call of StoreRevocation.

func (*MockVCRMockRecorder) Trust

func (mr *MockVCRMockRecorder) Trust(credentialType, issuer interface{}) *gomock.Call

Trust indicates an expected call of Trust.

func (*MockVCRMockRecorder) Trusted

func (mr *MockVCRMockRecorder) Trusted(credentialType interface{}) *gomock.Call

Trusted indicates an expected call of Trusted.

func (*MockVCRMockRecorder) Untrust

func (mr *MockVCRMockRecorder) Untrust(credentialType, issuer interface{}) *gomock.Call

Untrust indicates an expected call of Untrust.

func (*MockVCRMockRecorder) Untrusted

func (mr *MockVCRMockRecorder) Untrusted(credentialType interface{}) *gomock.Call

Untrusted indicates an expected call of Untrusted.

func (*MockVCRMockRecorder) Validate

func (mr *MockVCRMockRecorder) Validate(credential, allowUntrusted, checkSignature, validAt interface{}) *gomock.Call

Validate indicates an expected call of Validate.

func (*MockVCRMockRecorder) Verifier

func (mr *MockVCRMockRecorder) Verifier() *gomock.Call

Verifier indicates an expected call of Verifier.

type MockValidator

type MockValidator struct {
	// contains filtered or unexported fields
}

MockValidator is a mock of Validator interface.

func NewMockValidator

func NewMockValidator(ctrl *gomock.Controller) *MockValidator

NewMockValidator creates a new mock instance.

func (*MockValidator) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockValidator) Validate

func (m *MockValidator) Validate(credential vc.VerifiableCredential, allowUntrusted, checkSignature bool, validAt *time.Time) error

Validate mocks base method.

type MockValidatorMockRecorder

type MockValidatorMockRecorder struct {
	// contains filtered or unexported fields
}

MockValidatorMockRecorder is the mock recorder for MockValidator.

func (*MockValidatorMockRecorder) Validate

func (mr *MockValidatorMockRecorder) Validate(credential, allowUntrusted, checkSignature, validAt interface{}) *gomock.Call

Validate indicates an expected call of Validate.

type MockWriter

type MockWriter struct {
	// contains filtered or unexported fields
}

MockWriter is a mock of Writer interface.

func NewMockWriter

func NewMockWriter(ctrl *gomock.Controller) *MockWriter

NewMockWriter creates a new mock instance.

func (*MockWriter) EXPECT

func (m *MockWriter) EXPECT() *MockWriterMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockWriter) StoreCredential

func (m *MockWriter) StoreCredential(vc vc.VerifiableCredential, validAt *time.Time) error

StoreCredential mocks base method.

func (*MockWriter) StoreRevocation

func (m *MockWriter) StoreRevocation(r credential.Revocation) error

StoreRevocation mocks base method.

type MockWriterMockRecorder

type MockWriterMockRecorder struct {
	// contains filtered or unexported fields
}

MockWriterMockRecorder is the mock recorder for MockWriter.

func (*MockWriterMockRecorder) StoreCredential

func (mr *MockWriterMockRecorder) StoreCredential(vc, validAt interface{}) *gomock.Call

StoreCredential indicates an expected call of StoreCredential.

func (*MockWriterMockRecorder) StoreRevocation

func (mr *MockWriterMockRecorder) StoreRevocation(r interface{}) *gomock.Call

StoreRevocation indicates an expected call of StoreRevocation.

type Resolver

type Resolver interface {
	// Registry returns the concept registry as read-only
	Registry() concept.Reader
	// Resolve returns a credential based on its ID.
	// The optional resolveTime will resolve the credential at that point in time.
	// The credential will still be returned in the case of ErrRevoked and ErrUntrusted.
	// For other errors, nil is returned
	Resolve(ID ssi.URI, resolveTime *time.Time) (*vc.VerifiableCredential, error)
}

Resolver binds all read type of operations into an interface

type TrustManager

type TrustManager interface {
	// Trust adds trust for a Issuer/CredentialType combination.
	Trust(credentialType ssi.URI, issuer ssi.URI) error
	// Untrust removes trust for a Issuer/CredentialType combination.
	Untrust(credentialType ssi.URI, issuer ssi.URI) error
	// Trusted returns a list of trusted issuers for given credentialType
	Trusted(credentialType ssi.URI) ([]ssi.URI, error)
	// Untrusted returns a list of untrusted issuers based on known credentials
	Untrusted(credentialType ssi.URI) ([]ssi.URI, error)
}

TrustManager bundles all trust related methods in one interface

type VCR

type VCR interface {
	Issuer() issuer.Issuer
	Holder() holder.Holder
	Verifier() verifier.Verifier

	// Issue creates and publishes a new VC.
	// An optional expirationDate can be given.
	// VCs are stored when the network has successfully published them.
	Issue(vcToIssue vc.VerifiableCredential) (*vc.VerifiableCredential, error)
	// Revoke a credential based on its ID, the Issuer will be resolved automatically.
	// The statusDate will be set to the current time.
	// It returns an error if the credential, issuer or private key can not be found.
	Revoke(ID ssi.URI) (*credential.Revocation, error)

	Finder
	ConceptFinder
	Resolver
	TrustManager
	Validator
	Writer
}

VCR is the interface that covers all functionality of the vcr store.

func NewVCRInstance

func NewVCRInstance(keyStore crypto.KeyStore, docResolver vdr.DocResolver, keyResolver vdr.KeyResolver, network network.Transactions) VCR

NewVCRInstance creates a new vcr instance with default config and empty concept registry

type Validator

type Validator interface {
	// Validate checks if the given credential:
	// - is not revoked
	// - is valid at the given time (or now if not give)
	// - has a valid issuer
	// - has a valid signature if checkSignature is true
	// if allowUntrusted == false, the issuer must also be a trusted DID
	// May return ErrRevoked, ErrUntrusted or ErrInvalidPeriod
	Validate(credential vc.VerifiableCredential, allowUntrusted bool, checkSignature bool, validAt *time.Time) error
}

Validator is the VCR interface for validation options

type Writer

type Writer interface {
	// StoreCredential writes a VC to storage. Before writing, it calls Verify!
	// It can handle duplicates.
	StoreCredential(vc vc.VerifiableCredential, validAt *time.Time) error
	// StoreRevocation writes a revocation to storage.
	StoreRevocation(r credential.Revocation) error
}

Writer is the interface that groups al the VC write methods

Directories

Path Synopsis
api
v1
Package v1 provides primitives to interact with the openapi HTTP API.
Package v1 provides primitives to interact with the openapi HTTP API.
v2
Package v2 provides primitives to interact with the openapi HTTP API.
Package v2 provides primitives to interact with the openapi HTTP API.
Package concept is a generated GoMock package.
Package concept is a generated GoMock package.
Package holder is a generated GoMock package.
Package holder is a generated GoMock package.
Package issuer is a generated GoMock package.
Package issuer is a generated GoMock package.
pe
schema Module
Package signature is a generated GoMock package.
Package signature is a generated GoMock package.
Package verifier is a generated GoMock package.
Package verifier is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL