dns v2 - both empty string and default should be allowed for namespace and partition in Ce

pull/21230/head
John Murret 2024-05-28 14:18:30 -06:00
parent ad9ada883c
commit 8513eda629
3 changed files with 55 additions and 1 deletions

View File

@ -424,6 +424,7 @@ RPC:
}
func (f *V1DataFetcher) ValidateRequest(_ Context, req *QueryPayload) error {
f.logger.Debug(fmt.Sprintf("req %+v", req))
if req.EnableFailover {
return ErrNotSupported
}

View File

@ -15,7 +15,7 @@ func (f *V1DataFetcher) NormalizeRequest(req *QueryPayload) {
}
func validateEnterpriseTenancy(req QueryTenancy) error {
if req.Namespace != "" || req.Partition != acl.DefaultPartitionName {
if !(req.Namespace == "" || req.Namespace == acl.DefaultNamespaceName) || !(req.Partition == acl.DefaultPartitionName || req.Partition == "default") {
return ErrNotSupported
}
return nil

View File

@ -5,7 +5,60 @@
package discovery
import (
"github.com/stretchr/testify/require"
"testing"
)
const (
defaultTestNamespace = ""
defaultTestPartition = ""
)
func Test_validateEnterpriseTenancy(t *testing.T) {
testCases := []struct {
name string
req QueryTenancy
expected error
}{
{
name: "empty namespace and partition returns no error",
req: QueryTenancy{
Namespace: defaultTestNamespace,
Partition: defaultTestPartition,
},
expected: nil,
},
{
name: "namespace and partition set to 'default' returns no error",
req: QueryTenancy{
Namespace: "default",
Partition: "default",
},
expected: nil,
},
{
name: "namespace set to something other than empty string or `default` returns not supported error",
req: QueryTenancy{
Namespace: "namespace-1",
Partition: "default",
},
expected: ErrNotSupported,
},
{
name: "partition set to something other than empty string or `default` returns not supported error",
req: QueryTenancy{
Namespace: "default",
Partition: "partition-1",
},
expected: ErrNotSupported,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := validateEnterpriseTenancy(tc.req)
require.Equal(t, tc.expected, err)
})
}
}