Fix #533, add a reader for lease values (#529) and an acceptance test for mysql to prove it works

This commit is contained in:
Caleb Tennis
2015-08-13 15:32:40 -04:00
parent 6d05df1596
commit d009d79696
4 changed files with 103 additions and 3 deletions

View File

@@ -41,6 +41,21 @@ func TestBackend_roleCrud(t *testing.T) {
})
}
func TestBackend_leaseWriteRead(t *testing.T) {
b := Backend()
logicaltest.Test(t, logicaltest.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Backend: b,
Steps: []logicaltest.TestStep{
testAccStepConfig(t),
testAccStepWriteLease(t),
testAccStepReadLease(t),
},
})
}
func testAccPreCheck(t *testing.T) {
if v := os.Getenv("MYSQL_DSN"); v == "" {
t.Fatal("MYSQL_DSN must be set for acceptance tests")
@@ -122,6 +137,31 @@ func testAccStepReadRole(t *testing.T, name string, sql string) logicaltest.Test
}
}
func testAccStepWriteLease(t *testing.T) logicaltest.TestStep {
return logicaltest.TestStep{
Operation: logical.WriteOperation,
Path: "config/lease",
Data: map[string]interface{}{
"lease": "1h5m",
"lease_max": "24h",
},
}
}
func testAccStepReadLease(t *testing.T) logicaltest.TestStep {
return logicaltest.TestStep{
Operation: logical.ReadOperation,
Path: "config/lease",
Check: func(resp *logical.Response) error {
if resp.Data["lease"] != "1h5m0s" || resp.Data["lease_max"] != "24h0m0s" {
return fmt.Errorf("bad: %#v", resp)
}
return nil
},
}
}
const testRole = `
CREATE USER '{{name}}'@'%' IDENTIFIED BY '{{password}}';
GRANT SELECT ON *.* TO '{{name}}'@'%';