Fixed bug where numbers where returned as string
This commit is contained in:
parent
5928203a0a
commit
6ec9c81c32
|
@ -103,6 +103,8 @@ class Domains
|
||||||
if ($item['type'] != 'SLAVE') {
|
if ($item['type'] != 'SLAVE') {
|
||||||
unset($item['master']);
|
unset($item['master']);
|
||||||
}
|
}
|
||||||
|
$item['id'] = intval($item['id']);
|
||||||
|
$item['records'] = intval($item['records']);
|
||||||
return $item;
|
return $item;
|
||||||
}, $data);
|
}, $data);
|
||||||
}
|
}
|
||||||
|
@ -147,6 +149,7 @@ class Domains
|
||||||
$query->execute();
|
$query->execute();
|
||||||
|
|
||||||
$record = $query->fetch();
|
$record = $query->fetch();
|
||||||
|
$record['id'] = intval($record['id']);
|
||||||
if ($type !== 'SLAVE') {
|
if ($type !== 'SLAVE') {
|
||||||
unset($record['master']);
|
unset($record['master']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const cartesianProduct = require('cartesian-product');
|
const cartesianProduct = require('cartesian-product');
|
||||||
|
|
||||||
require('../testlib')('admin', async function (assert, req) {
|
(async function () {
|
||||||
|
await require('../testlib')('admin', async function (assert, req) {
|
||||||
//Test missing fields
|
//Test missing fields
|
||||||
var res = await req({
|
var res = await req({
|
||||||
url: '/domains',
|
url: '/domains',
|
||||||
|
@ -46,7 +47,7 @@ require('../testlib')('admin', async function (assert, req) {
|
||||||
|
|
||||||
assert.equal(res.status, 201, 'Creation should be successfull');
|
assert.equal(res.status, 201, 'Creation should be successfull');
|
||||||
assert.equal(res.data, {
|
assert.equal(res.data, {
|
||||||
id: '6',
|
id: 6,
|
||||||
name: 'master.de',
|
name: 'master.de',
|
||||||
type: 'MASTER'
|
type: 'MASTER'
|
||||||
}, 'Creation result fail.')
|
}, 'Creation result fail.')
|
||||||
|
@ -63,7 +64,7 @@ require('../testlib')('admin', async function (assert, req) {
|
||||||
|
|
||||||
assert.equal(res.status, 201, 'Creation should be successfull');
|
assert.equal(res.status, 201, 'Creation should be successfull');
|
||||||
assert.equal(res.data, {
|
assert.equal(res.data, {
|
||||||
id: '7',
|
id: 7,
|
||||||
name: 'native.de',
|
name: 'native.de',
|
||||||
type: 'NATIVE'
|
type: 'NATIVE'
|
||||||
}, 'Creation result fail.')
|
}, 'Creation result fail.')
|
||||||
|
@ -74,19 +75,21 @@ require('../testlib')('admin', async function (assert, req) {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
name: 'slave.de',
|
name: 'slave.de',
|
||||||
type: 'SLAVE'
|
type: 'SLAVE',
|
||||||
|
master: '1.2.3.4'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(res.status, 201, 'Creation should be successfull');
|
assert.equal(res.status, 201, 'Creation should be successfull');
|
||||||
assert.equal(res.data, {
|
assert.equal(res.data, {
|
||||||
id: '8',
|
id: 8,
|
||||||
name: 'slave.de',
|
name: 'slave.de',
|
||||||
type: 'SLAVE'
|
type: 'SLAVE',
|
||||||
|
master: '1.2.3.4'
|
||||||
}, 'Creation result fail.')
|
}, 'Creation result fail.')
|
||||||
});
|
});
|
||||||
|
|
||||||
require('../testlib')('user', async function (assert, req) {
|
await require('../testlib')('user', async function (assert, req) {
|
||||||
//Test insufficient privileges
|
//Test insufficient privileges
|
||||||
var res = await req({
|
var res = await req({
|
||||||
url: '/domains',
|
url: '/domains',
|
||||||
|
@ -97,4 +100,6 @@ require('../testlib')('user', async function (assert, req) {
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(res.status, 403, 'Domain creation should be forbidden for users.')
|
assert.equal(res.status, 403, 'Domain creation should be forbidden for users.')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
})();
|
|
@ -1,6 +1,7 @@
|
||||||
const cartesianProduct = require('cartesian-product');
|
const cartesianProduct = require('cartesian-product');
|
||||||
|
|
||||||
require('../testlib')('admin', async function (assert, req) {
|
(async function () {
|
||||||
|
require('../testlib')('admin', async function (assert, req) {
|
||||||
//GET /domains?page=5&pagesize=10&query=foo&sort=id-asc,name-desc,type-asc,records-asc&type=MASTER
|
//GET /domains?page=5&pagesize=10&query=foo&sort=id-asc,name-desc,type-asc,records-asc&type=MASTER
|
||||||
|
|
||||||
//Test sorting in all combinations
|
//Test sorting in all combinations
|
||||||
|
@ -74,17 +75,17 @@ require('../testlib')('admin', async function (assert, req) {
|
||||||
assert.equal(res.status, 200, 'Status should be OK');
|
assert.equal(res.status, 200, 'Status should be OK');
|
||||||
assert.equal(res.data.results, [
|
assert.equal(res.data.results, [
|
||||||
{
|
{
|
||||||
id: '2',
|
id: 2,
|
||||||
name: 'slave.example.net',
|
name: 'slave.example.net',
|
||||||
type: 'SLAVE',
|
type: 'SLAVE',
|
||||||
master: '12.34.56.78',
|
master: '12.34.56.78',
|
||||||
records: '0'
|
records: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '4',
|
id: 4,
|
||||||
name: 'bar.net',
|
name: 'bar.net',
|
||||||
type: 'MASTER',
|
type: 'MASTER',
|
||||||
records: '0'
|
records: 0
|
||||||
}
|
}
|
||||||
], 'Result fail for ' + res.config.url);
|
], 'Result fail for ' + res.config.url);
|
||||||
|
|
||||||
|
@ -97,10 +98,11 @@ require('../testlib')('admin', async function (assert, req) {
|
||||||
assert.equal(res.status, 200, 'Status should be OK');
|
assert.equal(res.status, 200, 'Status should be OK');
|
||||||
assert.equal(res.data.results, [
|
assert.equal(res.data.results, [
|
||||||
{
|
{
|
||||||
id: '3',
|
id: 3,
|
||||||
name: 'foo.de',
|
name: 'foo.de',
|
||||||
type: 'NATIVE',
|
type: 'NATIVE',
|
||||||
records: '0'
|
records: 0
|
||||||
}
|
}
|
||||||
], 'Result fail for ' + res.config.url);
|
], 'Result fail for ' + res.config.url);
|
||||||
});
|
});
|
||||||
|
})();
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
require('../testlib')('admin', async function (assert, req) {
|
(async function () {
|
||||||
|
require('../testlib')('admin', async function (assert, req) {
|
||||||
//Try to login with invalid username and password
|
//Try to login with invalid username and password
|
||||||
var res = await req({
|
var res = await req({
|
||||||
url: '/sessions',
|
url: '/sessions',
|
||||||
|
@ -58,4 +59,5 @@ require('../testlib')('admin', async function (assert, req) {
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(res.status, 201, 'Status not valid');
|
assert.equal(res.status, 201, 'Status not valid');
|
||||||
});
|
});
|
||||||
|
})();
|
Loading…
Reference in a new issue