Skip to content

Commit

Permalink
bump cross test timeouts to 10 seconds (#46)
Browse files Browse the repository at this point in the history
* bump ruby command timeouts to 10 seconds

* use longer timeout to test duration
  • Loading branch information
James-Pickett authored Jan 7, 2025
1 parent 46a8d5c commit cb25b5e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
10 changes: 6 additions & 4 deletions cross_language_tests/boxer_cross_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"github.com/vmihailenco/msgpack/v5"
)

const rubyCmdTimeout = 10 * time.Second

type boxerCrossTestCase struct {
Key []byte
Counterparty []byte
Expand Down Expand Up @@ -95,7 +97,7 @@ func TestBoxerRuby(t *testing.T) {
//#nosec G306 -- Need readable files
require.NoError(t, os.WriteFile(rubyInFile, []byte(base64.StdEncoding.EncodeToString(b)), 0644))

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), rubyCmdTimeout)
defer cancel()

cmd := exec.CommandContext(ctx, "ruby", boxerRB, "encode", rubyInFile, rubyOutFile)
Expand Down Expand Up @@ -204,7 +206,7 @@ func TestBoxerRuby(t *testing.T) {
//#nosec G306 -- Need readable files
require.NoError(t, os.WriteFile(testfile, []byte(base64.StdEncoding.EncodeToString(b)), 0644))

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), rubyCmdTimeout)
defer cancel()

//#nosec G204 -- No taint on hardcoded input
Expand Down Expand Up @@ -253,7 +255,7 @@ func TestBoxerRuby(t *testing.T) {
//#nosec G306 -- Need readable files
require.NoError(t, os.WriteFile(rubyInFile, []byte(base64.StdEncoding.EncodeToString(b)), 0644))

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), rubyCmdTimeout)
defer cancel()

cmd := exec.CommandContext(ctx, "ruby", boxerRB, "sign", rubyInFile, rubyOutFile)
Expand Down Expand Up @@ -377,7 +379,7 @@ func TestBoxerMaxSize(t *testing.T) {
//#nosec G306 -- Need readable files
require.NoError(t, os.WriteFile(testfile, []byte(base64.StdEncoding.EncodeToString(b)), 0644))

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), rubyCmdTimeout)
defer cancel()

//#nosec G204 -- No taint on hardcoded input
Expand Down
2 changes: 1 addition & 1 deletion cross_language_tests/challenge_cross_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestChallenge_RubyGenerate_GoRespondPng(t *testing.T) {

require.Equal(t, challengeData, innerResponse.ChallengeData)
require.Equal(t, responderData, innerResponse.ResponseData)
require.WithinDuration(t, time.Now(), time.Unix(innerResponse.Timestamp, 0), time.Second*5)
require.WithinDuration(t, time.Now(), time.Unix(innerResponse.Timestamp, 0), rubyCmdTimeout)
})
}
}
Expand Down
3 changes: 1 addition & 2 deletions cross_language_tests/png_cross_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path"
"runtime"
"testing"
"time"

"github.com/kolide/kit/ulid"
"github.com/kolide/krypto"
Expand Down Expand Up @@ -64,7 +63,7 @@ func TestPngRuby(t *testing.T) {
t.Skip("skip png decode test on windows because ruby library chunky_png is looking for CRLF png signature")
}

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), rubyCmdTimeout)
defer cancel()

resultFile := path.Join(dir, ulid.New()+".dat")
Expand Down
9 changes: 4 additions & 5 deletions cross_language_tests/rsa_cross_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os/exec"
"path"
"testing"
"time"

"github.com/kolide/krypto"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -59,7 +58,7 @@ func TestRsaRuby(t *testing.T) {
t.Parallel()
tt := tt

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), rubyCmdTimeout)
defer cancel()

dir := t.TempDir()
Expand Down Expand Up @@ -90,7 +89,7 @@ func TestRsaRuby(t *testing.T) {
t.Parallel()
tt := tt

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), rubyCmdTimeout)
defer cancel()

dir := t.TempDir()
Expand Down Expand Up @@ -119,7 +118,7 @@ func TestRsaRuby(t *testing.T) {
t.Parallel()
tt := tt

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), rubyCmdTimeout)
defer cancel()

dir := t.TempDir()
Expand Down Expand Up @@ -151,7 +150,7 @@ func TestRsaRuby(t *testing.T) {
t.Parallel()
tt := tt

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), rubyCmdTimeout)
defer cancel()

dir := t.TempDir()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kolide/krypto

go 1.22
go 1.22.0

require (
github.com/kolide/kit v0.0.0-20221107170827-fb85e3d59eab
Expand Down

0 comments on commit cb25b5e

Please sign in to comment.