Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 11, 01:00 UTC
| 1 | package caddytls |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/caddyserver/certmagic" |
| 7 | "go.uber.org/zap" |
| 8 | ) |
| 9 | |
| 10 | func TestAutomationPolicyMakeCertMagicConfigImplicitTailscaleManagersOnly(t *testing.T) { |
| 11 | ap := AutomationPolicy{ |
| 12 | Managers: []certmagic.Manager{Tailscale{}}, |
| 13 | subjects: []string{"test-node.example.ts.net"}, |
| 14 | } |
| 15 | |
| 16 | cfg, err := ap.makeCertMagicConfig(&TLS{ |
| 17 | logger: zap.NewNop(), |
| 18 | }, nil, &certmagic.FileStorage{Path: t.TempDir()}) |
| 19 | if err != nil { |
| 20 | t.Fatalf("making certmagic config: %v", err) |
| 21 | } |
| 22 | if cfg.OnDemand == nil { |
| 23 | t.Fatal("expected on-demand config to be set") |
| 24 | } |
| 25 | if len(cfg.Issuers) != 0 { |
| 26 | t.Fatalf("expected no issuers for tailscale-managed ts.net policy, got %d", len(cfg.Issuers)) |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | func TestAutomationPolicyImplicitTailscaleManagersOnlyCatchAll(t *testing.T) { |
| 31 | ap := AutomationPolicy{ |
| 32 | Managers: []certmagic.Manager{Tailscale{}}, |
| 33 | } |
| 34 | if ap.implicitTailscaleManagersOnly() { |
| 35 | t.Fatal("expected catch-all manager policy to remain outside tailscale-only special case") |
| 36 | } |
| 37 | } |