Rename connection idle timeout duration -> seconds and sessions max duration -> seconds (#376)
This commit is contained in:
1 parent
62baef1b7e
commit
0a3f9b8357
19 files changed
+399
-401
No files matched your search
@@ -351,7 +351,7 @@ HOST_GATHERING_DONE:
|
||||
}
|
||||
|
||||
expTime := timestamppb.Now()
|
||||
expTime.Seconds += int64(t.GetSessionMaxDuration())
|
||||
expTime.Seconds += int64(t.GetSessionMaxSeconds())
|
||||
sessionComposition := session.ComposedOf{
|
||||
UserId: authResults.UserId,
|
||||
HostId: chosenId.hostId,
|
||||
@@ -362,7 +362,7 @@ HOST_GATHERING_DONE:
|
||||
Endpoint: endpointUrl.String(),
|
||||
ExpirationTime: ×tamp.Timestamp{Timestamp: expTime},
|
||||
ConnectionLimit: t.GetSessionConnectionLimit(),
|
||||
ConnectionIdleTimeoutSeconds: t.GetConnectionIdleTimeoutDuration(),
|
||||
ConnectionIdleTimeoutSeconds: t.GetConnectionIdleTimeoutSeconds(),
|
||||
}
|
||||
|
||||
sess, err := session.New(sessionComposition)
|
||||
@@ -435,14 +435,14 @@ func (s Service) createInRepo(ctx context.Context, item *pb.Target) (*pb.Target,
|
||||
if item.GetDescription() != nil {
|
||||
opts = append(opts, target.WithDescription(item.GetDescription().GetValue()))
|
||||
}
|
||||
if item.GetSessionMaxDuration() != nil {
|
||||
opts = append(opts, target.WithSessionMaxDuration(item.GetSessionMaxDuration().GetValue()))
|
||||
if item.GetSessionMaxSeconds() != nil {
|
||||
opts = append(opts, target.WithSessionMaxSeconds(item.GetSessionMaxSeconds().GetValue()))
|
||||
}
|
||||
if item.GetSessionConnectionLimit() != nil {
|
||||
opts = append(opts, target.WithSessionConnectionLimit(item.GetSessionConnectionLimit().GetValue()))
|
||||
}
|
||||
if item.GetConnectionIdleTimeoutDuration() != nil {
|
||||
opts = append(opts, target.WithConnectionIdleTimeoutDuration(item.GetConnectionIdleTimeoutDuration().GetValue()))
|
||||
if item.GetConnectionIdleTimeoutSeconds() != nil {
|
||||
opts = append(opts, target.WithConnectionIdleTimeoutSeconds(item.GetConnectionIdleTimeoutSeconds().GetValue()))
|
||||
}
|
||||
tcpAttrs := &pb.TcpTargetAttributes{}
|
||||
if err := handlers.StructToProto(item.GetAttributes(), tcpAttrs); err != nil {
|
||||
@@ -477,14 +477,14 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, id string, mask []st
|
||||
if name := item.GetName(); name != nil {
|
||||
opts = append(opts, target.WithName(name.GetValue()))
|
||||
}
|
||||
if item.GetSessionMaxDuration() != nil {
|
||||
opts = append(opts, target.WithSessionMaxDuration(item.GetSessionMaxDuration().GetValue()))
|
||||
if item.GetSessionMaxSeconds() != nil {
|
||||
opts = append(opts, target.WithSessionMaxSeconds(item.GetSessionMaxSeconds().GetValue()))
|
||||
}
|
||||
if item.GetSessionConnectionLimit() != nil {
|
||||
opts = append(opts, target.WithSessionConnectionLimit(item.GetSessionConnectionLimit().GetValue()))
|
||||
}
|
||||
if item.GetConnectionIdleTimeoutDuration() != nil {
|
||||
opts = append(opts, target.WithConnectionIdleTimeoutDuration(item.GetConnectionIdleTimeoutDuration().GetValue()))
|
||||
if item.GetConnectionIdleTimeoutSeconds() != nil {
|
||||
opts = append(opts, target.WithConnectionIdleTimeoutSeconds(item.GetConnectionIdleTimeoutSeconds().GetValue()))
|
||||
}
|
||||
tcpAttrs := &pb.TcpTargetAttributes{}
|
||||
if err := handlers.StructToProto(item.GetAttributes(), tcpAttrs); err != nil {
|
||||
@@ -652,15 +652,15 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
|
||||
func toProto(in target.Target, m []*target.TargetSet) (*pb.Target, error) {
|
||||
out := pb.Target{
|
||||
Id: in.GetPublicId(),
|
||||
ScopeId: in.GetScopeId(),
|
||||
CreatedTime: in.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: in.GetUpdateTime().GetTimestamp(),
|
||||
Version: in.GetVersion(),
|
||||
Type: target.TcpTargetType.String(),
|
||||
SessionMaxDuration: &wrapperspb.UInt32Value{Value: in.GetSessionMaxDuration()},
|
||||
SessionConnectionLimit: &wrapperspb.UInt32Value{Value: in.GetSessionConnectionLimit()},
|
||||
ConnectionIdleTimeoutDuration: &wrapperspb.UInt32Value{Value: in.GetConnectionIdleTimeoutDuration()},
|
||||
Id: in.GetPublicId(),
|
||||
ScopeId: in.GetScopeId(),
|
||||
CreatedTime: in.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: in.GetUpdateTime().GetTimestamp(),
|
||||
Version: in.GetVersion(),
|
||||
Type: target.TcpTargetType.String(),
|
||||
SessionMaxSeconds: &wrapperspb.UInt32Value{Value: in.GetSessionMaxSeconds()},
|
||||
SessionConnectionLimit: &wrapperspb.UInt32Value{Value: in.GetSessionConnectionLimit()},
|
||||
ConnectionIdleTimeoutSeconds: &wrapperspb.UInt32Value{Value: in.GetConnectionIdleTimeoutSeconds()},
|
||||
}
|
||||
if in.GetDescription() != "" {
|
||||
out.Description = wrapperspb.String(in.GetDescription())
|
||||
|
||||
@@ -68,18 +68,18 @@ func TestGet(t *testing.T) {
|
||||
tar := target.TestTcpTarget(t, conn, proj.GetPublicId(), "test", target.WithHostSets([]string{hs[0].GetPublicId(), hs[1].GetPublicId()}))
|
||||
|
||||
pTar := &pb.Target{
|
||||
Id: tar.GetPublicId(),
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Name: wrapperspb.String("test"),
|
||||
CreatedTime: tar.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: tar.UpdateTime.GetTimestamp(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()},
|
||||
Type: target.TcpTargetType.String(),
|
||||
HostSetIds: []string{hs[0].GetPublicId(), hs[1].GetPublicId()},
|
||||
Attributes: new(structpb.Struct),
|
||||
SessionMaxDuration: &wrapperspb.UInt32Value{Value: 28800},
|
||||
ConnectionIdleTimeoutDuration: &wrapperspb.UInt32Value{Value: 3600},
|
||||
SessionConnectionLimit: &wrapperspb.UInt32Value{Value: 1},
|
||||
Id: tar.GetPublicId(),
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Name: wrapperspb.String("test"),
|
||||
CreatedTime: tar.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: tar.UpdateTime.GetTimestamp(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()},
|
||||
Type: target.TcpTargetType.String(),
|
||||
HostSetIds: []string{hs[0].GetPublicId(), hs[1].GetPublicId()},
|
||||
Attributes: new(structpb.Struct),
|
||||
SessionMaxSeconds: &wrapperspb.UInt32Value{Value: 28800},
|
||||
ConnectionIdleTimeoutSeconds: &wrapperspb.UInt32Value{Value: 3600},
|
||||
SessionConnectionLimit: &wrapperspb.UInt32Value{Value: 1},
|
||||
}
|
||||
for _, ihs := range hs {
|
||||
pTar.HostSets = append(pTar.HostSets, &pb.HostSet{Id: ihs.GetPublicId(), HostCatalogId: ihs.GetCatalogId()})
|
||||
@@ -149,18 +149,18 @@ func TestList(t *testing.T) {
|
||||
name := fmt.Sprintf("tar%d", i)
|
||||
tar := target.TestTcpTarget(t, conn, proj.GetPublicId(), name, target.WithHostSets([]string{hss[0].GetPublicId(), hss[1].GetPublicId()}))
|
||||
wantTars = append(wantTars, &pb.Target{
|
||||
Id: tar.GetPublicId(),
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Name: wrapperspb.String(name),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()},
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: tar.GetUpdateTime().GetTimestamp(),
|
||||
Version: tar.GetVersion(),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Attributes: new(structpb.Struct),
|
||||
SessionMaxDuration: &wrapperspb.UInt32Value{Value: 28800},
|
||||
ConnectionIdleTimeoutDuration: &wrapperspb.UInt32Value{Value: 3600},
|
||||
SessionConnectionLimit: &wrapperspb.UInt32Value{Value: 1},
|
||||
Id: tar.GetPublicId(),
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Name: wrapperspb.String(name),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()},
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: tar.GetUpdateTime().GetTimestamp(),
|
||||
Version: tar.GetVersion(),
|
||||
Type: target.TcpTargetType.String(),
|
||||
Attributes: new(structpb.Struct),
|
||||
SessionMaxSeconds: &wrapperspb.UInt32Value{Value: 28800},
|
||||
ConnectionIdleTimeoutSeconds: &wrapperspb.UInt32Value{Value: 3600},
|
||||
SessionConnectionLimit: &wrapperspb.UInt32Value{Value: 1},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -310,9 +310,9 @@ func TestCreate(t *testing.T) {
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
SessionMaxDuration: &wrapperspb.UInt32Value{Value: 28800},
|
||||
ConnectionIdleTimeoutDuration: &wrapperspb.UInt32Value{Value: 3600},
|
||||
SessionConnectionLimit: &wrapperspb.UInt32Value{Value: 1},
|
||||
SessionMaxSeconds: &wrapperspb.UInt32Value{Value: 28800},
|
||||
ConnectionIdleTimeoutSeconds: &wrapperspb.UInt32Value{Value: 3600},
|
||||
SessionConnectionLimit: &wrapperspb.UInt32Value{Value: 1},
|
||||
},
|
||||
},
|
||||
errCode: codes.OK,
|
||||
@@ -455,14 +455,14 @@ func TestUpdate(t *testing.T) {
|
||||
name: "Update an Existing Target",
|
||||
req: &pbs.UpdateTargetRequest{
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"name", "description", "session_max_duration", "connection_idle_timeout_duration", "session_connection_limit"},
|
||||
Paths: []string{"name", "description", "session_max_seconds", "connection_idle_timeout_seconds", "session_connection_limit"},
|
||||
},
|
||||
Item: &pb.Target{
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
SessionMaxDuration: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutDuration: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
Name: wrapperspb.String("name"),
|
||||
Description: wrapperspb.String("desc"),
|
||||
SessionMaxSeconds: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutSeconds: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateTargetResponse{
|
||||
@@ -476,12 +476,12 @@ func TestUpdate(t *testing.T) {
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxDuration: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutDuration: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
CreatedTime: tar.GetCreateTime().GetTimestamp(),
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxSeconds: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutSeconds: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
},
|
||||
},
|
||||
errCode: codes.OK,
|
||||
@@ -509,11 +509,11 @@ func TestUpdate(t *testing.T) {
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxDuration: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutDuration: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxSeconds: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutSeconds: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
},
|
||||
},
|
||||
errCode: codes.OK,
|
||||
@@ -595,11 +595,11 @@ func TestUpdate(t *testing.T) {
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxDuration: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutDuration: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxSeconds: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutSeconds: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
},
|
||||
},
|
||||
errCode: codes.OK,
|
||||
@@ -627,11 +627,11 @@ func TestUpdate(t *testing.T) {
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxDuration: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutDuration: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxSeconds: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutSeconds: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
},
|
||||
},
|
||||
errCode: codes.OK,
|
||||
@@ -658,12 +658,12 @@ func TestUpdate(t *testing.T) {
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"default_port": structpb.NewNumberValue(2),
|
||||
}},
|
||||
Type: target.TcpTargetType.String(),
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxDuration: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutDuration: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
Type: target.TcpTargetType.String(),
|
||||
HostSetIds: hsIds,
|
||||
HostSets: hostSets,
|
||||
SessionMaxSeconds: wrapperspb.UInt32(3600),
|
||||
ConnectionIdleTimeoutSeconds: wrapperspb.UInt32(180),
|
||||
SessionConnectionLimit: wrapperspb.UInt32(5),
|
||||
},
|
||||
},
|
||||
errCode: codes.OK,
|
||||
|
||||
Reference in new issue
Block a user