grnet / webdns4

A Ruby-on-Rails Webdns Frontend for Powerdns
2 stars 2 forks source link

Upserts doesn't work correctly #15

Closed alexkiousis closed 6 years ago

alexkiousis commented 6 years ago

The upsert endpoint doesn't check something correctly when using shortname instead of fqdn:

curl -X POST http://localhost:3000/api/domain/example.com/bulk?token=a73a8126f7e88d35089e  -H 'Content-Type: application/json' -d '{ "upserts": [ { "name": "dsa", "type": "A", "content": "1.1.1.1" } ] }'
{"ok":true,"response":{"operations":{"additions":[{"name":"dsa.example.com","content":"1.1.1.1","type":"A","ttl":null,"prio":null,"disabled":false}]}}}

curl -X POST http://localhost:3000/api/domain/example.com/bulk?token=a73a8126f7e88d35089e  -H 'Content-Type: application/json' -d '{ "upserts": [ { "name": "dsa", "type": "A", "content": "1.1.1.1" } ] }'
{"ok":true,"response":{"operations":{"additions":[{"name":"dsa.example.com","content":"1.1.1.1","type":"A","ttl":null,"prio":null,"disabled":false}]}}}

curl -X POST http://localhost:3000/api/domain/example.com/bulk?token=a73a8126f7e88d35089e  -H 'Content-Type: application/json' -d '{ "upserts": [ { "name": "dsa", "type": "A", "content": "1.1.1.1" } ] }'
{"ok":true,"response":{"operations":{"additions":[{"name":"dsa.example.com","content":"1.1.1.1","type":"A","ttl":null,"prio":null,"disabled":false}]}}}
--
    "name": "dsa.example.com",
    "content": "1.1.1.1",
    "type": "A",
--
    "name": "dsa.example.com",
    "content": "1.1.1.1",
    "type": "A",
--
    "name": "dsa.example.com",
    "content": "1.1.1.1",
    "type": "A",

When you send a POST with the FQDN content:

curl -X POST http://localhost:3000/api/domain/example.com/bulk?token=a73a8126f7e88d35089e  -H 'Content-Type: application/json' -d '{ "upserts": [ { "name": "dsa.example.com", "type": "A", "content": "1.1.1.1" } ] }'

{"ok":true,"response":{"operations":{"deletes":[{"name":"dsa.example.com","content":"1.1.1.1","type":"A","ttl":null,"prio":null,"disabled":false},{"name":"dsa.example.com","content":"1.1.1.1","type":"A","ttl":null,"prio":null,"disabled":false},{"name":"dsa.example.com","content":"1.1.1.1","type":"A","ttl":null,"prio":null,"disabled":false}],"additions":[{"name":"dsa.example.com","content":"1.1.1.1","type":"A","ttl":null,"prio":null,"disabled":false}]}}}
--
    "name": "dsa.example.com",
    "content": "1.1.1.1",
    "type": "A",

it seems to cleanup all wrongly inserted values.