mirror of https://github.com/hashicorp/consul
dns v2 - both empty string and default should be allowed for namespace and partition in Ce
parent
ad9ada883c
commit
8513eda629
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue