-
Notifications
You must be signed in to change notification settings - Fork 626
/
Copy pathmain_test.go
120 lines (96 loc) · 3.19 KB
/
main_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
* one or more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Licensed under the Camunda License 1.0. You may not use this file
* except in compliance with the Camunda License 1.0.
*/
package main
import (
"github.com/stretchr/testify/assert"
"strings"
"testing"
)
func TestCamundaCmdWithKeystoreSettings(t *testing.T) {
settings := C8RunSettings{
config: "",
detached: false,
port: 8080,
keystore: "/tmp/camundatest/certs/secret.jks",
keystorePassword: "changeme",
}
expectedJavaOpts := "JAVA_OPTS= -Dserver.ssl.keystore=file:" + settings.keystore + " -Dserver.ssl.enabled=true" + " -Dserver.ssl.key-password=" + settings.keystorePassword + " -Dspring.profiles.active=operate,tasklist,broker,identity,auth-basic"
javaOpts := adjustJavaOpts("", settings)
c8runPlatform := getC8RunPlatform()
err := validateKeystore(settings, "/tmp/camundatest/")
assert.Nil(t, err)
cmd := c8runPlatform.CamundaCmd("8.7.0", "/tmp/camundatest/", "", javaOpts)
foundVar := ""
for _, envVar := range cmd.Env {
if strings.Contains(envVar, "JAVA_OPTS") {
foundVar = envVar
break
}
}
assert.Equal(t, expectedJavaOpts, foundVar)
}
func TestCamundaCmdKeystoreRequiresPassword(t *testing.T) {
settings := C8RunSettings{
config: "",
detached: false,
port: 8080,
keystore: "/tmp/camundatest/certs/secret.jks",
keystorePassword: "",
}
err := validateKeystore(settings, "/tmp/camundatest/")
assert.NotNil(t, err)
assert.Error(t, err, "You must provide a password with --keystorePassword to unlock your keystore.")
}
func TestCamundaCmdDifferentPort(t *testing.T) {
settings := C8RunSettings{
port: 8087,
}
javaOpts := adjustJavaOpts("", settings)
c8runPlatform := getC8RunPlatform()
cmd := c8runPlatform.CamundaCmd("8.7.0", "/tmp/camundatest/", "", javaOpts)
javaOptsEnvVar := ""
for _, envVar := range cmd.Env {
if strings.Contains(envVar, "JAVA_OPTS") {
javaOptsEnvVar = envVar
break
}
}
assert.Contains(t, javaOptsEnvVar, "-Dserver.port=8087")
}
func TestCamundaCmdUsername(t *testing.T) {
settings := C8RunSettings{
username: "admin",
}
javaOpts := adjustJavaOpts("", settings)
c8runPlatform := getC8RunPlatform()
cmd := c8runPlatform.CamundaCmd("8.7.0", "/tmp/camundatest/", "", javaOpts)
javaOptsEnvVar := ""
for _, envVar := range cmd.Env {
if strings.Contains(envVar, "JAVA_OPTS") {
javaOptsEnvVar = envVar
break
}
}
assert.Contains(t, javaOptsEnvVar, "-Dcamunda.security.initialization.users[0].username=admin")
}
func TestCamundaCmdPassword(t *testing.T) {
settings := C8RunSettings{
password: "changeme",
}
javaOpts := adjustJavaOpts("", settings)
c8runPlatform := getC8RunPlatform()
cmd := c8runPlatform.CamundaCmd("8.7.0", "/tmp/camundatest/", "", javaOpts)
javaOptsEnvVar := ""
for _, envVar := range cmd.Env {
if strings.Contains(envVar, "JAVA_OPTS") {
javaOptsEnvVar = envVar
break
}
}
assert.Contains(t, javaOptsEnvVar, "-Dcamunda.security.initialization.users[0].password=changeme")
}