Skip to content

Commit

Permalink
test(target): Update TestAuthorizeSession to check session connection…
Browse files Browse the repository at this point in the history
… limit
  • Loading branch information
dkanney committed Dec 26, 2024
1 parent 6267234 commit 978ee1f
Showing 1 changed file with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3547,32 +3547,36 @@ func TestAuthorizeSession(t *testing.T) {

const defaultPort = 2
cases := []struct {
name string
hostSourceId string
credSourceId string
wantedHostId string
wantedEndpoint string
name string
hostSourceId string
credSourceId string
wantedHostId string
wantedEndpoint string
wantedConnectionLimit int32
}{
{
name: "static host",
hostSourceId: shs.GetPublicId(),
credSourceId: clsResp.GetItem().GetId(),
wantedHostId: h.GetPublicId(),
wantedEndpoint: fmt.Sprintf("%s:%d", h.GetAddress(), defaultPort),
name: "static host",
hostSourceId: shs.GetPublicId(),
credSourceId: clsResp.GetItem().GetId(),
wantedHostId: h.GetPublicId(),
wantedEndpoint: fmt.Sprintf("%s:%d", h.GetAddress(), defaultPort),
wantedConnectionLimit: -1,
},
{
name: "static host with port defined",
hostSourceId: shsWithPort.GetPublicId(),
credSourceId: clsResp.GetItem().GetId(),
wantedHostId: hWithPort.GetPublicId(),
wantedEndpoint: fmt.Sprintf("%s:%d", hWithPortBareAddress, defaultPort),
name: "static host with port defined",
hostSourceId: shsWithPort.GetPublicId(),
credSourceId: clsResp.GetItem().GetId(),
wantedHostId: hWithPort.GetPublicId(),
wantedEndpoint: fmt.Sprintf("%s:%d", hWithPortBareAddress, defaultPort),
wantedConnectionLimit: -1,
},
{
name: "plugin host",
hostSourceId: phs.GetPublicId(),
credSourceId: clsResp.GetItem().GetId(),
wantedHostId: "?",
wantedEndpoint: fmt.Sprintf("10.0.0.1:%d", defaultPort),
name: "plugin host",
hostSourceId: phs.GetPublicId(),
credSourceId: clsResp.GetItem().GetId(),
wantedHostId: "?",
wantedEndpoint: fmt.Sprintf("10.0.0.1:%d", defaultPort),
wantedConnectionLimit: 2,
},
}

Expand All @@ -3588,7 +3592,7 @@ func TestAuthorizeSession(t *testing.T) {
ctx, err = event.NewCorrelationIdContext(ctx, corId)
require.NoError(t, err)

tar := tcp.TestTarget(ctx, t, conn, proj.GetPublicId(), tc.name, target.WithDefaultPort(defaultPort))
tar := tcp.TestTarget(ctx, t, conn, proj.GetPublicId(), tc.name, target.WithDefaultPort(defaultPort), target.WithSessionConnectionLimit(tc.wantedConnectionLimit))
apiTar, err := s.AddTargetHostSources(ctx, &pbs.AddTargetHostSourcesRequest{
Id: tar.GetPublicId(),
Version: tar.GetVersion(),
Expand Down Expand Up @@ -3660,7 +3664,8 @@ func TestAuthorizeSession(t *testing.T) {
},
},
},
EndpointPort: uint32(defaultPort),
EndpointPort: uint32(defaultPort),
ConnectionLimit: int32(tc.wantedConnectionLimit),
// TODO: validate the contents of the authorization token is what is expected
}
wantSecret := map[string]any{
Expand Down

0 comments on commit 978ee1f

Please sign in to comment.