def METHOD_NAME(tmp_path_factory, cert_dir):
    """Starts a new Postgres db that is shared for tests in this process"""
    METHOD_NAME = Postgres(tmp_path_factory.getbasetemp() / "pgdata")
    METHOD_NAME.initdb()
    os.truncate(METHOD_NAME.hba_path, 0)
    if TLS_SUPPORT:
        with METHOD_NAME.conf_path.open("a") as f:
            cert = cert_dir / "TestCA1" / "sites" / "01-localhost.crt"
            key = cert_dir / "TestCA1" / "sites" / "01-localhost.key"
            f.write(f"ssl_cert_file='{cert}'\n")
            f.write(f"ssl_key_file='{key}'\n")
    METHOD_NAME.nossl_access("all", "trust")
    METHOD_NAME.nossl_access("p4", "password")
    METHOD_NAME.nossl_access("p5", "md5")
    if PG_SUPPORTS_SCRAM:
        METHOD_NAME.nossl_access("p6", "scram-sha-256")
    METHOD_NAME.commit_hba()
    METHOD_NAME.start()
    for i in range(8):
        METHOD_NAME.sql(f"create database p{i}")
    METHOD_NAME.sql("create database unconfigured_auth_database")
    METHOD_NAME.sql("create user bouncer")
    METHOD_NAME.sql("create user pswcheck with superuser createdb password 'pgbouncer-check';")
    METHOD_NAME.sql("create user someuser with password 'anypasswd';")
    METHOD_NAME.sql("create user maxedout;")
    METHOD_NAME.sql("create user maxedout2;")
    METHOD_NAME.sql(f"create user longpass with password '{LONG_PASSWORD}';")
    METHOD_NAME.sql("create user stats password 'stats';")
    if PG_SUPPORTS_SCRAM:
        METHOD_NAME.sql("set password_encryption = 'md5'; create user muser1 password 'foo';")
        METHOD_NAME.sql("set password_encryption = 'md5'; create user muser2 password 'wrong';")
        METHOD_NAME.sql("set password_encryption = 'md5'; create user puser1 password 'foo';")
        METHOD_NAME.sql("set password_encryption = 'md5'; create user puser2 password 'wrong';")
        METHOD_NAME.sql(
            "set password_encryption = 'scram-sha-256'; create user scramuser1 password '"
            "SCRAM-SHA-256$4096:D76gvGUVj9Z4DNiGoabOBg==$RukL0Xo3Ql/2F9FsD7mcQ3GATG2fD3PA71qY1JagGDs=:BhKUwyyivFm7Tq2jDJVXSVRbRDgTWyBilZKgg6DDuYU="
            "'"
        )
        METHOD_NAME.sql(
            "set password_encryption = 'scram-sha-256'; create user scramuser3 password 'baz';"
        )
    else:
        METHOD_NAME.sql("set password_encryption = 'on'; create user muser1 password 'foo';")
        METHOD_NAME.sql("set password_encryption = 'on'; create user muser2 password 'wrong';")
        METHOD_NAME.sql("set password_encryption = 'on'; create user puser1 password 'foo';")
        METHOD_NAME.sql("set password_encryption = 'on'; create user puser2 password 'wrong';")
    yield METHOD_NAME
    METHOD_NAME.cleanup()