diff --git a/embedded/sql/type_conversion.go b/embedded/sql/type_conversion.go index 5c390b9872..161385080a 100644 --- a/embedded/sql/type_conversion.go +++ b/embedded/sql/type_conversion.go @@ -62,7 +62,10 @@ func getConverter(src, dst SQLValueType) (converterFunc, error) { str := val.RawValue().(string) var supportedTimeFormats = []string{ + "2006-01-02 15:04:05 MST", + "2006-01-02 15:04:05 -0700", "2006-01-02 15:04:05.999999", + "2006-01-02 15:04:05", "2006-01-02 15:04", "2006-01-02", } diff --git a/pkg/client/client.go b/pkg/client/client.go index 6847aa4d4f..e31c91160a 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -342,6 +342,12 @@ type ImmuClient interface { // If verification does not succeed the store.ErrCorruptedData error is returned. VerifiedGetAtRevision(ctx context.Context, key []byte, rev int64) (*schema.Entry, error) + // VerifiableGet reads value for a given key, and returs internal data used to perform + // the verification. + // + // You can use this function if you want to have visibility on the verification data + VerifiableGet(ctx context.Context, in *schema.VerifiableGetRequest, opts ...grpc.CallOption) (*schema.VerifiableEntry, error) + // History returns history for a single key. History(ctx context.Context, req *schema.HistoryRequest) (*schema.Entries, error) @@ -2311,3 +2317,10 @@ func (c *immuClient) TruncateDatabase(ctx context.Context, db string, retentionP return err } + +// VerifiableGet +func (c *immuClient) VerifiableGet(ctx context.Context, in *schema.VerifiableGetRequest, opts ...grpc.CallOption) (*schema.VerifiableEntry, error) { + result, err := c.ServiceClient.VerifiableGet(ctx, in, opts...) + + return result, err +} diff --git a/pkg/client/clienttest/immuclient_mock.go b/pkg/client/clienttest/immuclient_mock.go index 24df5edf88..24a18ee80c 100644 --- a/pkg/client/clienttest/immuclient_mock.go +++ b/pkg/client/clienttest/immuclient_mock.go @@ -46,6 +46,7 @@ type ImmuClientMock struct { VerifiedGetF func(context.Context, []byte, ...client.GetOption) (*schema.Entry, error) VerifiedGetAtF func(context.Context, []byte, uint64) (*schema.Entry, error) VerifiedSetF func(context.Context, []byte, []byte) (*schema.TxHeader, error) + VerifiableGetF func(context.Context, *schema.VerifiableGetRequest, ...grpc.CallOption) (*schema.VerifiableEntry, error) SetF func(context.Context, []byte, []byte) (*schema.TxHeader, error) SetAllF func(context.Context, *schema.SetRequest) (*schema.TxHeader, error) SetReferenceF func(context.Context, []byte, []byte, uint64) (*schema.TxHeader, error) @@ -129,6 +130,11 @@ func (icm *ImmuClientMock) VerifiedSet(ctx context.Context, key []byte, value [] return icm.VerifiedSetF(ctx, key, value) } +// VerifiedSet ... +func (icm *ImmuClientMock) VerifiableGet(ctx context.Context, in *schema.VerifiableGetRequest, opts ...grpc.CallOption) (*schema.VerifiableEntry, error) { + return icm.VerifiableGetF(ctx, in, opts...) +} + // Set ... func (icm *ImmuClientMock) Set(ctx context.Context, key []byte, value []byte) (*schema.TxHeader, error) { return icm.SetF(ctx, key, value) diff --git a/pkg/client/clienttest/immuclient_mock_test.go b/pkg/client/clienttest/immuclient_mock_test.go index e9fb41fd8d..e46edeb2de 100644 --- a/pkg/client/clienttest/immuclient_mock_test.go +++ b/pkg/client/clienttest/immuclient_mock_test.go @@ -35,6 +35,7 @@ func TestImmuClientMock(t *testing.T) { errLogout := errors.New("LogoutF got called") errVerifiedGet := errors.New("VerifiedGetF got called") errVerifiedSet := errors.New("VerifiedSetF got called") + errVerifiableGet := errors.New("VerifiableGetF got called") errSet := errors.New("SetF got called") errVerifiedReference := errors.New("VerifiedReferenceF got called") errVerifiedZAdd := errors.New("VerifiedZAddF got called") @@ -66,6 +67,9 @@ func TestImmuClientMock(t *testing.T) { VerifiedSetF: func(context.Context, []byte, []byte) (*schema.TxHeader, error) { return nil, errVerifiedSet }, + VerifiableGetF: func(ctx context.Context, in *schema.VerifiableGetRequest, opts ...grpc.CallOption) (*schema.VerifiableEntry, error) { + return nil, errVerifiableGet + }, SetF: func(context.Context, []byte, []byte) (*schema.TxHeader, error) { return nil, errSet }, @@ -107,6 +111,9 @@ func TestImmuClientMock(t *testing.T) { _, err = icm.VerifiedSet(context.Background(), nil, nil) require.ErrorIs(t, err, errVerifiedSet) + _, err = icm.VerifiableGet(context.Background(), nil, nil) + require.ErrorIs(t, err, errVerifiableGet) + _, err = icm.Set(context.Background(), nil, nil) require.ErrorIs(t, err, errSet)