mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-18 18:16:26 +00:00
Add backend unit tests
This commit is contained in:
@ -136,7 +136,15 @@ func getCommonArgs() []string {
|
||||
}
|
||||
|
||||
// This is split out into it's own function so it's testable
|
||||
func buildCertRequestArgs(domains []string, method, outputFullchainFile, outputKeyFile string, dnsProvider *dnsprovider.Model, ca *certificateauthority.Model, force bool) ([]string, error) {
|
||||
func buildCertRequestArgs(
|
||||
domains []string,
|
||||
method,
|
||||
outputFullchainFile,
|
||||
outputKeyFile string,
|
||||
dnsProvider *dnsprovider.Model,
|
||||
ca *certificateauthority.Model,
|
||||
force bool,
|
||||
) ([]string, error) {
|
||||
// The argument order matters.
|
||||
// see https://github.com/acmesh-official/acme.sh/wiki/How-to-issue-a-cert#3-multiple-domains-san-mode--hybrid-mode
|
||||
// for multiple domains and note that the method of validation is required just after the domain arg, each time.
|
||||
|
@ -193,3 +193,33 @@ func TestBuildCertRequestArgs(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAcmeShFilePath(t *testing.T) {
|
||||
t.Run("basic test", func(t *testing.T) {
|
||||
path, err := getAcmeShFilePath()
|
||||
assert.Equal(t, "/bin/acme.sh", path)
|
||||
assert.Equal(t, nil, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetCommonEnvVars(t *testing.T) {
|
||||
t.Run("basic test", func(t *testing.T) {
|
||||
expected := []string{
|
||||
"ACMESH_CONFIG_HOME=/data/.acme.sh/config",
|
||||
"ACMESH_HOME=/data/.acme.sh",
|
||||
"CERT_HOME=/data/.acme.sh/certs",
|
||||
"LE_CONFIG_HOME=/data/.acme.sh/config",
|
||||
"LE_WORKING_DIR=/data/.acme.sh",
|
||||
}
|
||||
vals := getCommonEnvVars()
|
||||
assert.Equal(t, expected, vals)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetAcmeShVersion(t *testing.T) {
|
||||
t.Run("basic test", func(t *testing.T) {
|
||||
resp := GetAcmeShVersion()
|
||||
assert.Greater(t, len(resp), 1)
|
||||
assert.Equal(t, "v", resp[:1])
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user