github.com/trustbloc/kms-go@v1.1.2/wrapper/localsuite/suite_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  	kmsapi "github.com/trustbloc/kms-go/spi/kms"
    16  )
    17  
    18  func TestSuite(t *testing.T) {
    19  	store, e := kms.NewAriesProviderWrapper(mockstorage.NewMockStoreProvider())
    20  	require.NoError(t, e)
    21  
    22  	suite, e := NewLocalCryptoSuite("local-lock://custom/primary/key/", store, &noop.NoLock{})
    23  	require.NoError(t, e)
    24  
    25  	creator, e := suite.KeyCreator()
    26  	require.NoError(t, e)
    27  
    28  	pub, e := creator.Create(kmsapi.BLS12381G2Type)
    29  	require.NoError(t, e)
    30  
    31  	t.Run("KMSCryptoVerifier", func(t *testing.T) {
    32  		kcv, err := suite.KMSCryptoVerifier()
    33  		require.NoError(t, err)
    34  		require.NotNil(t, kcv)
    35  	})
    36  
    37  	t.Run("KeyCreator", func(t *testing.T) {
    38  		c, err := suite.KeyCreator()
    39  		require.NoError(t, err)
    40  		require.NotNil(t, c)
    41  	})
    42  
    43  	t.Run("KMSCrypto", func(t *testing.T) {
    44  		kc, err := suite.KMSCrypto()
    45  		require.NoError(t, err)
    46  		require.NotNil(t, kc)
    47  	})
    48  
    49  	t.Run("FixedKeyCrypto", func(t *testing.T) {
    50  		fkc, err := suite.FixedKeyCrypto(pub)
    51  		require.NoError(t, err)
    52  		require.NotNil(t, fkc)
    53  	})
    54  
    55  	t.Run("RawKeyCreator", func(t *testing.T) {
    56  		rc, err := suite.RawKeyCreator()
    57  		require.NoError(t, err)
    58  		require.NotNil(t, rc)
    59  	})
    60  
    61  	t.Run("KMSCryptoSigner", func(t *testing.T) {
    62  		kcs, err := suite.KMSCryptoSigner()
    63  		require.NoError(t, err)
    64  		require.NotNil(t, kcs)
    65  	})
    66  
    67  	t.Run("FixedKeySigner", func(t *testing.T) {
    68  		fks, err := suite.FixedKeySigner(pub.KeyID)
    69  		require.NoError(t, err)
    70  		require.NotNil(t, fks)
    71  	})
    72  
    73  	t.Run("KMSCryptoMultiSigner", func(t *testing.T) {
    74  		kcms, err := suite.KMSCryptoMultiSigner()
    75  		require.NoError(t, err)
    76  		require.NotNil(t, kcms)
    77  	})
    78  
    79  	t.Run("FixedKeyMultiSigner", func(t *testing.T) {
    80  		fkms, err := suite.FixedKeyMultiSigner(pub.KeyID)
    81  		require.NoError(t, err)
    82  		require.NotNil(t, fkms)
    83  	})
    84  
    85  	t.Run("EncrypterDecrypter", func(t *testing.T) {
    86  		enc, err := suite.EncrypterDecrypter()
    87  		require.NoError(t, err)
    88  		require.NotNil(t, enc)
    89  	})
    90  }