Test: Accept PG11 error messages
This commit is contained in:
parent
3f6cccc50b
commit
7eb412cf59
@ -105,9 +105,7 @@ it('GET /api/v1/sql with INSERT. oAuth not used, so public user - should fail',
|
||||
assert.equal(res.statusCode, 403, res.statusCode + ': ' + res.body);
|
||||
assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8');
|
||||
assert.deepEqual(res.headers['content-disposition'], 'inline');
|
||||
assert.deepEqual(JSON.parse(res.body),
|
||||
{"error":["permission denied for relation untitle_table_4"]}
|
||||
);
|
||||
assert.ok(JSON.parse(res.body).error[0].match(/permission denied for .+? untitle_table_4/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -122,9 +120,7 @@ it('GET /api/v1/sql with DROP TABLE. oAuth not used, so public user - should fai
|
||||
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
||||
assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8');
|
||||
assert.deepEqual(res.headers['content-disposition'], 'inline');
|
||||
assert.deepEqual(JSON.parse(res.body),
|
||||
{"error":["must be owner of relation untitle_table_4"]}
|
||||
);
|
||||
assert.ok(JSON.parse(res.body).error[0].match(/must be owner of.+? untitle_table_4/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -148,9 +144,7 @@ it('GET /api/v1/sql with SQL parameter on DROP TABLE. should fail', function(don
|
||||
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
||||
assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8');
|
||||
assert.deepEqual(res.headers['content-disposition'], 'inline');
|
||||
assert.deepEqual(JSON.parse(res.body),
|
||||
{"error":["must be owner of relation untitle_table_4"]}
|
||||
);
|
||||
assert.ok(JSON.parse(res.body).error[0].match(/must be owner of.+? untitle_table_4/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -767,7 +761,7 @@ it('GET with callback must return 200 status error even if it is an error', func
|
||||
var didRunJsonCallback = false;
|
||||
// jshint ignore:start
|
||||
function foo_jsonp(body) {
|
||||
assert.deepEqual(body, {"error":["must be owner of relation untitle_table_4"]});
|
||||
assert.ok(body.error[0].match(/must be owner of.+? untitle_table_4/));
|
||||
didRunJsonCallback = true;
|
||||
}
|
||||
eval(res.body);
|
||||
|
@ -46,7 +46,7 @@ describe('Auth API', function () {
|
||||
};
|
||||
this.testClient.getResult(privateSQL, expectedResponse, (err, result) => {
|
||||
assert.ifError(err);
|
||||
assert.equal(result.error, 'permission denied for relation private_table');
|
||||
assert.ok(result.error[0].match(/permission denied for .+? private_table/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -88,7 +88,7 @@ describe('Auth API', function () {
|
||||
|
||||
this.testClient.getResult(scopedSQL, expectedResponse, (err, result) => {
|
||||
assert.ifError(err);
|
||||
assert.equal(result.error, 'permission denied for relation scoped_table_1');
|
||||
assert.ok(result.error[0].match(/permission denied for .+? scoped_table_1/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -183,7 +183,7 @@ describe('Auth API', function () {
|
||||
|
||||
this.testClient.getResult(scopedSQL, expectedResponse, (err, result) => {
|
||||
assert.ifError(err);
|
||||
assert.equal(result.error, 'permission denied for relation scoped_table_1');
|
||||
assert.ok(result.error[0].match(/permission denied for .+? scoped_table_1/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -68,10 +68,10 @@ describe('copy-statements', function() {
|
||||
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
||||
assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8');
|
||||
assert.deepEqual(res.headers['content-disposition'], 'inline');
|
||||
assert.deepEqual(JSON.parse(res.body), {
|
||||
error: ["must be superuser to COPY to or from a file"],
|
||||
hint: "Anyone can COPY to stdout or from stdin. psql's \\copy command also works for anyone."
|
||||
});
|
||||
const error_exp = /must be superuser.* to COPY.* a file/;
|
||||
const hint_exp = /Anyone can COPY to stdout or from stdin. psql's \\copy command also works for anyone./;
|
||||
assert.ok(JSON.parse(res.body).error[0].match(error_exp));
|
||||
assert.ok(JSON.parse(res.body).hint.match(hint_exp));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -126,8 +126,7 @@ it('GET /api/v1/sql as csv', function(done){
|
||||
method: 'GET'
|
||||
},{ }, function(err, res){
|
||||
assert.equal(res.statusCode, 200, res.body);
|
||||
var expected = 'cartodb_id,geom\r\n1,"SRID=4326;POINT(-3.699732 40.423012)"\r\n';
|
||||
assert.equal(res.body, expected);
|
||||
assert.ok(res.body.match(/cartodb_id,geom\r\n.?1.?,"SRID=4326;POINT(.*)"\r\n/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -155,8 +154,7 @@ it('GET /api/v1/sql as csv, properly escaped', function(done){
|
||||
method: 'GET'
|
||||
},{ }, function(err, res){
|
||||
assert.equal(res.statusCode, 200, res.body);
|
||||
var expected = 'cartodb_id,address\r\n1,"Calle de Pérez Galdós 9, Madrid, Spain"\r\n';
|
||||
assert.equal(res.body, expected);
|
||||
assert.ok(res.body.match(/cartodb_id,address\r\n.?1.?,"Calle de Pérez Galdós 9, Madrid, Spain"\r\n/));
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -166,8 +164,7 @@ it('GET /api/v1/sql as csv, concurrently', function(done){
|
||||
var concurrency = 4;
|
||||
var waiting = concurrency;
|
||||
function validate(err, res){
|
||||
var expected = 'cartodb_id,address\r\n1,"Calle de Pérez Galdós 9, Madrid, Spain"\r\n';
|
||||
assert.equal(res.body, expected);
|
||||
assert.ok(res.body.match(/cartodb_id,address\r\n.?1.?,"Calle de Pérez Galdós 9, Madrid, Spain"\r\n/));
|
||||
if ( ! --waiting ) {
|
||||
done();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user