File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 22
33## [ master] ( https://github.com/arangodb/kube-arangodb/tree/master ) (N/A)
44- (Improvement) Block traffic on the services if there is more than 1 active leader in ActiveFailover mode
5+ - (Improvement) Improve master endpoint validation.
56
67## [ 1.2.30] ( https://github.com/arangodb/kube-arangodb/tree/1.2.30 ) (2023-06-16)
78- (Feature) AgencyCache Interface
Original file line number Diff line number Diff line change @@ -63,8 +63,15 @@ func (s SyncExternalAccessSpec) Validate() error {
6363 return errors .WithStack (err )
6464 }
6565 for _ , ep := range s .MasterEndpoint {
66- if _ , err := url .Parse (ep ); err != nil {
66+ if u , err := url .Parse (ep ); err != nil {
6767 return errors .WithStack (errors .Newf ("Failed to parse master endpoint '%s': %s" , ep , err ))
68+ } else {
69+ if u .Scheme != "http" && u .Scheme != "https" {
70+ return errors .WithStack (errors .Newf ("Invalid scheme '%s' in master endpoint '%s'" , u .Scheme , ep ))
71+ }
72+ if u .Host == "" {
73+ return errors .WithStack (errors .Newf ("Missing host in master endpoint '%s'" , ep ))
74+ }
6875 }
6976 }
7077 for _ , name := range s .AccessPackageSecretNames {
Original file line number Diff line number Diff line change @@ -102,3 +102,37 @@ func TestSyncSpecResetImmutableFields(t *testing.T) {
102102 assert .Equal (t , test .Expected , test .Target )
103103 }
104104}
105+
106+ func TestSyncSpecMasterEndpointValidate (t * testing.T ) {
107+ auth := SyncAuthenticationSpec {
108+ JWTSecretName : util.NewType [string ]("foo" ),
109+ ClientCASecretName : util.NewType [string ]("foo-client" ),
110+ }
111+ tls := TLSSpec {
112+ CASecretName : util.NewType [string ]("None" ),
113+ }
114+ t .Run ("Valid MasterEndpoint" , func (t * testing.T ) {
115+ err := SyncSpec {
116+ Authentication : auth ,
117+ TLS : tls ,
118+ ExternalAccess : SyncExternalAccessSpec {
119+ MasterEndpoint : []string {"https://arangodb.xyz:8629" },
120+ },
121+ Enabled : util.NewType [bool ](true ),
122+ }.Validate (DeploymentModeCluster )
123+ assert .Nil (t , err )
124+ })
125+
126+ t .Run ("Invalid MasterEndpoint without protocol" , func (t * testing.T ) {
127+ err := SyncSpec {
128+ Authentication : auth ,
129+ TLS : tls ,
130+ ExternalAccess : SyncExternalAccessSpec {
131+ MasterEndpoint : []string {"example.com:8629" },
132+ },
133+ Enabled : util.NewType [bool ](true ),
134+ }.Validate (DeploymentModeCluster )
135+ assert .Error (t , err )
136+ assert .Equal (t , "Invalid scheme 'example.com' in master endpoint 'example.com:8629'" , err .Error ())
137+ })
138+ }
You can’t perform that action at this time.
0 commit comments