Linter fixes numero 2 (#4408)
This commit is contained in:
1 parent
25bce9e8ff
commit
49803e653c
23 files changed
+172
-109
No files matched your search
@@ -9,7 +9,6 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/db/timestamp"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
@@ -213,14 +212,8 @@ func (r *Repository) ValidateToken(ctx context.Context, id, token string, opt ..
|
||||
}
|
||||
|
||||
// If the token is too old or stale invalidate it and return nothing.
|
||||
exp, err := ptypes.Timestamp(retAT.GetExpirationTime().GetTimestamp())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("expiration time"), errors.WithCode(errors.InvalidTimeStamp))
|
||||
}
|
||||
lastAccessed, err := ptypes.Timestamp(retAT.GetApproximateLastAccessTime().GetTimestamp())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("last accessed time"), errors.WithCode(errors.InvalidTimeStamp))
|
||||
}
|
||||
exp := retAT.GetExpirationTime().AsTime()
|
||||
lastAccessed := retAT.GetApproximateLastAccessTime().AsTime()
|
||||
|
||||
now := time.Now()
|
||||
sinceLastAccessed := now.Sub(lastAccessed) + timeSkew
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
@@ -19,6 +18,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/testing/protocmp"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/authtoken/store"
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
@@ -462,10 +462,8 @@ func TestRepository_ValidateToken(t *testing.T) {
|
||||
require.NotNil(tt.want, "Got %v but wanted nil", got)
|
||||
|
||||
// NOTE: See comment in LookupAuthToken about this logic
|
||||
wantGoTimeExpr, err := ptypes.Timestamp(tt.want.AuthToken.GetExpirationTime().Timestamp)
|
||||
require.NoError(err)
|
||||
gotGoTimeExpr, err := ptypes.Timestamp(got.AuthToken.GetExpirationTime().Timestamp)
|
||||
require.NoError(err)
|
||||
wantGoTimeExpr := tt.want.AuthToken.GetExpirationTime().AsTime()
|
||||
gotGoTimeExpr := got.AuthToken.GetExpirationTime().AsTime()
|
||||
assert.WithinDuration(wantGoTimeExpr, gotGoTimeExpr, time.Millisecond)
|
||||
tt.want.AuthToken.ExpirationTime = got.AuthToken.ExpirationTime
|
||||
assert.Empty(cmp.Diff(tt.want.AuthToken, got.AuthToken, protocmp.Transform()))
|
||||
@@ -906,8 +904,7 @@ func Test_CloseExpiredPendingTokens(t *testing.T) {
|
||||
id, err := NewAuthTokenId(ctx)
|
||||
require.NoError(t, err)
|
||||
at.PublicId = id
|
||||
exp, err := ptypes.TimestampProto(time.Now().Add(expIn).Truncate(time.Second))
|
||||
require.NoError(t, err)
|
||||
exp := timestamppb.New(time.Now().Add(expIn).Truncate(time.Second))
|
||||
at.ExpirationTime = ×tamp.Timestamp{Timestamp: exp}
|
||||
at.Status = string(status)
|
||||
at.AuthAccountId = accts[i].PublicId
|
||||
|
||||
Reference in new issue
Block a user