forked from microsoft/go-mssqldb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alwaysencrypted_windows_test.go
45 lines (36 loc) · 1.03 KB
/
alwaysencrypted_windows_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//go:build go1.17
// +build go1.17
package mssql
import (
"fmt"
"testing"
"github.com/microsoft/go-mssqldb/aecmk"
"github.com/microsoft/go-mssqldb/aecmk/localcert"
"github.com/microsoft/go-mssqldb/internal/certs"
"github.com/stretchr/testify/assert"
)
type certStoreProviderTest struct {
thumbprint string
}
func (p *certStoreProviderTest) ProvisionMasterKey(t *testing.T) string {
t.Helper()
thumbprint, err := certs.ProvisionMasterKeyInCertStore()
assert.NoError(t, err, "Create cert in cert store")
certPath := fmt.Sprintf(`CurrentUser/My/%s`, thumbprint)
p.thumbprint = thumbprint
return certPath
}
func (p *certStoreProviderTest) DeleteMasterKey(t *testing.T) {
t.Helper()
certs.DeleteMasterKeyCert(p.thumbprint)
}
func (p *certStoreProviderTest) GetProvider(t *testing.T) aecmk.ColumnEncryptionKeyProvider {
t.Helper()
return &localcert.WindowsCertificateStoreKeyProvider
}
func (p *certStoreProviderTest) Name() string {
return aecmk.CertificateStoreKeyProvider
}
func init() {
addProviderTest(&certStoreProviderTest{})
}