forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperation_put_certificate_test.go
50 lines (39 loc) · 1.13 KB
/
operation_put_certificate_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
46
47
48
49
50
package tests
import (
"fmt"
"github.com/ravendb/ravendb-go-client/serverwide/certificates"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func putCertificateTest(t *testing.T, driver *RavenTestDriver) {
var err error
store := driver.getSecuredDocumentStoreMust(t)
assert.NotNil(t, store)
defer store.Close()
path := os.Getenv("RAVENDB_TEST_CA_PATH")
if !fileExists(path) {
fmt.Printf("Didn't find cert.crt file at '%s'. Set RAVENDB_TEST_CA_PATH env variable\n", path)
os.Exit(1)
}
certificate := loadTestCaCertificate(path)
assert.NotNil(t, certificate)
fmt.Printf("Loaded client certificate from '%s'\n", path)
certName := "Admin Certificate"
operation := certificates.OperationPutCertificate{
CertName: certName,
CertBytes: certificate.Raw,
SecurityClearance: certificates.ClusterAdmin.String(),
Permissions: nil,
}
err = store.Maintenance().Server().Send(&operation)
assert.NoError(t, err)
}
func TestPutCertificateTest(t *testing.T) {
driver := createTestDriver(t)
destroy := func() {
destroyDriver(t, driver)
}
defer recoverTest(t, destroy)
putCertificateTest(t, driver)
}