@@ -20,6 +20,7 @@ import (
2020 "context"
2121 "crypto/tls"
2222 "fmt"
23+ "strings"
2324 "testing"
2425
2526 "github.com/go-logr/logr"
@@ -752,6 +753,79 @@ func TestProxyURLFromSecret(t *testing.T) {
752753 ),
753754 errMsg : "secret 'default/proxy-secret': failed to parse proxy address" ,
754755 },
756+ {
757+ name : "socks5 proxy" ,
758+ secret : testSecret (
759+ withName ("proxy-secret" ),
760+ withData (map [string ][]byte {
761+ secrets .KeyAddress : []byte ("socks5://socks-proxy.example.com:1080" ),
762+ }),
763+ ),
764+ wantURL : "socks5://socks-proxy.example.com:1080" ,
765+ },
766+ {
767+ name : "socks5 proxy with authentication" ,
768+ secret : testSecret (
769+ withName ("proxy-secret" ),
770+ withData (map [string ][]byte {
771+ secrets .KeyAddress : []byte ("socks5://socks-proxy.example.com:1080" ),
772+ secrets .KeyUsername : []byte ("sockuser" ),
773+ secrets .KeyPassword : []byte ("sockpass" ),
774+ }),
775+ ),
776+ wantURL : "socks5://sockuser:sockpass@socks-proxy.example.com:1080" ,
777+ },
778+ {
779+ name : "unsupported scheme - ftp" ,
780+ secret : testSecret (
781+ withName ("proxy-secret" ),
782+ withData (map [string ][]byte {
783+ secrets .KeyAddress : []byte ("ftp://ftp.example.com:21" ),
784+ }),
785+ ),
786+ errMsg : "proxy URL must use one of the supported schemes (http, https, socks5), got 'ftp'" ,
787+ },
788+ {
789+ name : "unsupported scheme - socks4" ,
790+ secret : testSecret (
791+ withName ("proxy-secret" ),
792+ withData (map [string ][]byte {
793+ secrets .KeyAddress : []byte ("socks4://proxy.example.com:1080" ),
794+ }),
795+ ),
796+ errMsg : "proxy URL must use one of the supported schemes (http, https, socks5), got 'socks4'" ,
797+ },
798+ {
799+ name : "URL exceeds maximum length" ,
800+ secret : testSecret (
801+ withName ("proxy-secret" ),
802+ withData (map [string ][]byte {
803+ secrets .KeyAddress : []byte ("http://" + strings .Repeat ("a" , 2050 )),
804+ }),
805+ ),
806+ errMsg : "proxy URL exceeds maximum length of 2048 characters" ,
807+ },
808+ {
809+ name : "URL at maximum length boundary" ,
810+ secret : testSecret (
811+ withName ("proxy-secret" ),
812+ withData (map [string ][]byte {
813+ // Create a URL exactly 2048 characters (http:// = 7 chars, so 2041 'a's)
814+ secrets .KeyAddress : []byte ("http://" + strings .Repeat ("a" , 2041 )),
815+ }),
816+ ),
817+ wantURL : "http://" + strings .Repeat ("a" , 2041 ),
818+ },
819+ {
820+ name : "missing scheme" ,
821+ secret : testSecret (
822+ withName ("proxy-secret" ),
823+ withData (map [string ][]byte {
824+ secrets .KeyAddress : []byte ("//proxy.example.com:8080" ),
825+ }),
826+ ),
827+ errMsg : "proxy URL must use one of the supported schemes (http, https, socks5), got ''" ,
828+ },
755829 }
756830
757831 for _ , tt := range tests {
0 commit comments