Skip to content

Commit

Permalink
test: add buffer to both sides of token expiry validation (#1797)
Browse files Browse the repository at this point in the history
This helps account for skew and timing issues.

Fixes: #1783
  • Loading branch information
codyoss committed Jan 3, 2023
1 parent b35900a commit ddb5c65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions integration-tests/byoid/integration_test.go
Expand Up @@ -443,8 +443,8 @@ func TestConfigurableTokenLifetime(t *testing.T) {
}

now := time.Now()
expiryMax := now.Add(tokenLifetimeSeconds * time.Second)
expiryMin := expiryMax.Add(-safetyBuffer * time.Second)
expiryMax := now.Add((safetyBuffer + tokenLifetimeSeconds) * time.Second)
expiryMin := now.Add((tokenLifetimeSeconds - safetyBuffer) * time.Second)
if token.Expiry.Before(expiryMin) || token.Expiry.After(expiryMax) {
t.Fatalf("Expiry time not set correctly. Got %v, want %v", token.Expiry, expiryMax)
}
Expand Down

0 comments on commit ddb5c65

Please sign in to comment.