@@ -6,6 +6,7 @@ import (
66 "fmt"
77 "io"
88 "net/http"
9+ "os"
910
1011 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
1112 . "github.com/onsi/ginkgo"
@@ -26,9 +27,13 @@ var _ = Describe("Server", func() {
2627 expectedErr error
2728 expectHTTPListener bool
2829 expectTLSListener bool
30+ ipv6 bool
2931 }
3032
3133 DescribeTable("When creating the new server from the options", func(in *newServerTableInput) {
34+ if in.ipv6 {
35+ skipDevContainer()
36+ }
3237 srv, err := NewServer(in.opts)
3338 if in.expectedErr != nil {
3439 Expect(err).To(MatchError(ContainSubstring(in.expectedErr.Error())))
@@ -303,6 +308,7 @@ var _ = Describe("Server", func() {
303308 expectedErr: nil,
304309 expectHTTPListener: true,
305310 expectTLSListener: false,
311+ ipv6: true,
306312 }),
307313 Entry("with an ipv6 valid https bind address, with no TLS config", &newServerTableInput{
308314 opts: Opts{
@@ -312,6 +318,7 @@ var _ = Describe("Server", func() {
312318 expectedErr: errors.New("error setting up TLS listener: no TLS config provided"),
313319 expectHTTPListener: false,
314320 expectTLSListener: false,
321+ ipv6: true,
315322 }),
316323 Entry("with an ipv6 valid https bind address, and valid TLS config", &newServerTableInput{
317324 opts: Opts{
@@ -325,6 +332,7 @@ var _ = Describe("Server", func() {
325332 expectedErr: nil,
326333 expectHTTPListener: false,
327334 expectTLSListener: true,
335+ ipv6: true,
328336 }),
329337 Entry("with a both a ipv6 valid http and ipv6 valid https bind address, and valid TLS config", &newServerTableInput{
330338 opts: Opts{
@@ -339,6 +347,7 @@ var _ = Describe("Server", func() {
339347 expectedErr: nil,
340348 expectHTTPListener: true,
341349 expectTLSListener: true,
350+ ipv6: true,
342351 }),
343352 Entry("with an ipv6 invalid bind address scheme", &newServerTableInput{
344353 opts: Opts{
@@ -348,6 +357,7 @@ var _ = Describe("Server", func() {
348357 expectedErr: errors.New("error setting up listener: listen (invalid, [::1]:0) failed: listen invalid: unknown network invalid"),
349358 expectHTTPListener: false,
350359 expectTLSListener: false,
360+ ipv6: true,
351361 }),
352362 Entry("with an ipv6 invalid secure bind address scheme", &newServerTableInput{
353363 opts: Opts{
@@ -361,6 +371,7 @@ var _ = Describe("Server", func() {
361371 expectedErr: nil,
362372 expectHTTPListener: false,
363373 expectTLSListener: true,
374+ ipv6: true,
364375 }),
365376 Entry("with an ipv6 invalid bind address port", &newServerTableInput{
366377 opts: Opts{
@@ -370,6 +381,7 @@ var _ = Describe("Server", func() {
370381 expectedErr: errors.New("error setting up listener: listen (tcp, [::1]:a) failed: listen tcp: "),
371382 expectHTTPListener: false,
372383 expectTLSListener: false,
384+ ipv6: true,
373385 }),
374386 Entry("with an ipv6 invalid secure bind address port", &newServerTableInput{
375387 opts: Opts{
@@ -383,6 +395,7 @@ var _ = Describe("Server", func() {
383395 expectedErr: errors.New("error setting up TLS listener: listen ([::1]:a) failed: listen tcp: "),
384396 expectHTTPListener: false,
385397 expectTLSListener: false,
398+ ipv6: true,
386399 }),
387400 Entry("with an ipv6 invalid TLS key", &newServerTableInput{
388401 opts: Opts{
@@ -398,6 +411,7 @@ var _ = Describe("Server", func() {
398411 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"),
399412 expectHTTPListener: false,
400413 expectTLSListener: false,
414+ ipv6: true,
401415 }),
402416 Entry("with an ipv6 invalid TLS cert", &newServerTableInput{
403417 opts: Opts{
@@ -413,6 +427,7 @@ var _ = Describe("Server", func() {
413427 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"),
414428 expectHTTPListener: false,
415429 expectTLSListener: false,
430+ ipv6: true,
416431 }),
417432 Entry("with an ipv6 address, with no TLS key", &newServerTableInput{
418433 opts: Opts{
@@ -425,6 +440,7 @@ var _ = Describe("Server", func() {
425440 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not load key data: no configuration provided"),
426441 expectHTTPListener: false,
427442 expectTLSListener: false,
443+ ipv6: true,
428444 }),
429445 Entry("with an ipv6 address, with no TLS cert", &newServerTableInput{
430446 opts: Opts{
@@ -437,6 +453,7 @@ var _ = Describe("Server", func() {
437453 expectedErr: errors.New("error setting up TLS listener: could not load certificate: could not load cert data: no configuration provided"),
438454 expectHTTPListener: false,
439455 expectTLSListener: false,
456+ ipv6: true,
440457 }),
441458 Entry("when the ipv6 bind address is prefixed with the http scheme", &newServerTableInput{
442459 opts: Opts{
@@ -446,6 +463,7 @@ var _ = Describe("Server", func() {
446463 expectedErr: nil,
447464 expectHTTPListener: true,
448465 expectTLSListener: false,
466+ ipv6: true,
449467 }),
450468 Entry("when the ipv6 secure bind address is prefixed with the https scheme", &newServerTableInput{
451469 opts: Opts{
@@ -459,6 +477,7 @@ var _ = Describe("Server", func() {
459477 expectedErr: nil,
460478 expectHTTPListener: false,
461479 expectTLSListener: true,
480+ ipv6: true,
462481 }),
463482 Entry("with an ipv6 valid https bind address, and valid TLS config with MinVersion", &newServerTableInput{
464483 opts: Opts{
@@ -473,6 +492,7 @@ var _ = Describe("Server", func() {
473492 expectedErr: nil,
474493 expectHTTPListener: false,
475494 expectTLSListener: true,
495+ ipv6: true,
476496 }),
477497 Entry("with an ipv6 valid https bind address, and invalid TLS config with unknown MinVersion", &newServerTableInput{
478498 opts: Opts{
@@ -487,6 +507,7 @@ var _ = Describe("Server", func() {
487507 expectedErr: errors.New("error setting up TLS listener: unknown TLS MinVersion config provided"),
488508 expectHTTPListener: false,
489509 expectTLSListener: true,
510+ ipv6: true,
490511 }),
491512 Entry("with an ipv6 valid https bind address, and valid TLS config with CipherSuites", &newServerTableInput{
492513 opts: Opts{
@@ -504,6 +525,7 @@ var _ = Describe("Server", func() {
504525 expectedErr: nil,
505526 expectHTTPListener: false,
506527 expectTLSListener: true,
528+ ipv6: true,
507529 }),
508530 Entry("with an ipv6 valid https bind address, and invalid TLS config with unknown CipherSuites", &newServerTableInput{
509531 opts: Opts{
@@ -521,6 +543,7 @@ var _ = Describe("Server", func() {
521543 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\""),
522544 expectHTTPListener: false,
523545 expectTLSListener: true,
546+ ipv6: true,
524547 }),
525548 )
526549 })
@@ -738,6 +761,7 @@ var _ = Describe("Server", func() {
738761 var listenAddr string
739762
740763 BeforeEach(func() {
764+ skipDevContainer()
741765 var err error
742766 srv, err = NewServer(Opts{
743767 Handler: handler,
@@ -788,6 +812,7 @@ var _ = Describe("Server", func() {
788812 var secureListenAddr string
789813
790814 BeforeEach(func() {
815+ skipDevContainer()
791816 var err error
792817 srv, err = NewServer(Opts{
793818 Handler: handler,
@@ -857,6 +882,7 @@ var _ = Describe("Server", func() {
857882 var listenAddr, secureListenAddr string
858883
859884 BeforeEach(func() {
885+ skipDevContainer()
860886 var err error
861887 srv, err = NewServer(Opts{
862888 Handler: handler,
@@ -965,3 +991,9 @@ var _ = Describe("Server", func() {
965991 )
966992 })
967993})
994+
995+func skipDevContainer() {
996+ if os.Getenv("DEVCONTAINER") != "" {
997+ Skip("Skipping testing in DevContainer environment")
998+ }
999+}