Skip to content

Commit

Permalink
Deal with os matrix / absence of docker. Update dependencies but avoi…
Browse files Browse the repository at this point in the history
…d x/tools 0.25.0 which forces go 1.22 upgrade (#155)

* Deal with os matrix / absence of docker. Update dependencies but avoid x/tools 0.25.0 which forces go 1.22 upgrade

* avoid issue with wrong openssl in the macos github action

* switching strategy re docker

* windows error is different

* seems txtar/testscript files don't work on windows

* more windows error message difference

* Pass token down for codecov

* last 2 windows error adjustments, hopefully

* giving up on tescript on windows because of the -- issue
  • Loading branch information
ldemailly authored Sep 17, 2024
1 parent 21a9d3d commit 2c9e587
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/include.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
uses: fortio/workflows/.github/workflows/gochecks.yml@main
call-codecov:
uses: fortio/workflows/.github/workflows/codecov.yml@main
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
call-codeql:
uses: fortio/workflows/.github/workflows/codeql-analysis.yml@main
call-releaser:
Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
all: clean lint check test-local-image

OS:=$(shell go env GOOS)

test: test-local-image
ifeq ($(OS),windows)
@echo "Skipping test on windows, issue with -- and testscript"
else
go test -race ./...
endif

lint: .golangci.yml
golangci-lint run
Expand All @@ -21,9 +27,12 @@ build_no_tls_fallback:
clean:
rm -f multicurl

# on a mac with docker... run `make OS=linux` to test local docker.
test-local-image: multicurl
ifeq ($(OS),linux)
docker build -t fortio/multicurl:local -f Dockerfile .
docker run --rm fortio/multicurl:local -4 https://debug.fortio.org/build-test
endif

.golangci.yml: Makefile
curl -fsS -o .golangci.yml https://raw.githubusercontent.com/fortio/workflows/main/golangci.yml
Expand Down
58 changes: 29 additions & 29 deletions cli/multicurl.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -117,47 +117,47 @@ grep 'Debug server on a1' out.18.222.136.83.txt

# error case
! multicurl -4 -i -o /doesnexist/debug.%.txt debug.fortio.org
stderr '\[E\] Error creating file /doesnexist/debug.+: open /doesnexist/debug.+: no such file or directory'
stderr '\[E\] Error creating file /doesnexist/debug'

# Weird method test - count depends on number of ip addresses for debug.fortio.org
multicurl -4 -X INFO -d 'blah blah' https://debug.fortio.org
stdout 'INFO / HTTP/2.0'
stdout -count=3 'blah blah'

# Debug summary of proxy is escaping the body thus the \n
multicurl -4 -d @payloadFile.txt https://debug.fortio.org
stderr '\[I\] Read 23 bytes from "payloadFile.txt" as payload'
stdout 'POST / HTTP/2.0'
stdout 'Content-Length: 23'
stdout '^body:$'
stdout '^Just a test\\nof payload\\n$'
[unix] multicurl -4 -d @payloadFile.txt https://debug.fortio.org
[unix] stderr '\[I\] Read 23 bytes from "payloadFile.txt" as payload'
[unix] stdout 'POST / HTTP/2.0'
[unix] stdout 'Content-Length: 23'
[unix] stdout '^body:$'
[unix] stdout '^Just a test\\nof payload\\n$'

# payload file error
! multicurl -4 -d @nosuchfile.txt https://debug.fortio.org
stderr '\[F\] Unable to read payload from file "nosuchfile.txt": open nosuchfile.txt: no such file or directory'
stderr '\[F\] Unable to read payload from file "nosuchfile.txt": open nosuchfile.txt'

# ip file error
! multicurl -4 -I nosuchfile.txt https://debug.fortio.org
stderr '\[F\] Unable to resolve ip4 host debug.fortio.org: open nosuchfile.txt: no such file or directory'
stderr '\[F\] Unable to resolve ip4 host debug.fortio.org: open nosuchfile.txt'

# ip file
multicurl -4 -I ips.txt https://debug.fortio.org
stderr 'Using content of "ips.txt" to resolve IPs'
stderr '18.222.136.83'
[unix] multicurl -4 -I ips.txt https://debug.fortio.org
[unix] stderr 'Using content of "ips.txt" to resolve IPs'
[unix] stderr '18.222.136.83'

# bad ip file
! multicurl -4 -I badIps.txt https://debug.fortio.org
stderr '\[F\] Unable to resolve ip4 host debug.fortio.org: unable to parse IP "not-an-ip"'
[unix] ! multicurl -4 -I badIps.txt https://debug.fortio.org
[unix] stderr '\[F\] Unable to resolve ip4 host debug.fortio.org: unable to parse IP "not-an-ip"'

# good ipv6
! multicurl -I ipv6.txt http://foo:9099/
stderr '\[I\] Resolved ip foo:9099 to port 9099 and 2 addresses \[::1 ::2\]'
stderr 'connect: connection refused'
[unix] ! multicurl -I ipv6.txt http://foo:9099/
[unix] stderr '\[I\] Resolved ip foo:9099 to port 9099 and 2 addresses \[::1 ::2\]'
[unix] stderr 'connect: connection refused'

# stdin ips
stdin ips.txt
multicurl -4 -I - https://debug.fortio.org
stderr 'Using stdin for list of IPs to connect to'
[unix] stdin ips.txt
[unix] multicurl -4 -I - https://debug.fortio.org
[unix] stderr 'Using stdin for list of IPs to connect to'

# retries
! multicurl -4 -repeat -1 -repeat-delay 1s -total-timeout 1.9s -expected 301 http://debug.fortio.org
Expand All @@ -180,7 +180,7 @@ stderr '\[I\] Certificate "CN=BadSSL Untrusted Root Certificate Authority'

# no such ca-cert file
! multicurl -4 -cacert nosuchfile https://debug.fortio.org/
stderr '\[F\] can.t read CA file: open nosuchfile: no such file or directory'
stderr '\[F\] can.t read CA file: open nosuchfile:'

# get the server cert
exec sh -c 'openssl s_client -showcerts -servername self-signed.badssl.com -connect self-signed.badssl.com:443 </dev/null | openssl x509 > test.ca'
Expand All @@ -189,17 +189,17 @@ stderr '\[I\] Certificate "CN=..badssl.com'

# bad client cert path
! multicurl -4 -cert nosuchfile.crt -key nosuchfile.key https://debug.fortio.org/
stderr '\[F\] LoadX509KeyPair error for cert nosuchfile.crt / key nosuchfile.key: open nosuchfile.crt: no such file or directory'
stderr '\[F\] LoadX509KeyPair error for cert nosuchfile.crt / key nosuchfile.key: open nosuchfile.crt:'

# mtls test
# on mac you need to use openssl from
# brew install openssl@3
exec curl -sS -o client.p12 https://badssl.com/certs/badssl.com-client.p12
exec openssl version
exec openssl pkcs12 -legacy -in client.p12 -out client.crt -clcerts -nokeys -passin pass:badssl.com
exec openssl pkcs12 -legacy -in client.p12 -out client.key -nocerts -nodes -passin pass:badssl.com
multicurl -4 -cert client.crt -key client.key https://client.badssl.com/
stdout 'This site requires a .*client-authenticated.*TLS handshake'
# brew install openssl@3 - so because CI macos doesn't have it, we tag this with linux for now.
[linux] exec curl -sS -o client.p12 https://badssl.com/certs/badssl.com-client.p12
[linux] exec openssl version
[linux] exec openssl pkcs12 -legacy -in client.p12 -out client.crt -clcerts -nokeys -passin pass:badssl.com
[linux] exec openssl pkcs12 -legacy -in client.p12 -out client.key -nocerts -nodes -passin pass:badssl.com
[linux] multicurl -4 -cert client.crt -key client.key https://client.badssl.com/
[linux] stdout 'This site requires a .*client-authenticated.*TLS handshake'

# json, no certs, no expiry
multicurl -4 -n 1 -json -o none http://debug.fortio.org
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module fortio.org/multicurl

go 1.18
go 1.20

require (
fortio.org/cli v1.9.0
fortio.org/log v1.16.0
fortio.org/testscript v0.3.1
fortio.org/testscript v0.3.2
fortio.org/version v1.0.4
)

require (
fortio.org/struct2env v0.4.1 // indirect
github.com/kortschak/goroutine v1.1.2 // indirect
golang.org/x/crypto/x509roots/fallback v0.0.0-20240626151235-a6a393ffd658 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/tools v0.8.0 // indirect
golang.org/x/crypto/x509roots/fallback v0.0.0-20240916204253-42ee18b96377 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/tools v0.24.0 // indirect
)
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ fortio.org/log v1.16.0 h1:GhU8/9NkYZmEIzvTN/DTMedDAStLJraWUUVUA2EbNDc=
fortio.org/log v1.16.0/go.mod h1:t58Spg9njjymvRioh5F6qKGSupEsnMjXLGWIS1i3khE=
fortio.org/struct2env v0.4.1 h1:rJludAMO5eBvpWplWEQNqoVDFZr4RWMQX7RUapgZyc0=
fortio.org/struct2env v0.4.1/go.mod h1:lENUe70UwA1zDUCX+8AsO663QCFqYaprk5lnPhjD410=
fortio.org/testscript v0.3.1 h1:MmRO64AsmzaU1KlYMzAbotJIMKRGxD1XXssJnBRiMGQ=
fortio.org/testscript v0.3.1/go.mod h1:7OJ+U4avooRNqc7p/VHKJadYgj9fA6+N0SbGU8FVWGs=
fortio.org/testscript v0.3.2 h1:ks5V+Y6H6nmeGqnVlZuLdiFwpqXemDkEnyGgCZa/ZNA=
fortio.org/testscript v0.3.2/go.mod h1:Z2kUvEDHYETV8FLxsdA6zwSZ8sZUiTNJh2Dw5c4a3Pg=
fortio.org/version v1.0.4 h1:FWUMpJ+hVTNc4RhvvOJzb0xesrlRmG/a+D6bjbQ4+5U=
fortio.org/version v1.0.4/go.mod h1:2JQp9Ax+tm6QKiGuzR5nJY63kFeANcgrZ0osoQFDVm0=
github.com/kortschak/goroutine v1.1.2 h1:lhllcCuERxMIK5cYr8yohZZScL1na+JM5JYPRclWjck=
github.com/kortschak/goroutine v1.1.2/go.mod h1:zKpXs1FWN/6mXasDQzfl7g0LrGFIOiA6cLs9eXKyaMY=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240626151235-a6a393ffd658 h1:i7K6wQLN/0oxF7FT3tKkfMCstxoT4VGG36YIB9ZKLzI=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240626151235-a6a393ffd658/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y=
golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240916204253-42ee18b96377 h1:aDWu69N3Si4isYMY1ppnuoGEFypX/E5l4MWA//GPClw=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240916204253-42ee18b96377/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=

0 comments on commit 2c9e587

Please sign in to comment.