Skip to content

Commit

Permalink
tests pass!
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx committed May 20, 2024
1 parent 20fcd91 commit d6a5aee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
21 changes: 11 additions & 10 deletions pkg/mls/api/v1/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ func (m *mockedMLSValidationService) ValidateV3KeyPackages(ctx context.Context,
}

func (m *mockedMLSValidationService) ValidateInboxIdKeyPackages(ctx context.Context, keyPackages [][]byte) ([]mlsvalidate.InboxIdValidationResult, error) {
args := m.Called(ctx, keyPackages)

response := args.Get(0)
if response == nil {
return nil, args.Error(1)
}

return response.([]mlsvalidate.InboxIdValidationResult), args.Error(1)
return nil, nil
}

func (m *mockedMLSValidationService) ValidateGroupMessages(ctx context.Context, groupMessages []*mlsv1.GroupMessageInput) ([]mlsvalidate.GroupMessageValidationResult, error) {
Expand All @@ -65,7 +58,7 @@ func newMockedValidationService() *mockedMLSValidationService {
}

func (m *mockedMLSValidationService) mockValidateKeyPackages(installationId []byte, accountAddress string) *mock.Call {
return m.On("ValidateKeyPackages", mock.Anything, mock.Anything).Return([]mlsvalidate.IdentityValidationResult{
return m.On("ValidateV3KeyPackages", mock.Anything, mock.Anything).Return([]mlsvalidate.IdentityValidationResult{
{
InstallationKey: installationId,
AccountAddress: accountAddress,
Expand Down Expand Up @@ -127,6 +120,7 @@ func TestRegisterInstallation(t *testing.T) {
KeyPackage: &mlsv1.KeyPackageUpload{
KeyPackageTlsSerialized: []byte("test"),
},
IsInboxIdCredential: false,
})

require.NoError(t, err)
Expand All @@ -143,12 +137,13 @@ func TestRegisterInstallationError(t *testing.T) {
svc, _, mlsValidationService, cleanup := newTestService(t, ctx)
defer cleanup()

mlsValidationService.On("ValidateKeyPackages", ctx, mock.Anything).Return(nil, errors.New("error validating"))
mlsValidationService.On("ValidateV3KeyPackages", ctx, mock.Anything).Return(nil, errors.New("error validating"))

res, err := svc.RegisterInstallation(ctx, &mlsv1.RegisterInstallationRequest{
KeyPackage: &mlsv1.KeyPackageUpload{
KeyPackageTlsSerialized: []byte("test"),
},
IsInboxIdCredential: false,
})
require.Error(t, err)
require.Nil(t, res)
Expand All @@ -168,6 +163,7 @@ func TestUploadKeyPackage(t *testing.T) {
KeyPackage: &mlsv1.KeyPackageUpload{
KeyPackageTlsSerialized: []byte("test"),
},
IsInboxIdCredential: false,
})
require.NoError(t, err)
require.NotNil(t, res)
Expand All @@ -176,6 +172,7 @@ func TestUploadKeyPackage(t *testing.T) {
KeyPackage: &mlsv1.KeyPackageUpload{
KeyPackageTlsSerialized: []byte("test2"),
},
IsInboxIdCredential: false,
})
require.NoError(t, err)
require.NotNil(t, uploadRes)
Expand All @@ -199,6 +196,7 @@ func TestFetchKeyPackages(t *testing.T) {
KeyPackage: &mlsv1.KeyPackageUpload{
KeyPackageTlsSerialized: []byte("test"),
},
IsInboxIdCredential: false,
})
require.NoError(t, err)
require.NotNil(t, res)
Expand All @@ -214,6 +212,7 @@ func TestFetchKeyPackages(t *testing.T) {
KeyPackage: &mlsv1.KeyPackageUpload{
KeyPackageTlsSerialized: []byte("test2"),
},
IsInboxIdCredential: false,
})
require.NoError(t, err)
require.NotNil(t, res)
Expand Down Expand Up @@ -328,6 +327,7 @@ func TestGetIdentityUpdates(t *testing.T) {
KeyPackage: &mlsv1.KeyPackageUpload{
KeyPackageTlsSerialized: []byte("test"),
},
IsInboxIdCredential: false,
})
require.NoError(t, err)

Expand All @@ -352,6 +352,7 @@ func TestGetIdentityUpdates(t *testing.T) {
KeyPackage: &mlsv1.KeyPackageUpload{
KeyPackageTlsSerialized: []byte("test"),
},
IsInboxIdCredential: false,
})
require.NoError(t, err)

Expand Down
6 changes: 0 additions & 6 deletions pkg/mlsvalidate/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ type InboxIdValidationResult struct {
Expiration uint64
}

type ValidationResult struct {
isInboxIdCredential bool
InboxIdResult *[]InboxIdValidationResult
V3Result *[]IdentityValidationResult
}

type GroupMessageValidationResult struct {
GroupId string
}
Expand Down

0 comments on commit d6a5aee

Please sign in to comment.