dd0e8eec14
* copyright headers for agent folder * Ignore test data files * fix proto files and remove headers in agent/uiserver folder * ignore deep-copy files
66 lines
1.8 KiB
Go
66 lines
1.8 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
//go:build !consulent
|
|
// +build !consulent
|
|
|
|
package peering_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/hashicorp/consul/proto/private/pbpeering"
|
|
)
|
|
|
|
func TestPeeringService_RejectsPartition(t *testing.T) {
|
|
s := newTestServer(t, nil)
|
|
client := pbpeering.NewPeeringServiceClient(s.ClientConn(t))
|
|
|
|
t.Run("read", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
req := &pbpeering.PeeringReadRequest{Name: "foo", Partition: "test"}
|
|
resp, err := client.PeeringRead(ctx, req)
|
|
require.Contains(t, err.Error(), "Partitions are a Consul Enterprise feature")
|
|
require.Nil(t, resp)
|
|
})
|
|
|
|
t.Run("list", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
req := &pbpeering.PeeringListRequest{Partition: "test"}
|
|
resp, err := client.PeeringList(ctx, req)
|
|
require.Contains(t, err.Error(), "Partitions are a Consul Enterprise feature")
|
|
require.Nil(t, resp)
|
|
})
|
|
}
|
|
|
|
func TestPeeringService_IgnoresDefaultPartition(t *testing.T) {
|
|
s := newTestServer(t, nil)
|
|
client := pbpeering.NewPeeringServiceClient(s.ClientConn(t))
|
|
|
|
t.Run("read", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
req := &pbpeering.PeeringReadRequest{Name: "foo", Partition: "DeFaUlT"}
|
|
_, err := client.PeeringRead(ctx, req)
|
|
require.NoError(t, err)
|
|
})
|
|
|
|
t.Run("list", func(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
t.Cleanup(cancel)
|
|
|
|
req := &pbpeering.PeeringListRequest{Partition: "DeFaUlT"}
|
|
_, err := client.PeeringList(ctx, req)
|
|
require.NoError(t, err)
|
|
})
|
|
}
|