unioslo / mreg

GNU General Public License v3.0
7 stars 13 forks source link

Handle JSON in Zone POST requests #538

Closed pederhan closed 4 months ago

pederhan commented 4 months ago

Checks content type before trying to call getlist on request data.

coveralls commented 4 months ago

Coverage Status

coverage: 98.925% (-0.01%) from 98.938% when pulling fdb50d1f484ce98b01c140864ce57c07542361aa on pederhan:zone-json-support into fa6ca20a41bd486cc8053a116f412b1d526a72ef on unioslo:master.

oyvindhagberg commented 4 months ago

I tested this with mreg-cli from the migrate_to_pydandic branch (248a19e) and verified that the "zone create" commands in the testsuite work now.

oyvindkolbu commented 4 months ago
- zone.primary_ns = request.data.getlist('primary_ns')[0]
+ zone.primary_ns = nameservers[0]

I'm not going to pretend that I understand why we're simply picking the first one, but the PR retains behaviour and fixes the issue with content type management. That works for me. :)

It is due to https://github.com/unioslo/mreg/blob/b4975799aaa18905e704182cead4f990aaad896a/mreg/models/zone.py#L58 We (ab)use the first name server in the list to be used as mname server in the SOA record for the zone.

The zone's primary_ns field could possibly be changed to mname to better reflect usage.

terjekv commented 4 months ago

We (ab)use the first name server in the list to be used as mname server in the SOA record for the zone.

Now that I know I wish I didn't know. :)

The zone's primary_ns field could possibly be changed to mname to better reflect usage.

Yep.