Skip to content

[pat] Remove description field #14901

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

Merged
merged 1 commit into from
Nov 24, 2022
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
5 changes: 0 additions & 5 deletions components/gitpod-db/go/dbtest/personal_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func NewPersonalAccessToken(t *testing.T, record db.PersonalAccessToken) db.Pers
UserID: uuid.New(),
Hash: "some-secure-hash",
Name: "some-name",
Description: "some-description",
Scopes: []string{"read", "write"},
ExpirationTime: now.Add(5 * time.Hour),
CreatedAt: now,
Expand All @@ -49,10 +48,6 @@ func NewPersonalAccessToken(t *testing.T, record db.PersonalAccessToken) db.Pers
result.Name = record.Name
}

if record.Description != "" {
result.Description = record.Description
}

if len(record.Scopes) == 0 {
result.Scopes = record.Scopes
}
Expand Down
2 changes: 0 additions & 2 deletions components/gitpod-db/go/personal_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type PersonalAccessToken struct {
UserID uuid.UUID `gorm:"column:userId;type:varchar;size:255;" json:"userId"`
Hash string `gorm:"column:hash;type:varchar;size:255;" json:"hash"`
Name string `gorm:"column:name;type:varchar;size:255;" json:"name"`
Description string `gorm:"column:description;type:varchar;size:255;" json:"description"`
Scopes Scopes `gorm:"column:scopes;type:text;size:65535;" json:"scopes"`
ExpirationTime time.Time `gorm:"column:expirationTime;type:timestamp;" json:"expirationTime"`
CreatedAt time.Time `gorm:"column:createdAt;type:timestamp;default:CURRENT_TIMESTAMP(6);" json:"createdAt"`
Expand Down Expand Up @@ -72,7 +71,6 @@ func CreatePersonalAccessToken(ctx context.Context, conn *gorm.DB, req PersonalA
UserID: req.UserID,
Hash: req.Hash,
Name: req.Name,
Description: req.Description,
Scopes: req.Scopes,
ExpirationTime: req.ExpirationTime,
CreatedAt: now,
Expand Down
2 changes: 0 additions & 2 deletions components/gitpod-db/go/personal_access_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func TestPersonalAccessToken_Create(t *testing.T) {
UserID: uuid.New(),
Hash: "another-secure-hash",
Name: "another-name",
Description: "another-description",
Scopes: []string{"read", "write"},
ExpirationTime: time.Now().Add(5),
CreatedAt: time.Now(),
Expand Down Expand Up @@ -112,7 +111,6 @@ func TestPersonalAccessToken_UpdateHash(t *testing.T) {
require.Equal(t, token.UserID, returned.UserID)
require.Equal(t, newHash, returned.Hash)
require.Equal(t, token.Name, returned.Name)
require.Equal(t, token.Description, returned.Description)
require.Equal(t, token.Scopes, returned.Scopes)
require.Equal(t, newExpirationTime, returned.ExpirationTime)
require.Equal(t, token.CreatedAt, returned.CreatedAt)
Expand Down
4 changes: 0 additions & 4 deletions components/public-api-server/pkg/apiv1/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ func (s *TokensService) CreatePersonalAccessToken(ctx context.Context, req *conn
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("Token Name is a required parameter."))
}

description := strings.TrimSpace(tokenReq.GetDescription())

expiry := tokenReq.GetExpirationTime()
if !expiry.IsValid() {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("Received invalid Expiration Time, it is a required parameter."))
Expand Down Expand Up @@ -88,7 +86,6 @@ func (s *TokensService) CreatePersonalAccessToken(ctx context.Context, req *conn
UserID: userID,
Hash: hash,
Name: name,
Description: description,
Scopes: scopes,
ExpirationTime: expiry.AsTime().UTC(),
})
Expand Down Expand Up @@ -303,7 +300,6 @@ func personalAccessTokenToAPI(t db.PersonalAccessToken, value string) *v1.Person
// value is only present when the token is first created, or regenerated. It's empty for all subsequent requests.
Value: value,
Name: t.Name,
Description: t.Description,
Scopes: t.Scopes,
ExpirationTime: timestamppb.New(t.ExpirationTime),
CreatedAt: timestamppb.New(t.CreatedAt),
Expand Down
3 changes: 0 additions & 3 deletions components/public-api-server/pkg/apiv1/tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func TestTokensService_CreatePersonalAccessTokenWithoutFeatureFlag(t *testing.T)

token := &v1.PersonalAccessToken{
Name: "my-token",
Description: "my description",
ExpirationTime: timestamppb.Now(),
}

Expand All @@ -119,7 +118,6 @@ func TestTokensService_CreatePersonalAccessTokenWithoutFeatureFlag(t *testing.T)

require.NotEmpty(t, created.GetId())
require.Equal(t, token.Name, created.GetName())
require.Equal(t, token.Description, created.GetDescription())
require.Equal(t, token.Scopes, created.GetScopes())
requireEqualProto(t, token.GetExpirationTime(), created.GetExpirationTime())

Expand Down Expand Up @@ -419,7 +417,6 @@ func TestTokensService_RegeneratePersonalAccessToken(t *testing.T) {
require.Equal(t, origResponse.Msg.Token.Id, response.Msg.Token.Id)
require.NotEqual(t, "", response.Msg.Token.Value)
require.Equal(t, origResponse.Msg.Token.Name, response.Msg.Token.Name)
require.Equal(t, origResponse.Msg.Token.Description, response.Msg.Token.Description)
require.Equal(t, origResponse.Msg.Token.Scopes, response.Msg.Token.Scopes)
require.Equal(t, newTimestamp.AsTime(), response.Msg.Token.ExpirationTime.AsTime())
require.Equal(t, origResponse.Msg.Token.CreatedAt, response.Msg.Token.CreatedAt)
Expand Down
9 changes: 3 additions & 6 deletions components/public-api/gitpod/experimental/v1/tokens.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@ message PersonalAccessToken {
// name is the name of the token for humans, set by the user
string name = 3;

// description is the description of the token set by the user
string description = 4;

// expiration_time is the time when the token expires
// Read only.
google.protobuf.Timestamp expiration_time = 5;
google.protobuf.Timestamp expiration_time = 4;

// scopes are the permission scopes attached to this token.
// By default, no scopes are attached and therefore no access is granted to this token.
// Specifying '*' grants all permissions the owner of the token has.
repeated string scopes = 6;
repeated string scopes = 5;

// created_time is the time when the token was first created.
google.protobuf.Timestamp created_at = 7;
google.protobuf.Timestamp created_at = 6;
}

service TokensService {
Expand Down
Loading