-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprovider_test.go
More file actions
65 lines (61 loc) · 1.59 KB
/
provider_test.go
File metadata and controls
65 lines (61 loc) · 1.59 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package provider
import (
"os"
"strings"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
)
var (
providerConfig = func() string {
option := os.Getenv("DEPENDENCYTRACK_TEST_PROVIDER")
if option == "rootCA" {
rootCa, err := os.ReadFile("/opt/server_cert.pem")
if err != nil {
panic("Root CA file is unable to be read: " + err.Error())
}
return `provider "dependencytrack" {
host = "https://localhost:8082"
key = "OS_ENV"
root_ca = "` + strings.ReplaceAll(string(rootCa), "\n", "\\n") + `"
}`
}
if option == "mtls" {
return `provider "dependencytrack" {
host = "http://localhost:8083"
auth = {
type = "KEY"
key = "OS_ENV"
}
mtls = {
key_path = "/opt/client_key.pem",
cert_path = "/opt/client_cert.pem",
}
}`
}
if option == "rootCA+mtls" {
rootCa, err := os.ReadFile("/opt/server_cert.pem")
if err != nil {
panic("Root CA file is unable to be read: " + err.Error())
}
return `provider "dependencytrack" {
host = "https://localhost:8084"
auth = {
type = "KEY"
key = "OS_ENV"
}
root_ca = "` + strings.ReplaceAll(string(rootCa), "\n", "\\n") + `"
mtls = {
key_path = "/opt/client_key.pem",
cert_path = "/opt/client_cert.pem",
}
}`
}
return `provider "dependencytrack" {
host = "http://localhost:8081"
key = "OS_ENV"
}`
}()
testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
"dependencytrack": providerserver.NewProtocol6WithError(New("test")()),
}
)