Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLOUDP-66615: Add support for rotation of TLS certificates and keys (#…
…122)
- Loading branch information
1 parent
e6b9eb1
commit 459582c
Showing
11 changed files
with
268 additions
and
65 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
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
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
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
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
49 changes: 49 additions & 0 deletions
49
test/e2e/replica_set_tls_rotate/replica_set_tls_rotate_test.go
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,49 @@ | ||
package replica_set_tls | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/mongodb/mongodb-kubernetes-operator/test/e2e/tlstests" | ||
|
||
e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" | ||
"github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" | ||
setup "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" | ||
f "github.com/operator-framework/operator-sdk/pkg/test" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
f.MainEntry(m) | ||
} | ||
|
||
func TestReplicaSetTLSRotate(t *testing.T) { | ||
ctx, shouldCleanup := setup.InitTest(t) | ||
if shouldCleanup { | ||
defer ctx.Cleanup() | ||
} | ||
|
||
mdb, user := e2eutil.NewTestMongoDB("mdb-tls") | ||
mdb.Spec.Security.TLS = e2eutil.NewTestTLSConfig(false) | ||
|
||
_, err := setup.GeneratePasswordForUser(user, ctx) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if err := setup.CreateTLSResources(mdb.Namespace, ctx); err != nil { | ||
t.Fatalf("Failed to set up TLS resources: %+v", err) | ||
} | ||
|
||
t.Run("Create MongoDB Resource", mongodbtests.CreateMongoDBResource(&mdb, ctx)) | ||
t.Run("Basic tests", mongodbtests.BasicFunctionality(&mdb)) | ||
t.Run("Wait for TLS to be enabled", tlstests.WaitForTLSMode(&mdb, "requireSSL")) | ||
t.Run("Test Basic TLS Connectivity", tlstests.ConnectivityWithTLS(&mdb)) | ||
t.Run("Test TLS required", tlstests.ConnectivityWithoutTLSShouldFail(&mdb)) | ||
|
||
t.Run("MongoDB is reachable while certificate is rotated", tlstests.IsReachableOverTLSDuring(&mdb, time.Second*10, | ||
func() { | ||
t.Run("Update certificate secret", tlstests.RotateCertificate(&mdb)) | ||
t.Run("Wait for certificate to be rotated", tlstests.WaitForRotatedCertificate(&mdb)) | ||
}, | ||
)) | ||
} |
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
Oops, something went wrong.