Skip to content

Commit

Permalink
rpc: fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav committed Apr 24, 2024
1 parent d836b02 commit 09fccd6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions rpc/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 09fccd6

Please sign in to comment.