forked from minio/kes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edge: move tests from edge_test to edge package (minio#367)
This commit moves the tests added by 485624f into the `edge` package. Further, it converts the single tests to table-driven tests and adds keystore cleanup to keep test runs predictable. Tests for `List` and `Delete` are omitted because the cleanup code first lists and then deletes entries. So, `List` and `Delete` get tested automatically. Signed-off-by: Andreas Auernhammer <[email protected]>
- Loading branch information
Showing
18 changed files
with
814 additions
and
673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2023 - MinIO, Inc. All rights reserved. | ||
// Use of this source code is governed by the AGPLv3 | ||
// license that can be found in the LICENSE file. | ||
|
||
package edge_test | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"testing" | ||
|
||
"github.com/minio/kes/edge" | ||
) | ||
|
||
var awsConfigFile = flag.String("aws.config", "", "Path to a KES config file with AWS SecretsManager config") | ||
|
||
func TestAWS(t *testing.T) { | ||
if *awsConfigFile == "" { | ||
t.Skip("AWS SecretsManager tests disabled. Use -aws.config=<FILE> to enable them") | ||
} | ||
|
||
file, err := os.Open(*awsConfigFile) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer file.Close() | ||
|
||
config, err := edge.ReadServerConfigYAML(file) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if _, ok := config.KeyStore.(*edge.AWSSecretsManagerKeyStore); !ok { | ||
t.Fatalf("Invalid Keystore: want %T - got %T", config.KeyStore, &edge.AWSSecretsManagerKeyStore{}) | ||
} | ||
|
||
ctx, cancel := testingContext(t) | ||
defer cancel() | ||
|
||
store, err := config.KeyStore.Connect(ctx) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
t.Run("Create", func(t *testing.T) { testCreate(ctx, store, t) }) | ||
t.Run("Set", func(t *testing.T) { testSet(ctx, store, t) }) | ||
t.Run("Get", func(t *testing.T) { testGet(ctx, store, t) }) | ||
t.Run("Status", func(t *testing.T) { testStatus(ctx, store, t) }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2023 - MinIO, Inc. All rights reserved. | ||
// Use of this source code is governed by the AGPLv3 | ||
// license that can be found in the LICENSE file. | ||
|
||
package edge_test | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"testing" | ||
|
||
"github.com/minio/kes/edge" | ||
) | ||
|
||
var azureConfigFile = flag.String("azure.config", "", "Path to a KES config file with Azure KeyVault config") | ||
|
||
func TestAzure(t *testing.T) { | ||
if *azureConfigFile == "" { | ||
t.Skip("Azure KeyVault tests disabled. Use -azure.config=<FILE> to enable them") | ||
} | ||
file, err := os.Open(*azureConfigFile) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer file.Close() | ||
|
||
config, err := edge.ReadServerConfigYAML(file) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if _, ok := config.KeyStore.(*edge.AzureKeyVaultKeyStore); !ok { | ||
t.Fatalf("Invalid Keystore: want %T - got %T", config.KeyStore, &edge.AzureKeyVaultKeyStore{}) | ||
} | ||
|
||
ctx, cancel := testingContext(t) | ||
defer cancel() | ||
|
||
store, err := config.KeyStore.Connect(ctx) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
t.Run("Create", func(t *testing.T) { testCreate(ctx, store, t) }) | ||
t.Run("Set", func(t *testing.T) { testSet(ctx, store, t) }) | ||
t.Run("Get", func(t *testing.T) { testGet(ctx, store, t) }) | ||
t.Run("Status", func(t *testing.T) { testStatus(ctx, store, t) }) | ||
} |
Oops, something went wrong.