Skip to content

Commit

Permalink
testing: fix TestS3SettingsValidate
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Nov 27, 2023
1 parent 694f7eb commit 1a2a8c6
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions internal/testing/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,15 @@ func TestS3SettingsValidate(t *testing.T) {
t.SkipNow()
}

charset := "doesntreallymatter"
stringOfLength := func(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = charset[frand.Intn(len(charset))]
}
return string(b)
}

cluster := newTestCluster(t, clusterOptsDefault)
defer cluster.Shutdown()

Expand All @@ -612,33 +621,38 @@ func TestS3SettingsValidate(t *testing.T) {
shouldFail bool
}{
{
// Min length
id: "id",
key: "aaaaaaaaaaaaaaaa",
id: stringOfLength(api.S3MinAccessKeyLen),
key: stringOfLength(api.S3SecretKeyLen),
shouldFail: false,
},
{
// Max length
id: "id",
key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
id: stringOfLength(api.S3MaxAccessKeyLen),
key: stringOfLength(api.S3SecretKeyLen),
shouldFail: false,
},
{
// Min length - 1
id: "id",
key: "aaaaaaaaaaaaaaa",
id: stringOfLength(api.S3MinAccessKeyLen - 1),
key: stringOfLength(api.S3SecretKeyLen),
shouldFail: true,
},
{
// Max length + 1
id: "id",
key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
id: stringOfLength(api.S3MaxAccessKeyLen + 1),
key: stringOfLength(api.S3SecretKeyLen),
shouldFail: true,
},
{
// No ID
id: "",
key: "aaaaaaaaaaaaaaaa",
key: stringOfLength(api.S3SecretKeyLen),
shouldFail: true,
},
{
id: stringOfLength(api.S3MinAccessKeyLen),
key: "",
shouldFail: true,
},
{
id: stringOfLength(api.S3MinAccessKeyLen),
key: stringOfLength(api.S3SecretKeyLen + 1),
shouldFail: true,
},
}
Expand Down

0 comments on commit 1a2a8c6

Please sign in to comment.