mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Fix deadlock in root credential rotation (#4309)
* fix deadlock in root credential rotation * add more logging of errors * adding cassandra test
This commit is contained in:
@@ -252,6 +252,45 @@ func TestCassandra_RevokeUser(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCassandra_RotateRootCredentials(t *testing.T) {
|
||||
cleanup, address, port := prepareCassandraTestContainer(t)
|
||||
defer cleanup()
|
||||
|
||||
connectionDetails := map[string]interface{}{
|
||||
"hosts": address,
|
||||
"port": port,
|
||||
"username": "cassandra",
|
||||
"password": "cassandra",
|
||||
"protocol_version": 4,
|
||||
}
|
||||
|
||||
db := new()
|
||||
|
||||
connProducer := db.cassandraConnectionProducer
|
||||
|
||||
_, err := db.Init(context.Background(), connectionDetails, true)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if !connProducer.Initialized {
|
||||
t.Fatal("Database should be initialized")
|
||||
}
|
||||
|
||||
newConf, err := db.RotateRootCredentials(context.Background(), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if newConf["password"] == "cassandra" {
|
||||
t.Fatal("password was not updated")
|
||||
}
|
||||
|
||||
err = db.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func testCredsExist(t testing.TB, address string, port int, username, password string) error {
|
||||
clusterConfig := gocql.NewCluster(address)
|
||||
clusterConfig.Authenticator = gocql.PasswordAuthenticator{
|
||||
|
||||
Reference in New Issue
Block a user