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:
Chris Hoffman
2018-04-08 13:34:59 -04:00
committed by GitHub
parent abb8b41331
commit aac9ee83f4
5 changed files with 154 additions and 7 deletions

View File

@@ -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{