From 09fccd67eced77339418a94a1565950de860200e Mon Sep 17 00:00:00 2001 From: Patryk Kalinowski Date: Wed, 24 Apr 2024 22:43:25 +0200 Subject: [PATCH] rpc: fix the tests --- rpc/helpers_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/rpc/helpers_test.go b/rpc/helpers_test.go index bfe137bc..00b63792 100644 --- a/rpc/helpers_test.go +++ b/rpc/helpers_test.go @@ -421,6 +421,27 @@ func (d *dbMock) Query(ctx context.Context, params *dynamodb.QueryInput, optFns } out := &dynamodb.QueryOutput{Items: []map[string]dynamodbtypes.AttributeValue{item}} return out, nil + case "Accounts": + pseParam, ok := params.ExpressionAttributeValues[":pse"] + if !ok { + return nil, fmt.Errorf("must include a :pse expression attribute") + } + pseParts := strings.Split(pseParam.(*dynamodbtypes.AttributeValueMemberS).Value, "|") + projectID, _ := strconv.Atoi(pseParts[0]) + email := pseParts[1] + + projectAccounts := d.accounts[uint64(projectID)] + out := &dynamodb.QueryOutput{Items: []map[string]dynamodbtypes.AttributeValue{}} + for _, acc := range projectAccounts { + if acc.Email == email { + item, err := attributevalue.MarshalMap(acc) + if err != nil { + return nil, err + } + out.Items = append(out.Items, item) + } + } + return out, nil } return nil, fmt.Errorf("invalid TableName: %q", *params.TableName) @@ -483,6 +504,11 @@ func newAccount(t *testing.T, enc *enclave.Enclave, issuer string, wallet *ethwa att, err := enc.GetAttestation(context.Background(), nil) require.NoError(t, err) + if wallet == nil { + wallet, err = ethwallet.NewWalletFromRandomEntropy() + require.NoError(t, err) + } + identity := proto.Identity{ Type: proto.IdentityType_OIDC, Issuer: issuer, @@ -566,6 +592,16 @@ type walletServiceMock struct { registeredSessions map[string]struct{} } +func (w walletServiceMock) FederateAccount(ctx context.Context, userID string, intent *proto_wallet.Intent) (*proto_wallet.IntentResponse, error) { + //TODO implement me + panic("implement me") +} + +func (w walletServiceMock) RemoveAccount(ctx context.Context, intent *proto_wallet.Intent) (*proto_wallet.IntentResponse, error) { + //TODO implement me + panic("implement me") +} + func (w walletServiceMock) ProjectParentWalletStatus(ctx context.Context, projectID uint64) ([]*proto_wallet.ParentWalletStatus, error) { //TODO implement me panic("implement me")