caddy icon indicating copy to clipboard operation
caddy copied to clipboard

[Tests] Running tests + caddy trust + being asked for password causes failure

Open xdevs23 opened this issue 3 years ago • 0 comments

Host information

OS: Arch Linux (rolling), Linux simao-arch 5.11.7-nitrous-1 #1 SMP PREEMPT Wed Mar 17 20:53:42 CET 2021 x86_64 GNU/Linux HEAD: 0018b9be0d2e409cd80367c9e8403188723d0996 Using doas (instead of sudo) symlinked to /usr/bin/sudo doas config:

permit :wheel
permit persist simao

Issue

Commands run prior to testing:

go get

When running all tests and trusting the certificate(s) during tests causes the tests to fail the first time.

First time I ran the tests I got (command go -count=1 test './...'):

2021/03/19 22:01:36 caddytest: redirecting the dialer from localhost:9080 to 127.0.0.1:9080
--- FAIL: TestAutoHTTPtoHTTPSRedirectsImplicitPort (11.87s)
    caddytest.go:159: unable to contact caddy server. Post "http://localhost:2019/load": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
    caddytest.go:99: failed to load config: Post "http://localhost:2019/load": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

If I run the tests again, it works.

To reproduce this, run caddy untrust and make sure you would get asked for your password the next time you use sudo/doas (for example doas -L).

Run the tests again:

go -count=1 './...' → fails with same error

My guess is that this happens when it asks me for my sudo password to install the local certificate and it simply runs into a context deadline. Not sure how to deal with this, maybe it's not a good idea to ask for root privileges during tests in the first place?

xdevs23 avatar Mar 19 '21 21:03 xdevs23