Skip to content

Commit a8fb319

Browse files
Jordan-Williams2Jordan-Williams2
authored andcommitted
fix: update submodule
1 parent e1011b2 commit a8fb319

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

common-dev-assets

tests/pr_test.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
package test
33

44
import (
5+
"crypto/rand"
56
"fmt"
67
"log"
8+
"math/big"
79
"os"
810
"strings"
911
"testing"
1012

11-
"math/rand/v2"
12-
1313
"github.com/gruntwork-io/terratest/modules/files"
1414
"github.com/gruntwork-io/terratest/modules/logger"
1515
"github.com/gruntwork-io/terratest/modules/random"
@@ -61,6 +61,15 @@ func TestMain(m *testing.M) {
6161
os.Exit(m.Run())
6262
}
6363

64+
// secureRandomInt generates a cryptographically secure random integer in the range [0, max)
65+
func secureRandomInt(max int) (int, error) {
66+
nBig, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
67+
if err != nil {
68+
return 0, err
69+
}
70+
return int(nBig.Int64()), nil
71+
}
72+
6473
func setupOptions(t *testing.T, prefix string, terraformDir string) *testhelper.TestOptions {
6574

6675
options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
@@ -81,7 +90,9 @@ func setupOptions(t *testing.T, prefix string, terraformDir string) *testhelper.
8190
func TestFullyConfigurableSolution(t *testing.T) {
8291
t.Parallel()
8392

84-
var region = validRegions[rand.IntN(len(validRegions))]
93+
randomIndex, err := secureRandomInt(len(validRegions))
94+
require.NoError(t, err, "Failed to generate random index")
95+
var region = validRegions[randomIndex]
8596

8697
// ------------------------------------------------------------------------------------------------------
8798
// Deploy OCP Cluster and Logs instance since it is needed to deploy Logs Agent
@@ -167,7 +178,9 @@ func TestFullyConfigurableSolution(t *testing.T) {
167178
func TestFullyConfigurableUpgradeSolution(t *testing.T) {
168179
t.Parallel()
169180

170-
var region = validRegions[rand.IntN(len(validRegions))]
181+
randomIndex, err := secureRandomInt(len(validRegions))
182+
require.NoError(t, err, "Failed to generate random index")
183+
var region = validRegions[randomIndex]
171184

172185
// ------------------------------------------------------------------------------------------------------
173186
// Deploy OCP Cluster and Observability instances since it is needed to deploy Logs Agent

0 commit comments

Comments
 (0)