Removed SOA from records

This commit is contained in:
Lukas Metzger 2018-04-13 17:13:53 +02:00
parent 2e4c49445f
commit e6ca551641
6 changed files with 49 additions and 40 deletions

View file

@ -84,7 +84,8 @@ class Domains
FROM domains D
LEFT OUTER JOIN records R ON D.id = R.domain_id
LEFT OUTER JOIN permissions P ON D.id = P.domain_id
WHERE (P.user_id=:userId OR :userIsAdmin)
WHERE (P.user_id=:userId OR :userIsAdmin) AND
(R.type <> \'SOA\' OR R.type IS NULL)
GROUP BY D.id
HAVING
(D.name LIKE :nameQuery) AND
@ -223,7 +224,7 @@ class Domains
$query = $this->db->prepare('
SELECT D.id,D.name,D.type,D.master,COUNT(R.domain_id) AS records FROM domains D
LEFT OUTER JOIN records R ON D.id = R.domain_id
WHERE D.id=:id
WHERE D.id=:id AND (R.type <> \'SOA\' OR R.type IS NULL)
GROUP BY D.id,D.name,D.type,D.master
');
$query->bindValue(':id', $id, \PDO::PARAM_INT);

View file

@ -72,7 +72,8 @@ class Records
(R.domain_id IN ' . $setDomains . ' OR :noDomainFilter) AND
(R.name LIKE :queryName) AND
(R.type IN ' . $setTypes . ' OR :noTypeFilter) AND
(R.content LIKE :queryContent)
(R.content LIKE :queryContent) AND
R.type <> \'SOA\'
');
$query->bindValue(':userId', $userId, \PDO::PARAM_INT);
@ -107,7 +108,8 @@ class Records
(R.domain_id IN ' . $setDomains . ' OR :noDomainFilter) AND
(R.name LIKE :queryName) AND
(R.type IN ' . $setTypes . ' OR :noTypeFilter) AND
(R.content LIKE :queryContent)
(R.content LIKE :queryContent) AND
R.type <> \'SOA\'
GROUP BY R.id' . $ordStr . $pageStr);
$query->bindValue(':userId', $userId, \PDO::PARAM_INT);

View file

@ -143,7 +143,8 @@ INSERT INTO `records` (`id`, `domain_id`, `name`, `type`, `content`, `ttl`, `pri
(1, 1, 'test.example.com', 'A', '12.34.56.78', 86400, 0, 1521645110, 0, NULL, 1),
(2, 1, 'sdfdf.example.com', 'TXT', 'foo bar baz', 60, 10, 1522321931, 0, NULL, 1),
(3, 1, 'foo.example.com', 'AAAA', '::1', 86400, 0, 1522321902, 0, NULL, 1),
(4, 3, 'foo.de', 'A', '9.8.7.6', 86400, 0, 1522321989, 0, NULL, 1);
(4, 3, 'foo.de', 'A', '9.8.7.6', 86400, 0, 1522321989, 0, NULL, 1),
(5, 1, 'example.com', 'SOA', 'ns1.example.com hostmaster.example.com 2018041300 3600 900 604800 86400', 86400, NULL, 1523629358, 0, NULL, 1);
-- --------------------------------------------------------

View file

@ -50,7 +50,7 @@ test.run(async function () {
//Getting soa data from master zone without soa should fail
var res = await req({
url: '/domains/1/soa',
url: '/domains/4/soa',
method: 'get'
});
@ -58,7 +58,7 @@ test.run(async function () {
//Getting soa data from slave zone should fail
var res = await req({
url: '/domains/1/soa',
url: '/domains/2/soa',
method: 'get'
});

View file

@ -78,7 +78,7 @@ test.run(async function () {
assert.equal(res.status, 201, 'Adding of record should succeed.');
assert.equal(res.data, {
id: 5,
id: 6,
name: 'dns.example.com',
type: 'A',
content: '1.2.3.4',
@ -97,13 +97,13 @@ test.run(async function () {
//Get created record
var res = await req({
url: '/records/5',
url: '/records/6',
method: 'get'
});
assert.equal(res.status, 200, 'Get of created record should succeed.');
assert.equal(res.data, {
id: 5,
id: 6,
name: 'dns.example.com',
type: 'A',
content: '1.2.3.4',
@ -115,7 +115,7 @@ test.run(async function () {
//Update record
var res = await req({
url: '/records/5',
url: '/records/6',
method: 'put',
data: {
name: 'foo.example.com'
@ -126,13 +126,13 @@ test.run(async function () {
//Get updated record
var res = await req({
url: '/records/5',
url: '/records/6',
method: 'get'
});
assert.equal(res.status, 200, 'Get updated record should succeed.');
assert.equal(res.data, {
id: 5,
id: 6,
name: 'foo.example.com',
type: 'A',
content: '1.2.3.4',
@ -151,7 +151,7 @@ test.run(async function () {
//Delete existing record
var res = await req({
url: '/records/5',
url: '/records/6',
method: 'delete'
});
@ -212,7 +212,7 @@ test.run(async function () {
assert.equal(res.status, 201, 'Adding of record should succeed.');
assert.equal(res.data, {
id: 6,
id: 7,
name: 'dns.example.com',
type: 'A',
content: '1.2.3.4',
@ -223,13 +223,13 @@ test.run(async function () {
//Get created record
var res = await req({
url: '/records/6',
url: '/records/7',
method: 'get'
});
assert.equal(res.status, 200, 'Get of created record should succeed.');
assert.equal(res.data, {
id: 6,
id: 7,
name: 'dns.example.com',
type: 'A',
content: '1.2.3.4',
@ -241,7 +241,7 @@ test.run(async function () {
//Update record
var res = await req({
url: '/records/6',
url: '/records/7',
method: 'put',
data: {
name: 'foo.example.com',
@ -253,13 +253,13 @@ test.run(async function () {
//Get updated record
var res = await req({
url: '/records/6',
url: '/records/7',
method: 'get'
});
assert.equal(res.status, 200, 'Get updated record should succeed.');
assert.equal(res.data, {
id: 6,
id: 7,
name: 'foo.example.com',
type: 'A',
content: '1.2.3.4',
@ -270,7 +270,7 @@ test.run(async function () {
//Delete existing record
var res = await req({
url: '/records/6',
url: '/records/7',
method: 'delete'
});

View file

@ -38,6 +38,8 @@ test.run(async function () {
});
assert.equal(res.data.results, sortedData, 'Sort failed for ' + res.config.url);
assert.equal(res.data.results.filter((i) => i.type === 'SOA').length, 0, 'No soa should be in records');
}
//Test paging
@ -91,7 +93,8 @@ test.run(async function () {
priority: 0,
ttl: 86400,
domain: 3
}], 'Result fail for ' + res.config.url);
},
], 'Result fail for ' + res.config.url);
//Type filter
var res = await req({
@ -126,24 +129,26 @@ test.run(async function () {
});
assert.equal(res.status, 200, 'Status should be OK');
assert.equal(res.data.results, [{
id: 1,
name: 'test.example.com',
type: 'A',
content: '12.34.56.78',
priority: 0,
ttl: 86400,
domain: 1
},
{
id: 4,
name: 'foo.de',
type: 'A',
content: '9.8.7.6',
priority: 0,
ttl: 86400,
domain: 3
}], 'Result fail for ' + res.config.url);
assert.equal(res.data.results, [
{
id: 1,
name: 'test.example.com',
type: 'A',
content: '12.34.56.78',
priority: 0,
ttl: 86400,
domain: 1
},
{
id: 4,
name: 'foo.de',
type: 'A',
content: '9.8.7.6',
priority: 0,
ttl: 86400,
domain: 3
}
], 'Result fail for ' + res.config.url);
});
await test('user', async function (assert, req) {