diff options
author | Mark Sargent <99003+sarge@users.noreply.github.com> | 2020-03-23 13:08:02 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-22 18:08:02 -0600 |
commit | 8cc60e6896b7c030891a3578ae2405a14b2fed49 (patch) | |
tree | 34f23ea2f2e6e79bc578cba8dcd4d5cba315b43e /caddytest/caddytest.go | |
parent | bea8dedfb2b3bc11ad910853bcbe5601c729b548 (diff) |
ci: test local CA and update SNI tests (#3145)
* run caddy tests in process
* call main with run args
* exclude tests - windows
* include json example
* disable caddyfile tests, include json test with non trusted local ca
* converted SNI tests to json syntax
Diffstat (limited to 'caddytest/caddytest.go')
-rw-r--r-- | caddytest/caddytest.go | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/caddytest/caddytest.go b/caddytest/caddytest.go index 89e457c..a020be9 100644 --- a/caddytest/caddytest.go +++ b/caddytest/caddytest.go @@ -18,6 +18,11 @@ import ( "strings" "testing" "time" + + caddycmd "github.com/caddyserver/caddy/v2/cmd" + + // plug in Caddy modules here + _ "github.com/caddyserver/caddy/v2/modules/standard" ) // Defaults store any configuration required to make the tests run @@ -145,6 +150,30 @@ func validateTestPrerequisites() error { } } + if isCaddyAdminRunning() != nil { + // start inprocess caddy server + os.Args = []string{"caddy", "run"} + go func() { + caddycmd.Main() + }() + + // wait for caddy to start + retries := 4 + for ; retries > 0 && isCaddyAdminRunning() != nil; retries-- { + time.Sleep(10 * time.Millisecond) + } + } + + // assert that caddy is running + if err := isCaddyAdminRunning(); err != nil { + return err + } + + arePrerequisitesValid = true + return nil +} + +func isCaddyAdminRunning() error { // assert that caddy is running client := &http.Client{ Timeout: time.Second * 2, @@ -154,7 +183,6 @@ func validateTestPrerequisites() error { return errors.New("caddy integration test caddy server not running. Expected to be listening on localhost:2019") } - arePrerequisitesValid = true return nil } |