Skip to content

Commit

Permalink
Teleterm: add new access request fields (#39050)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa authored Mar 14, 2024
1 parent deeadc4 commit f33bbbf
Show file tree
Hide file tree
Showing 13 changed files with 1,501 additions and 1,102 deletions.
189 changes: 131 additions & 58 deletions gen/proto/go/teleport/lib/teleterm/v1/access_request.pb.go

Large diffs are not rendered by default.

2,101 changes: 1,089 additions & 1,012 deletions gen/proto/go/teleport/lib/teleterm/v1/service.pb.go

Large diffs are not rendered by default.

73 changes: 70 additions & 3 deletions gen/proto/ts/teleport/lib/teleterm/v1/access_request_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 78 additions & 2 deletions gen/proto/ts/teleport/lib/teleterm/v1/service_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/teleterm/apiserver/handler/handler_access_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func newAPIAccessRequest(req clusters.AccessRequest) *api.AccessRequest {
Reason: rev.Reason,
Created: timestamppb.New(rev.Created),
PromotedAccessListTitle: rev.GetAccessListTitle(),
AssumeStartTime: getProtoTimestamp(rev.AssumeStartTime),
})
}

Expand Down Expand Up @@ -214,6 +215,10 @@ func newAPIAccessRequest(req clusters.AccessRequest) *api.AccessRequest {
ResourceIds: requestedResourceIDs,
Resources: resources,
PromotedAccessListTitle: req.GetPromotedAccessListTitle(),
AssumeStartTime: getProtoTimestamp(req.GetAssumeStartTime()),
MaxDuration: timestamppb.New(req.GetMaxDuration()),
RequestTtl: timestamppb.New(req.Expiry()),
SessionTtl: timestamppb.New(req.GetSessionTLL()),
}
}

Expand Down
33 changes: 33 additions & 0 deletions lib/teleterm/apiserver/handler/time_converter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright 2024 Gravitational, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package handler

import (
"time"

"google.golang.org/protobuf/types/known/timestamppb"
)

func getProtoTimestamp(time *time.Time) *timestamppb.Timestamp {
var protoTime *timestamppb.Timestamp

if time != nil {
protoTime = timestamppb.New(*time)
}

return protoTime
}
34 changes: 34 additions & 0 deletions lib/teleterm/apiserver/handler/time_converter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright 2024 Gravitational, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package handler

import (
"testing"
"time"

"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/timestamppb"
)

func TestGetProtoTimestamp(t *testing.T) {
ts := getProtoTimestamp(nil)
require.Empty(t, ts)

time := time.Now().UTC()
ts = getProtoTimestamp(&time)
require.Equal(t, timestamppb.New(time), ts)
}
Loading

0 comments on commit f33bbbf

Please sign in to comment.