Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v15] Teleterm: add new access request fields (#39050) #39320

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,047 changes: 1,062 additions & 985 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
Loading