HomeDevCentral

Test if PostgreSQL connections for pg_hba.conf use CIDR notation

Description

Test if PostgreSQL connections for pg_hba.conf use CIDR notation

[ Context ]

PostgreSQL doesn't accept "127.0.0.1" anymore in pg_hba.conf, as
it accepts two notation, IP range or "ip-address ip-mask".

To represent the "127.0.0.1" address, two notations are valid:
"127.0.0.1/32" or "127.0.0.1 255.255.255.255".

Nasqueron configuration uses the CIDR notation format.

[ Test suite for connections ]

  • Check all mandatory keys are there
  • Check no unknown key is there (would be ignored by our template)
  • Check the ips parameter is a CIDR range (contains "/")

Reference: https://www.postgresql.org/docs/17/auth-pg-hba-conf.html

Test Plan:

  • New tests pass for current configuration
  • Tests fail for "ips: 127.0.0.1"
  • Tests fail if we mess with the keys
  • DNS test still pass

Differential Revision: https://devcentral.nasqueron.org/D3878

Details

Provenance
derecksonAuthored on Tue, Nov 11, 15:43
derecksonPushed on Tue, Nov 11, 15:52
Differential Revision
D3878: Test if PostgreSQL connections for pg_hba.conf use CIDR notation
Parents
rOPS1b64a441817e: Add Jinja2 to tests requirements
Branches
Unknown
Tags
Unknown

Event Timeline

/_tests/pillar/dbserver/test_postgresql.py
69

It's asserted a simple reminder to add /32 for unique IP address is the real need here.

If we want to test further CIDR correctness, ip_network can help.