mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 02:57:59 +00:00
Update Postgres tests and changelogify
This commit is contained in:
@@ -39,6 +39,8 @@ generate them, leading to client errors.
|
|||||||
* secret/generic: Validate given duration at write time, not just read time;
|
* secret/generic: Validate given duration at write time, not just read time;
|
||||||
if stored durations are not parseable, return a warning and the default
|
if stored durations are not parseable, return a warning and the default
|
||||||
duration rather than an error [GH-718]
|
duration rather than an error [GH-718]
|
||||||
|
* secret/postgresql: Revoke permissions before dropping a user or revocation
|
||||||
|
may fail [GH-699]
|
||||||
|
|
||||||
MISC:
|
MISC:
|
||||||
|
|
||||||
|
|||||||
@@ -13,26 +13,9 @@ import (
|
|||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
username string
|
|
||||||
db *sql.DB
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestBackend_basic(t *testing.T) {
|
func TestBackend_basic(t *testing.T) {
|
||||||
b, _ := Factory(logical.TestBackendConfig())
|
b, _ := Factory(logical.TestBackendConfig())
|
||||||
|
|
||||||
conn, err := pq.ParseURL(os.Getenv("PG_URL"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
conn += " timezone=utc"
|
|
||||||
|
|
||||||
db, err = sql.Open("postgres", conn)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
logicaltest.Test(t, logicaltest.TestCase{
|
logicaltest.Test(t, logicaltest.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Backend: b,
|
Backend: b,
|
||||||
@@ -106,13 +89,24 @@ func testAccStepReadCreds(t *testing.T, b logical.Backend, name string) logicalt
|
|||||||
if err := mapstructure.Decode(resp.Data, &d); err != nil {
|
if err := mapstructure.Decode(resp.Data, &d); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
username = d.Username
|
|
||||||
log.Printf("[WARN] Generated credentials: %v", d)
|
log.Printf("[WARN] Generated credentials: %v", d)
|
||||||
|
|
||||||
|
conn, err := pq.ParseURL(os.Getenv("PG_URL"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
conn += " timezone=utc"
|
||||||
|
|
||||||
|
db, err := sql.Open("postgres", conn)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
returnedRows := func() int {
|
returnedRows := func() int {
|
||||||
stmt, err := db.Prepare(fmt.Sprintf(
|
stmt, err := db.Prepare(fmt.Sprintf(
|
||||||
"SELECT DISTINCT table_schema FROM information_schema.role_column_grants WHERE grantee='%s';",
|
"SELECT DISTINCT table_schema FROM information_schema.role_column_grants WHERE grantee='%s';",
|
||||||
username))
|
d.Username))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
@@ -136,12 +130,12 @@ func testAccStepReadCreds(t *testing.T, b logical.Backend, name string) logicalt
|
|||||||
t.Fatalf("did not get expected number of rows, got %d", userRows)
|
t.Fatalf("did not get expected number of rows, got %d", userRows)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := b.HandleRequest(&logical.Request{
|
resp, err = b.HandleRequest(&logical.Request{
|
||||||
Operation: logical.RevokeOperation,
|
Operation: logical.RevokeOperation,
|
||||||
Secret: &logical.Secret{
|
Secret: &logical.Secret{
|
||||||
InternalData: map[string]interface{}{
|
InternalData: map[string]interface{}{
|
||||||
"secret_type": "creds",
|
"secret_type": "creds",
|
||||||
"username": username,
|
"username": d.Username,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user