github.com/trustbloc/kms-go@v1.1.2/wrapper/localsuite/localsuite_test.go (about)

     1  /*
     2  Copyright Gen Digital Inc. All Rights Reserved.
     3  SPDX-License-Identifier: Apache-2.0
     4  */
     5  
     6  package localsuite
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/stretchr/testify/require"
    12  	mockstorage "github.com/trustbloc/kms-go/internal/mock/storage"
    13  	"github.com/trustbloc/kms-go/kms"
    14  	"github.com/trustbloc/kms-go/secretlock/noop"
    15  )
    16  
    17  func TestNewLocalCryptoSuite(t *testing.T) {
    18  	t.Run("success", func(t *testing.T) {
    19  		store, err := kms.NewAriesProviderWrapper(mockstorage.NewMockStoreProvider())
    20  		require.NoError(t, err)
    21  
    22  		suite, err := NewLocalCryptoSuite("prefix://key/uri", store, &noop.NoLock{})
    23  		require.NoError(t, err)
    24  		require.NotNil(t, suite)
    25  	})
    26  
    27  	t.Run("fail to initialize localkms", func(t *testing.T) {
    28  		store, err := kms.NewAriesProviderWrapper(mockstorage.NewMockStoreProvider())
    29  		require.NoError(t, err)
    30  
    31  		suite, err := NewLocalCryptoSuite("", store, &noop.NoLock{})
    32  		require.Error(t, err)
    33  		require.Contains(t, err.Error(), "initializing local key manager")
    34  		require.Nil(t, suite)
    35  	})
    36  }