10 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
11 . "github.com/onsi/ginkgo"
12 . "github.com/onsi/ginkgo/extensions/table"
13 . "github.com/onsi/gomega"
16const hello = "Hello World!"
18var _ = Describe("Server", func() {
19 handler := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
20 rw.Write([]byte(hello))
23 Context("NewServer", func() {
24 type newServerTableInput struct {
27 expectHTTPListener bool
28 expectTLSListener bool
31 DescribeTable("When creating the new server from the options", func(in *newServerTableInput) {
32 srv, err := NewServer(in.opts)
33 if in.expectedErr != nil {
34 Expect(err).To(MatchError(ContainSubstring(in.expectedErr.Error())))
35 Expect(srv).To(BeNil())
39 Expect(err).ToNot(HaveOccurred())
41 s, ok := srv.(*server)
42 Expect(ok).To(BeTrue())
44 Expect(s.listener != nil).To(Equal(in.expectHTTPListener))
45 if in.expectHTTPListener {
46 Expect(s.listener.Close()).To(Succeed())
48 Expect(s.tlsListener != nil).To(Equal(in.expectTLSListener))
49 if in.expectTLSListener {
50 Expect(s.tlsListener.Close()).To(Succeed())
53 Entry("with an ipv4 valid http bind address", &newServerTableInput{
56 BindAddress: "127.0.0.1:0",
59 expectHTTPListener: true,
60 expectTLSListener: false,
62 Entry("with an ipv4 valid https bind address, with no TLS config", &newServerTableInput{
65 SecureBindAddress: "127.0.0.1:0",
67 expectedErr: errors.New("error setting up TLS listener: no TLS config provided"),
68 expectHTTPListener: false,
69 expectTLSListener: false,
71 Entry("with an ipv4 valid https bind address, and valid TLS config", &newServerTableInput{
74 SecureBindAddress: "127.0.0.1:0",
76 Key: &ipv4KeyDataSource,
77 Cert: &ipv4CertDataSource,
81 expectHTTPListener: false,
82 expectTLSListener: true,
84 Entry("with a both a ipv4 valid http and ipv4 valid https bind address, and valid TLS config", &newServerTableInput{
87 BindAddress: "127.0.0.1:0",
88 SecureBindAddress: "127.0.0.1:0",
90 Key: &ipv4KeyDataSource,
91 Cert: &ipv4CertDataSource,
95 expectHTTPListener: true,
96 expectTLSListener: true,
98 Entry("with a \"-\" for the bind address", &newServerTableInput{
104 expectHTTPListener: false,
105 expectTLSListener: false,
107 Entry("with a \"-\" for the secure bind address", &newServerTableInput{
110 SecureBindAddress: "-",
113 expectHTTPListener: false,
114 expectTLSListener: false,
116 Entry("with an ipv4 invalid bind address scheme", &newServerTableInput{
119 BindAddress: "invalid://127.0.0.1:0",
121 expectedErr: errors.New("error setting up listener: listen (invalid, 127.0.0.1:0) failed: listen invalid: unknown network invalid"),
122 expectHTTPListener: false,
123 expectTLSListener: false,
125 Entry("with an ipv4 invalid secure bind address scheme", &newServerTableInput{
128 SecureBindAddress: "invalid://127.0.0.1:0",
130 Key: &ipv4KeyDataSource,
131 Cert: &ipv4CertDataSource,
135 expectHTTPListener: false,
136 expectTLSListener: true,
138 Entry("with an ipv4 invalid bind address port", &newServerTableInput{
141 BindAddress: "127.0.0.1:a",
143 expectedErr: errors.New("error setting up listener: listen (tcp, 127.0.0.1:a) failed: listen tcp: "),
144 expectHTTPListener: false,
145 expectTLSListener: false,
147 Entry("with an ipv4 invalid secure bind address port", &newServerTableInput{
150 SecureBindAddress: "127.0.0.1:a",
152 Key: &ipv4KeyDataSource,
153 Cert: &ipv4CertDataSource,
156 expectedErr: errors.New("error setting up TLS listener: listen (127.0.0.1:a) failed: listen tcp: "),
157 expectHTTPListener: false,
158 expectTLSListener: false,
160 Entry("with an ipv4 invalid TLS key", &newServerTableInput{
163 SecureBindAddress: "127.0.0.1:0",
165 Key: &options.SecretSource{
166 Value: []byte("invalid"),
168 Cert: &ipv4CertDataSource,
171 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not parse certificate data: tls: failed to find any PEM data in key input"),
172 expectHTTPListener: false,
173 expectTLSListener: false,
175 Entry("with an ipv4 invalid TLS cert", &newServerTableInput{
178 SecureBindAddress: "127.0.0.1:0",
180 Key: &ipv4KeyDataSource,
181 Cert: &options.SecretSource{
182 Value: []byte("invalid"),
186 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not parse certificate data: tls: failed to find any PEM data in certificate input"),
187 expectHTTPListener: false,
188 expectTLSListener: false,
190 Entry("with an ipv4 address, with no TLS key", &newServerTableInput{
193 SecureBindAddress: "127.0.0.1:0",
195 Cert: &ipv4CertDataSource,
198 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not load key data: no configuration provided"),
199 expectHTTPListener: false,
200 expectTLSListener: false,
202 Entry("with an ipv4 address, with no TLS cert", &newServerTableInput{
205 SecureBindAddress: "127.0.0.1:0",
207 Key: &ipv4KeyDataSource,
210 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not load cert data: no configuration provided"),
211 expectHTTPListener: false,
212 expectTLSListener: false,
214 Entry("when the ipv4 bind address is prefixed with the http scheme", &newServerTableInput{
217 BindAddress: "http://127.0.0.1:0",
220 expectHTTPListener: true,
221 expectTLSListener: false,
223 Entry("when the ipv4 secure bind address is prefixed with the https scheme", &newServerTableInput{
226 SecureBindAddress: "https://127.0.0.1:0",
228 Key: &ipv4KeyDataSource,
229 Cert: &ipv4CertDataSource,
233 expectHTTPListener: false,
234 expectTLSListener: true,
236 Entry("with an ipv4 valid https bind address, and valid TLS config with MinVersion", &newServerTableInput{
239 SecureBindAddress: "127.0.0.1:0",
241 Key: &ipv4KeyDataSource,
242 Cert: &ipv4CertDataSource,
243 MinVersion: "TLS1.3",
247 expectHTTPListener: false,
248 expectTLSListener: true,
250 Entry("with an ipv4 valid https bind address, and invalid TLS config with unknown MinVersion", &newServerTableInput{
253 SecureBindAddress: "127.0.0.1:0",
255 Key: &ipv4KeyDataSource,
256 Cert: &ipv4CertDataSource,
257 MinVersion: "TLS1.42",
260 expectedErr: errors.New("error setting up TLS listener: unknown TLS MinVersion config provided"),
261 expectHTTPListener: false,
262 expectTLSListener: true,
264 Entry("with an ipv4 valid https bind address, and valid TLS config with CipherSuites", &newServerTableInput{
267 SecureBindAddress: "127.0.0.1:0",
269 Key: &ipv4KeyDataSource,
270 Cert: &ipv4CertDataSource,
271 CipherSuites: []string{
272 "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
273 "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
278 expectHTTPListener: false,
279 expectTLSListener: true,
281 Entry("with an ipv4 valid https bind address, and invalid TLS config with unknown CipherSuites", &newServerTableInput{
284 SecureBindAddress: "127.0.0.1:0",
286 Key: &ipv4KeyDataSource,
287 Cert: &ipv4CertDataSource,
288 CipherSuites: []string{
289 "TLS_RSA_WITH_RC4_64_SHA",
290 "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
294 expectedErr: errors.New("error setting up TLS listener: could not parse cipher suites: unknown TLS cipher suite name specified \"TLS_RSA_WITH_RC4_64_SHA\""),
295 expectHTTPListener: false,
296 expectTLSListener: true,
298 Entry("with an ipv6 valid http bind address", &newServerTableInput{
301 BindAddress: "[::1]:0",
304 expectHTTPListener: true,
305 expectTLSListener: false,
307 Entry("with an ipv6 valid https bind address, with no TLS config", &newServerTableInput{
310 SecureBindAddress: "[::1]:0",
312 expectedErr: errors.New("error setting up TLS listener: no TLS config provided"),
313 expectHTTPListener: false,
314 expectTLSListener: false,
316 Entry("with an ipv6 valid https bind address, and valid TLS config", &newServerTableInput{
319 SecureBindAddress: "[::1]:0",
321 Key: &ipv6KeyDataSource,
322 Cert: &ipv6CertDataSource,
326 expectHTTPListener: false,
327 expectTLSListener: true,
329 Entry("with a both a ipv6 valid http and ipv6 valid https bind address, and valid TLS config", &newServerTableInput{
332 BindAddress: "[::1]:0",
333 SecureBindAddress: "[::1]:0",
335 Key: &ipv6KeyDataSource,
336 Cert: &ipv6CertDataSource,
340 expectHTTPListener: true,
341 expectTLSListener: true,
343 Entry("with an ipv6 invalid bind address scheme", &newServerTableInput{
346 BindAddress: "invalid://[::1]:0",
348 expectedErr: errors.New("error setting up listener: listen (invalid, [::1]:0) failed: listen invalid: unknown network invalid"),
349 expectHTTPListener: false,
350 expectTLSListener: false,
352 Entry("with an ipv6 invalid secure bind address scheme", &newServerTableInput{
355 SecureBindAddress: "invalid://[::1]:0",
357 Key: &ipv6KeyDataSource,
358 Cert: &ipv6CertDataSource,
362 expectHTTPListener: false,
363 expectTLSListener: true,
365 Entry("with an ipv6 invalid bind address port", &newServerTableInput{
368 BindAddress: "[::1]:a",
370 expectedErr: errors.New("error setting up listener: listen (tcp, [::1]:a) failed: listen tcp: "),
371 expectHTTPListener: false,
372 expectTLSListener: false,
374 Entry("with an ipv6 invalid secure bind address port", &newServerTableInput{
377 SecureBindAddress: "[::1]:a",
379 Key: &ipv6KeyDataSource,
380 Cert: &ipv6CertDataSource,
383 expectedErr: errors.New("error setting up TLS listener: listen ([::1]:a) failed: listen tcp: "),
384 expectHTTPListener: false,
385 expectTLSListener: false,
387 Entry("with an ipv6 invalid TLS key", &newServerTableInput{
390 SecureBindAddress: "[::1]:0",
392 Key: &options.SecretSource{
393 Value: []byte("invalid"),
395 Cert: &ipv6CertDataSource,
398 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not parse certificate data: tls: failed to find any PEM data in key input"),
399 expectHTTPListener: false,
400 expectTLSListener: false,
402 Entry("with an ipv6 invalid TLS cert", &newServerTableInput{
405 SecureBindAddress: "[::1]:0",
407 Key: &ipv6KeyDataSource,
408 Cert: &options.SecretSource{
409 Value: []byte("invalid"),
413 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not parse certificate data: tls: failed to find any PEM data in certificate input"),
414 expectHTTPListener: false,
415 expectTLSListener: false,
417 Entry("with an ipv6 address, with no TLS key", &newServerTableInput{
420 SecureBindAddress: "[::1]:0",
422 Cert: &ipv6CertDataSource,
425 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not load key data: no configuration provided"),
426 expectHTTPListener: false,
427 expectTLSListener: false,
429 Entry("with an ipv6 address, with no TLS cert", &newServerTableInput{
432 SecureBindAddress: "[::1]:0",
434 Key: &ipv6KeyDataSource,
437 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not load cert data: no configuration provided"),
438 expectHTTPListener: false,
439 expectTLSListener: false,
441 Entry("when the ipv6 bind address is prefixed with the http scheme", &newServerTableInput{
444 BindAddress: "http://[::1]:0",
447 expectHTTPListener: true,
448 expectTLSListener: false,
450 Entry("when the ipv6 secure bind address is prefixed with the https scheme", &newServerTableInput{
453 SecureBindAddress: "https://[::1]:0",
455 Key: &ipv6KeyDataSource,
456 Cert: &ipv6CertDataSource,
460 expectHTTPListener: false,
461 expectTLSListener: true,
463 Entry("with an ipv6 valid https bind address, and valid TLS config with MinVersion", &newServerTableInput{
466 SecureBindAddress: "[::1]:0",
468 Key: &ipv6KeyDataSource,
469 Cert: &ipv6CertDataSource,
470 MinVersion: "TLS1.3",
474 expectHTTPListener: false,
475 expectTLSListener: true,
477 Entry("with an ipv6 valid https bind address, and invalid TLS config with unknown MinVersion", &newServerTableInput{
480 SecureBindAddress: "[::1]:0",
482 Key: &ipv6KeyDataSource,
483 Cert: &ipv6CertDataSource,
484 MinVersion: "TLS1.42",
487 expectedErr: errors.New("error setting up TLS listener: unknown TLS MinVersion config provided"),
488 expectHTTPListener: false,
489 expectTLSListener: true,
491 Entry("with an ipv6 valid https bind address, and valid TLS config with CipherSuites", &newServerTableInput{
494 SecureBindAddress: "[::1]:0",
496 Key: &ipv4KeyDataSource,
497 Cert: &ipv4CertDataSource,
498 CipherSuites: []string{
499 "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
500 "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
505 expectHTTPListener: false,
506 expectTLSListener: true,
508 Entry("with an ipv6 valid https bind address, and invalid TLS config with unknown CipherSuites", &newServerTableInput{
511 SecureBindAddress: "[::1]:0",
513 Key: &ipv4KeyDataSource,
514 Cert: &ipv4CertDataSource,
515 CipherSuites: []string{
516 "TLS_RSA_WITH_RC4_64_SHA",
517 "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
521 expectedErr: errors.New("error setting up TLS listener: could not parse cipher suites: unknown TLS cipher suite name specified \"TLS_RSA_WITH_RC4_64_SHA\""),
522 expectHTTPListener: false,
523 expectTLSListener: true,
528 Context("Start", func() {
530 var ctx context.Context
531 var cancel context.CancelFunc
534 ctx, cancel = context.WithCancel(context.Background())
541 Context("with an ipv4 http server", func() {
542 var listenAddr string
546 srv, err = NewServer(Opts{
548 BindAddress: "127.0.0.1:0",
550 Expect(err).ToNot(HaveOccurred())
552 s, ok := srv.(*server)
553 Expect(ok).To(BeTrue())
555 listenAddr = fmt.Sprintf("http://%s/", s.listener.Addr().String())
558 It("Starts the server and serves the handler", func() {
560 defer GinkgoRecover()
561 Expect(srv.Start(ctx)).To(Succeed())
564 resp, err := client.Get(listenAddr)
565 Expect(err).ToNot(HaveOccurred())
566 Expect(resp.StatusCode).To(Equal(http.StatusOK))
568 body, err := io.ReadAll(resp.Body)
569 Expect(err).ToNot(HaveOccurred())
570 Expect(string(body)).To(Equal(hello))
573 It("Stops the server when the context is cancelled", func() {
575 defer GinkgoRecover()
576 Expect(srv.Start(ctx)).To(Succeed())
579 _, err := client.Get(listenAddr)
580 Expect(err).ToNot(HaveOccurred())
584 Eventually(func() error {
585 _, err := client.Get(listenAddr)
587 }).Should(HaveOccurred())
591 Context("with an ipv4 https server", func() {
592 var secureListenAddr string
596 srv, err = NewServer(Opts{
598 SecureBindAddress: "127.0.0.1:0",
600 Key: &ipv4KeyDataSource,
601 Cert: &ipv4CertDataSource,
604 Expect(err).ToNot(HaveOccurred())
606 s, ok := srv.(*server)
607 Expect(ok).To(BeTrue())
609 secureListenAddr = fmt.Sprintf("https://%s/", s.tlsListener.Addr().String())
612 It("Starts the server and serves the handler", func() {
614 defer GinkgoRecover()
615 Expect(srv.Start(ctx)).To(Succeed())
618 resp, err := client.Get(secureListenAddr)
619 Expect(err).ToNot(HaveOccurred())
620 Expect(resp.StatusCode).To(Equal(http.StatusOK))
622 body, err := io.ReadAll(resp.Body)
623 Expect(err).ToNot(HaveOccurred())
624 Expect(string(body)).To(Equal(hello))
627 It("Stops the server when the context is cancelled", func() {
629 defer GinkgoRecover()
630 Expect(srv.Start(ctx)).To(Succeed())
633 _, err := client.Get(secureListenAddr)
634 Expect(err).ToNot(HaveOccurred())
638 Eventually(func() error {
639 _, err := client.Get(secureListenAddr)
641 }).Should(HaveOccurred())
644 It("Serves the certificate provided", func() {
646 defer GinkgoRecover()
647 Expect(srv.Start(ctx)).To(Succeed())
650 resp, err := client.Get(secureListenAddr)
651 Expect(err).ToNot(HaveOccurred())
652 Expect(resp.StatusCode).To(Equal(http.StatusOK))
654 Expect(resp.TLS.VerifiedChains).Should(HaveLen(1))
655 Expect(resp.TLS.VerifiedChains[0]).Should(HaveLen(1))
656 Expect(resp.TLS.VerifiedChains[0][0].Raw).Should(Equal(ipv4CertData))
660 Context("with both an ipv4 http and an ipv4 https server", func() {
661 var listenAddr, secureListenAddr string
665 srv, err = NewServer(Opts{
667 BindAddress: "127.0.0.1:0",
668 SecureBindAddress: "127.0.0.1:0",
670 Key: &ipv4KeyDataSource,
671 Cert: &ipv4CertDataSource,
674 Expect(err).ToNot(HaveOccurred())
676 s, ok := srv.(*server)
677 Expect(ok).To(BeTrue())
679 listenAddr = fmt.Sprintf("http://%s/", s.listener.Addr().String())
680 secureListenAddr = fmt.Sprintf("https://%s/", s.tlsListener.Addr().String())
683 It("Starts the server and serves the handler on http", func() {
685 defer GinkgoRecover()
686 Expect(srv.Start(ctx)).To(Succeed())
689 resp, err := client.Get(listenAddr)
690 Expect(err).ToNot(HaveOccurred())
691 Expect(resp.StatusCode).To(Equal(http.StatusOK))
693 body, err := io.ReadAll(resp.Body)
694 Expect(err).ToNot(HaveOccurred())
695 Expect(string(body)).To(Equal(hello))
698 It("Starts the server and serves the handler on https", func() {
700 defer GinkgoRecover()
701 Expect(srv.Start(ctx)).To(Succeed())
704 resp, err := client.Get(secureListenAddr)
705 Expect(err).ToNot(HaveOccurred())
706 Expect(resp.StatusCode).To(Equal(http.StatusOK))
708 body, err := io.ReadAll(resp.Body)
709 Expect(err).ToNot(HaveOccurred())
710 Expect(string(body)).To(Equal(hello))
713 It("Stops both servers when the context is cancelled", func() {
715 defer GinkgoRecover()
716 Expect(srv.Start(ctx)).To(Succeed())
719 _, err := client.Get(listenAddr)
720 Expect(err).ToNot(HaveOccurred())
721 _, err = client.Get(secureListenAddr)
722 Expect(err).ToNot(HaveOccurred())
726 Eventually(func() error {
727 _, err := client.Get(listenAddr)
729 }).Should(HaveOccurred())
730 Eventually(func() error {
731 _, err := client.Get(secureListenAddr)
733 }).Should(HaveOccurred())
737 Context("with an ipv6 http server", func() {
738 var listenAddr string
742 srv, err = NewServer(Opts{
744 BindAddress: "[::1]:0",
746 Expect(err).ToNot(HaveOccurred())
748 s, ok := srv.(*server)
749 Expect(ok).To(BeTrue())
751 listenAddr = fmt.Sprintf("http://%s/", s.listener.Addr().String())
754 It("Starts the server and serves the handler", func() {
756 defer GinkgoRecover()
757 Expect(srv.Start(ctx)).To(Succeed())
760 resp, err := client.Get(listenAddr)
761 Expect(err).ToNot(HaveOccurred())
762 Expect(resp.StatusCode).To(Equal(http.StatusOK))
764 body, err := io.ReadAll(resp.Body)
765 Expect(err).ToNot(HaveOccurred())
766 Expect(string(body)).To(Equal(hello))
769 It("Stops the server when the context is cancelled", func() {
771 defer GinkgoRecover()
772 Expect(srv.Start(ctx)).To(Succeed())
775 _, err := client.Get(listenAddr)
776 Expect(err).ToNot(HaveOccurred())
780 Eventually(func() error {
781 _, err := client.Get(listenAddr)
783 }).Should(HaveOccurred())
787 Context("with an ipv6 https server", func() {
788 var secureListenAddr string
792 srv, err = NewServer(Opts{
794 SecureBindAddress: "[::1]:0",
796 Key: &ipv6KeyDataSource,
797 Cert: &ipv6CertDataSource,
800 Expect(err).ToNot(HaveOccurred())
802 s, ok := srv.(*server)
803 Expect(ok).To(BeTrue())
805 secureListenAddr = fmt.Sprintf("https://%s/", s.tlsListener.Addr().String())
808 It("Starts the server and serves the handler", func() {
810 defer GinkgoRecover()
811 Expect(srv.Start(ctx)).To(Succeed())
814 resp, err := client.Get(secureListenAddr)
815 Expect(err).ToNot(HaveOccurred())
816 Expect(resp.StatusCode).To(Equal(http.StatusOK))
818 body, err := io.ReadAll(resp.Body)
819 Expect(err).ToNot(HaveOccurred())
820 Expect(string(body)).To(Equal(hello))
823 It("Stops the server when the context is cancelled", func() {
825 defer GinkgoRecover()
826 Expect(srv.Start(ctx)).To(Succeed())
829 _, err := client.Get(secureListenAddr)
830 Expect(err).ToNot(HaveOccurred())
834 Eventually(func() error {
835 _, err := client.Get(secureListenAddr)
837 }).Should(HaveOccurred())
840 It("Serves the certificate provided", func() {
842 defer GinkgoRecover()
843 Expect(srv.Start(ctx)).To(Succeed())
846 resp, err := client.Get(secureListenAddr)
847 Expect(err).ToNot(HaveOccurred())
848 Expect(resp.StatusCode).To(Equal(http.StatusOK))
850 Expect(resp.TLS.VerifiedChains).Should(HaveLen(1))
851 Expect(resp.TLS.VerifiedChains[0]).Should(HaveLen(1))
852 Expect(resp.TLS.VerifiedChains[0][0].Raw).Should(Equal(ipv6CertData))
856 Context("with both an ipv6 http and an ipv6 https server", func() {
857 var listenAddr, secureListenAddr string
861 srv, err = NewServer(Opts{
863 BindAddress: "[::1]:0",
864 SecureBindAddress: "[::1]:0",
866 Key: &ipv6KeyDataSource,
867 Cert: &ipv6CertDataSource,
870 Expect(err).ToNot(HaveOccurred())
872 s, ok := srv.(*server)
873 Expect(ok).To(BeTrue())
875 listenAddr = fmt.Sprintf("http://%s/", s.listener.Addr().String())
876 secureListenAddr = fmt.Sprintf("https://%s/", s.tlsListener.Addr().String())
879 It("Starts the server and serves the handler on http", func() {
881 defer GinkgoRecover()
882 Expect(srv.Start(ctx)).To(Succeed())
885 resp, err := client.Get(listenAddr)
886 Expect(err).ToNot(HaveOccurred())
887 Expect(resp.StatusCode).To(Equal(http.StatusOK))
889 body, err := io.ReadAll(resp.Body)
890 Expect(err).ToNot(HaveOccurred())
891 Expect(string(body)).To(Equal(hello))
894 It("Starts the server and serves the handler on https", func() {
896 defer GinkgoRecover()
897 Expect(srv.Start(ctx)).To(Succeed())
900 resp, err := client.Get(secureListenAddr)
901 Expect(err).ToNot(HaveOccurred())
902 Expect(resp.StatusCode).To(Equal(http.StatusOK))
904 body, err := io.ReadAll(resp.Body)
905 Expect(err).ToNot(HaveOccurred())
906 Expect(string(body)).To(Equal(hello))
909 It("Stops both servers when the context is cancelled", func() {
911 defer GinkgoRecover()
912 Expect(srv.Start(ctx)).To(Succeed())
915 _, err := client.Get(listenAddr)
916 Expect(err).ToNot(HaveOccurred())
917 _, err = client.Get(secureListenAddr)
918 Expect(err).ToNot(HaveOccurred())
922 Eventually(func() error {
923 _, err := client.Get(listenAddr)
925 }).Should(HaveOccurred())
926 Eventually(func() error {
927 _, err := client.Get(secureListenAddr)
929 }).Should(HaveOccurred())
934 Context("getNetworkScheme", func() {
935 DescribeTable("should return the scheme", func(in, expected string) {
936 Expect(getNetworkScheme(in)).To(Equal(expected))
938 Entry("ipv4 address with no scheme", "127.0.0.1:0", "tcp"),
939 Entry("ipv4 address with a tcp scheme", "tcp://127.0.0.1:0", "tcp"),
940 Entry("ipv4 address with a http scheme", "http://192.168.0.1:1", "tcp"),
941 Entry("ipv4 address with a unix scheme", "unix://172.168.16.2:2", "unix"),
942 Entry("ipv4 address with a random scheme", "random://10.10.10.10:10", "random"),
943 Entry("ipv6 address with no scheme", "[::1]:0", "tcp"),
944 Entry("ipv6 address with a tcp scheme", "tcp://[::1]:0", "tcp"),
945 Entry("ipv6 address with a http scheme", "http://[::ffff:c0a8:1]:1", "tcp"),
946 Entry("ipv6 address with a unix scheme", "unix://[::ffff:aca8:1002]:2", "unix"),
947 Entry("ipv6 address with a random scheme", "random://[::ffff:a0a:a0a]:10", "random"),
951 Context("getListenAddress", func() {
952 DescribeTable("should remove the scheme", func(in, expected string) {
953 Expect(getListenAddress(in)).To(Equal(expected))
955 Entry("ipv4 address with no scheme", "127.0.0.1:0", "127.0.0.1:0"),
956 Entry("ipv4 address with a tcp scheme", "tcp://127.0.0.1:0", "127.0.0.1:0"),
957 Entry("ipv4 address with a http scheme", "http://192.168.0.1:1", "192.168.0.1:1"),
958 Entry("ipv4 address with a unix scheme", "unix://172.168.16.2:2", "172.168.16.2:2"),
959 Entry("ipv4 address with a random scheme", "random://10.10.10.10:10", "10.10.10.10:10"),
960 Entry("ipv6 address with no scheme", "[::1]:0", "[::1]:0"),
961 Entry("ipv6 address with a tcp scheme", "tcp://[::1]:0", "[::1]:0"),
962 Entry("ipv6 address with a http scheme", "http://[::ffff:c0a8:1]:1", "[::ffff:c0a8:1]:1"),
963 Entry("ipv6 address with a unix scheme", "unix://[::ffff:aca8:1002]:2", "[::ffff:aca8:1002]:2"),
964 Entry("ipv6 address with a random scheme", "random://[::ffff:a0a:a0a]:10", "[::ffff:a0a:a0a]:10"),
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list