-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration: add proxy test for all platforms
- Loading branch information
Showing
27 changed files
with
2,367 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package util | ||
|
||
import ( | ||
"crypto/tls" | ||
"crypto/x509" | ||
_ "embed" // blanks are good | ||
"flag" | ||
"net/http" | ||
"os" | ||
"path/filepath" | ||
"regexp" | ||
|
||
"github.com/elazarl/goproxy" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
//go:embed rootCA.crt | ||
var caCert []byte | ||
|
||
//go:embed rootCA.key | ||
var caKey []byte | ||
|
||
var CACertTempLocation string | ||
|
||
func setCA() error { | ||
|
||
certLocation, err := WriteTempFile(string(caCert), "rootCA.crt") | ||
if err != nil { | ||
return err | ||
} | ||
CACertTempLocation = certLocation | ||
|
||
myCa, err := tls.X509KeyPair(caCert, caKey) | ||
if err != nil { | ||
return err | ||
} | ||
if myCa.Leaf, err = x509.ParseCertificate(myCa.Certificate[0]); err != nil { | ||
return err | ||
} | ||
goproxy.GoproxyCa = myCa | ||
goproxy.OkConnect = &goproxy.ConnectAction{Action: goproxy.ConnectAccept, TLSConfig: goproxy.TLSConfigFromCA(&myCa)} | ||
goproxy.MitmConnect = &goproxy.ConnectAction{Action: goproxy.ConnectMitm, TLSConfig: goproxy.TLSConfigFromCA(&myCa)} | ||
goproxy.HTTPMitmConnect = &goproxy.ConnectAction{Action: goproxy.ConnectHTTPMitm, TLSConfig: goproxy.TLSConfigFromCA(&myCa)} | ||
goproxy.RejectConnect = &goproxy.ConnectAction{Action: goproxy.ConnectReject, TLSConfig: goproxy.TLSConfigFromCA(&myCa)} | ||
return nil | ||
} | ||
|
||
func RunProxy() { | ||
|
||
err := setCA() | ||
if err != nil { | ||
log.Fatalf("error setting up the CA: %s", err) | ||
} | ||
|
||
proxy := goproxy.NewProxyHttpServer() | ||
proxy.OnRequest(goproxy.ReqHostMatches(regexp.MustCompile("^.*$"))).HandleConnect(goproxy.AlwaysMitm) | ||
|
||
logfile := filepath.Join("test", "integration", "out", "goproxylogfile.log") | ||
f, err := os.OpenFile(logfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) | ||
if err != nil { | ||
log.Printf("error opening file: %v", err) | ||
} | ||
defer f.Close() | ||
|
||
log.SetOutput(f) | ||
|
||
verbose := flag.Bool("v", true, "should every proxy request be logged to stdout") | ||
addr := flag.String("127.0.0.1", ":8888", "proxy listen address") // using network-mode=user | ||
flag.Parse() | ||
proxy.Verbose = *verbose | ||
proxy.Logger = log.StandardLogger() | ||
err = http.ListenAndServe(*addr, proxy) // #nosec G114 | ||
if err != nil { | ||
log.Printf("error running proxy: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIFZzCCA0+gAwIBAgIUYUgBLfOW73bbhaqO+p3+9gFv1XMwDQYJKoZIhvcNAQEL | ||
BQAwMDERMA8GA1UEAwwIc3F1aWQgQ0ExCzAJBgNVBAYTAkZSMQ4wDAYDVQQHDAVQ | ||
YXJpczAeFw0yMzA1MDgxMDU2MjVaFw0yODEyMTUxMDU2MjVaMDAxETAPBgNVBAMM | ||
CHNxdWlkIENBMQswCQYDVQQGEwJGUjEO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OH0Xfn0qaI/iZUO4JXe3hV4o8jYgCmED8Jxdi7ck | ||
83jt9yoQzmNrRuUZ9lloLrc3hU0TYhUqGlehg7w1lUVrSv1ykaxSxLyI4YPDURi2 | ||
wazbO6mU94l83lgHBISPRENw6s7/RyBOm2wdabrYGwzA8b/F7Z8gOlGh+LWiBmtG | ||
CHzTU8gnK5pvIBazTuL+Toysn615umPQxoCPp7sAjeNE6iL/AJ0ZvB2YCW9mZx47 | ||
+Hv5jMW9zAD2YqH3qMuhN3GxxXt+E4n+BwcK0xf+cK3wsOiHKDTOR6HRfQ5V/hPI | ||
MtHlWMWb3ej+KgKGiK07W1roKWbnSCmSfgQMZeEH07b/tu7VcLAzmMT1LVbgVliP | ||
d1SEgIjzIftA8VSlZvQCdGj80Dwe/nkurrC4SLA7hL6z9G7et62GgzwbgX7ivLSs | ||
uX0hRsssJ9Bj1seoIh6DBg8lTmJdf5AHsEdDOyzDGhWlWMvXvwYlKnRA7I5Z5mI2 | ||
jZV0k921EcYRXKpvnyNvl8ASW/IzjoDrfcJZVlZwGuhB8Jo7uugLmy7/xwcbf904 | ||
xc3Av5HNjV3N+5uZCAvoTqCBipLFZM5ioguE5IYBoTpR6IU3kJopbBTFAw== | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDfINY+pkT5DNQz | ||
cD6dngI49PlF3BurpSrEwLangjismHODNYzWpHzLoaifAG287g2v1D7SIGGmWImg | ||
5Ngon/ColZ2rJp/rFEdTb4joH7QZUA5LMnJMXq2Ox9FzXl5dmHmk+W114hZHXeeJ | ||
2k7j3GitpMvcpO+XSnePfpdl7QoBGyAPVOvgWp+UDr30RYVr5BeX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v/gPVeewwTvU1IMGT5aqY99ip+T0ZUAcWB3h9 | ||
hBF267/IowciGhWU5m5/ZGBHpKBWMsLCPiIRnQ3cFvYayz/kbdLQST6a03W1Ok8n | ||
GddhjFvHTQi/Ypec7wOhOfhfzcLJmRe8ZIaDB1gexGsJ1nDNWh0rUWDy4AVPqLYR | ||
q0iAYu44P4Wpkx2pcNaJhsQRHBfCKJZFZ9Rp260CggEBALMXxiweidmt6a7oUeqM | ||
M0WsQUvoRktkKFrNvRb6lWWrZ2jYtgcJFTk64EY9D+XQymbtVluX7KhJu9nswTkN | ||
Eoj3jEBITtgxap6iP9+K+TukbXtYwhm8PRoJIak9Wkr1L/wcywRDfgxGTiKgYZD5 | ||
sknZeOaLL6Omr8Vw8f0jjyhifUnlFKkN4UYkOqIkqqYereGGZlxvgljxtcx3ghAT | ||
+OhcIFJw+vAGQojwa94KocJLbp9CMVU5HDscB3mM0uSOrdtE5AbxHaQCk3vlpaFQ | ||
6+JhQJgQYEuTifAT3UFoL4zzSdO0wM4LtUqAT3b4JNKHMzSWUe6S67ErWgON2M3p | ||
OPkCggEAa4tDhkIPea4l9wsmxvuz3h+J4HSAlOgL6lHlEnM8Mw6iBQh+nwHgcJbA | ||
DDoxumomA24KpmGeRT4Ok1yfyEaP3rFA/+S6e4ybu99jud22A/uZQ3yc6SpHER4l | ||
Wdf2mg95aGziH1JAuTXWQ2Cf4/JT69qNcWjHc6oGvrzijWMob5FS3K8OdETFlnV/ | ||
7HhJ3MlQAcVOxl9XRixMl79ivuPYo7a5e5oJfjN9gssTgJM4/zmQL0Tl6tJ3p62y | ||
a+wmVvsQXSiWP+O93iwJPztW4MJCQqFEsQdvNXlWM59ZlhE03EVTMGEpyGeHqsoM | ||
H//KfO7DqxdcKnfNv3o67mtvY1EgUg== | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package test_test | ||
|
||
import ( | ||
"os/exec" | ||
|
||
"github.com/crc-org/crc/test/extended/util" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("", Label("openshift-preset", "goproxy"), func() { | ||
|
||
go util.RunProxy() | ||
|
||
Describe("Behind proxy", func() { | ||
|
||
networkMode := "user" | ||
httpProxy := "http://127.0.0.1:8888" | ||
httpsProxy := "http://127.0.0.1:8888" | ||
noProxy := ".testing" | ||
|
||
// Start goproxy | ||
|
||
It("configure CRC", func() { | ||
Expect(RunCRCExpectSuccess("config", "set", "network-mode", networkMode), ContainSubstring("Network mode")) | ||
Expect(RunCRCExpectSuccess("config", "set", "http-proxy", httpProxy), ContainSubstring("Successfully configured http-proxy")) | ||
Expect(RunCRCExpectSuccess("config", "set", "https-proxy", httpsProxy), ContainSubstring("Successfully configured https-proxy")) | ||
Expect(RunCRCExpectSuccess("config", "set", "no-proxy", noProxy), ContainSubstring("Successfully configured no-proxy")) | ||
Expect(RunCRCExpectSuccess("config", "set", "proxy-ca-file", util.CACertTempLocation), ContainSubstring("Successfully configured proxy-ca-file")) | ||
}) | ||
|
||
It("setup CRC", func() { | ||
if bundlePath == "" { | ||
Expect(RunCRCExpectSuccess("setup")).To(ContainSubstring("Your system is correctly setup for using CRC")) | ||
} else { | ||
Expect(RunCRCExpectSuccess("setup", "-b", bundlePath)).To(ContainSubstring("Your system is correctly setup for using CRC")) | ||
} | ||
}) | ||
|
||
It("start CRC", func() { | ||
// default values: "--memory", "9216", "--cpus", "4", "disk-size", "31" | ||
if bundlePath == "" { | ||
Expect(RunCRCExpectSuccess("start", "-p", pullSecretPath)).To(ContainSubstring("Started the OpenShift cluster")) | ||
} else { | ||
Expect(RunCRCExpectSuccess("start", "-b", bundlePath, "-p", pullSecretPath)).To(ContainSubstring("Started the OpenShift cluster")) | ||
} | ||
}) | ||
|
||
It("login to cluster using crc-admin context", func() { | ||
|
||
err := AddOCToPath() | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
cmd := exec.Command("oc", "config", "use-context", "crc-admin") | ||
err = cmd.Run() | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
cmd = exec.Command("oc", "whoami") | ||
out, err := cmd.Output() | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(string(out)).To(ContainSubstring("kubeadmin")) | ||
|
||
cmd = exec.Command("oc", "get", "co") | ||
err = cmd.Run() | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
It("stop CRC", func() { | ||
Expect(RunCRCExpectSuccess("stop", "-f")).To(MatchRegexp("[Ss]topped the instance")) | ||
}) | ||
|
||
It("cleanup CRC", func() { | ||
Expect(RunCRCExpectSuccess("cleanup")).To(MatchRegexp("Cleanup finished")) | ||
}) | ||
|
||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.