initial commit to fix empty consistency option issue

This commit is contained in:
Laura Bennett 2016-10-08 20:22:26 -04:00
parent 80281c16fc
commit bc58e02fe8
2 changed files with 15 additions and 1 deletions

View File

@ -35,7 +35,7 @@ func TestBackend_roleCrud(t *testing.T) {
Backend: b, Backend: b,
Steps: []logicaltest.TestStep{ Steps: []logicaltest.TestStep{
testAccStepConfig(t), testAccStepConfig(t),
testAccStepRole(t), testAccStepRoleWithOptions(t),
testAccStepReadRole(t, "test", testRole), testAccStepReadRole(t, "test", testRole),
testAccStepDeleteRole(t, "test"), testAccStepDeleteRole(t, "test"),
testAccStepReadRole(t, "test", ""), testAccStepReadRole(t, "test", ""),
@ -67,6 +67,17 @@ func testAccStepRole(t *testing.T) logicaltest.TestStep {
Path: "roles/test", Path: "roles/test",
Data: map[string]interface{}{ Data: map[string]interface{}{
"creation_cql": testRole, "creation_cql": testRole,
},
}
}
func testAccStepRoleWithOptions(t *testing.T) logicaltest.TestStep {
return logicaltest.TestStep{
Operation: logical.UpdateOperation,
Path: "roles/test2",
Data: map[string]interface{}{
"creation_cql": testRole,
"lease": "30s",
"consistency": "All", "consistency": "All",
}, },
} }

View File

@ -131,6 +131,9 @@ func (b *backend) pathRoleCreate(
} }
consistencyStr := data.Get("consistency").(string) consistencyStr := data.Get("consistency").(string)
if consistencyStr == "" {
consistencyStr = "Quorum"
}
_, err = gocql.ParseConsistencyWrapper(consistencyStr) _, err = gocql.ParseConsistencyWrapper(consistencyStr)
if err != nil { if err != nil {
return logical.ErrorResponse(fmt.Sprintf( return logical.ErrorResponse(fmt.Sprintf(