mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-27 16:12:56 +00:00
fix(adapter): password not set in role drop (#10130)
## Problem When entry was dropped and password wasn't set, new entry had uninitialized memory in controlplane adapter Resolves: https://github.com/neondatabase/cloud/issues/14914 ## Summary of changes Initialize password in all cases, add tests. Minor formatting for less indentation
This commit is contained in:
@@ -60,14 +60,12 @@ def ddl_forward_handler(
|
||||
if request.json is None:
|
||||
log.info("Received invalid JSON")
|
||||
return Response(status=400)
|
||||
json = request.json
|
||||
json: dict[str, list[str]] = request.json
|
||||
# Handle roles first
|
||||
if "roles" in json:
|
||||
for operation in json["roles"]:
|
||||
handle_role(dbs, roles, operation)
|
||||
if "dbs" in json:
|
||||
for operation in json["dbs"]:
|
||||
handle_db(dbs, roles, operation)
|
||||
for operation in json.get("roles", []):
|
||||
handle_role(dbs, roles, operation)
|
||||
for operation in json.get("dbs", []):
|
||||
handle_db(dbs, roles, operation)
|
||||
return Response(status=200)
|
||||
|
||||
|
||||
@@ -207,6 +205,23 @@ def test_ddl_forwarding(ddl: DdlForwardingContext):
|
||||
ddl.wait()
|
||||
assert ddl.roles == {}
|
||||
|
||||
cur.execute("CREATE ROLE bork WITH PASSWORD 'newyork'")
|
||||
cur.execute("BEGIN")
|
||||
cur.execute("SAVEPOINT point")
|
||||
cur.execute("DROP ROLE bork")
|
||||
cur.execute("COMMIT")
|
||||
ddl.wait()
|
||||
assert ddl.roles == {}
|
||||
|
||||
cur.execute("CREATE ROLE bork WITH PASSWORD 'oldyork'")
|
||||
cur.execute("BEGIN")
|
||||
cur.execute("SAVEPOINT point")
|
||||
cur.execute("ALTER ROLE bork PASSWORD NULL")
|
||||
cur.execute("COMMIT")
|
||||
cur.execute("DROP ROLE bork")
|
||||
ddl.wait()
|
||||
assert ddl.roles == {}
|
||||
|
||||
cur.execute("CREATE ROLE bork WITH PASSWORD 'dork'")
|
||||
cur.execute("CREATE DATABASE stork WITH OWNER=bork")
|
||||
cur.execute("ALTER ROLE bork RENAME TO cork")
|
||||
|
||||
Reference in New Issue
Block a user