Browse Source

httpcaddyfile: Fix automation policy consolidation again (fix #4161)

Also fix a previous test that asserted incorrect behavior.
master
Matthew Holt 4 years ago
parent
commit
dbe164d98a
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 5
      caddyconfig/httpcaddyfile/tlsapp.go
  2. 12
      caddytest/integration/caddyfile_adapt/tls_automation_policies_4.txt
  3. 120
      caddytest/integration/caddyfile_adapt/tls_automation_policies_6.txt

5
caddyconfig/httpcaddyfile/tlsapp.go

@ -510,7 +510,10 @@ outer:
// if they're exactly equal in every way, just keep one of them
if reflect.DeepEqual(aps[i], aps[j]) {
aps = append(aps[:j], aps[j+1:]...)
break
// must re-evaluate current i against next j; can't skip it!
// even if i decrements to -1, will be incremented to 0 immediately
i--
continue outer
}
// if the policy is the same, we can keep just one, but we have

12
caddytest/integration/caddyfile_adapt/tls_automation_policies_4.txt

@ -124,18 +124,6 @@ abc.de {
"tls": {
"automation": {
"policies": [
{
"issuers": [
{
"email": "my.email@example.com",
"module": "acme"
},
{
"email": "my.email@example.com",
"module": "zerossl"
}
]
},
{
"issuers": [
{

120
caddytest/integration/caddyfile_adapt/tls_automation_policies_6.txt

@ -0,0 +1,120 @@
# (this Caddyfile is contrived, but based on issue #4161)
example.com {
tls {
ca https://foobar
}
}
example.com:8443 {
tls {
ca https://foobar
}
}
example.com:8444 {
tls {
ca https://foobar
}
}
example.com:8445 {
tls {
ca https://foobar
}
}
----------
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"example.com"
]
}
],
"terminal": true
}
]
},
"srv1": {
"listen": [
":8443"
],
"routes": [
{
"match": [
{
"host": [
"example.com"
]
}
],
"terminal": true
}
]
},
"srv2": {
"listen": [
":8444"
],
"routes": [
{
"match": [
{
"host": [
"example.com"
]
}
],
"terminal": true
}
]
},
"srv3": {
"listen": [
":8445"
],
"routes": [
{
"match": [
{
"host": [
"example.com"
]
}
],
"terminal": true
}
]
}
}
},
"tls": {
"automation": {
"policies": [
{
"subjects": [
"example.com"
],
"issuers": [
{
"ca": "https://foobar",
"module": "acme"
}
]
}
]
}
}
}
}
Loading…
Cancel
Save