CartoDB-SQL-API/test/acceptance/app.test.js

61 lines
1.8 KiB
JavaScript
Raw Normal View History

require('../helper');
2011-06-20 21:39:12 +08:00
// Requires the database and tables setup in config/environments/test.js to exist
// Ensure the user is present in the pgbouncer auth file too
var app = require(global.settings.app_root + '/app/controllers/app')
, assert = require('assert');
module.exports = {
'GET /api/v1/': function(){
assert.response(app, {
url: '/api/v1/',
method: 'GET'
},{
body: '{"error":["You must indicate a sql query"]}',
status: 400
});
2011-06-20 21:39:12 +08:00
},
'GET /api/v1/ with SQL parameter on SELECT only. No oAuth included ': function(){
2011-06-20 21:39:12 +08:00
assert.response(app, {
url: '/api/v1/?sql=SELECT%20*%20FROM%20test_table&database=cartodb_test_user_1_db',
2011-06-20 21:39:12 +08:00
method: 'GET'
},{
status: 200
});
},
'GET /api/v1/ with SQL parameter on SELECT only. oAuth used ': function(){
2011-06-20 21:39:12 +08:00
assert.response(app, {
url: '/api/v1/?sql=SELECT%20*%20FROM%20test_table&oauth_token=1',
2011-06-20 21:39:12 +08:00
method: 'GET'
},{
status: 200
});
},
'GET /api/v1/ with SQL parameter on INSERT only. oAuth used ': function(){
2011-06-20 21:39:12 +08:00
assert.response(app, {
url: "/api/v1/?sql=INSERT%20INTO%20test_table%20(id)%20VALUES%20(1)&oauth_token=1",
2011-06-20 21:39:12 +08:00
method: 'GET'
},{
status: 200
});
},
'GET /api/v1/ with SQL parameter on INSERT only. oAuth not used, so public user - should fail': function(){
assert.response(app, {
url: "/api/v1/?sql=INSERT%20INTO%20test_table%20(id)%20VALUES%20(1)&database=cartodb_test_user_1_db",
method: 'GET'
},{
status: 400
});
2011-06-21 00:22:46 +08:00
},
'GET /api/v1/ with SQL parameter on DROP DATABASE nly. oAuth not used, so public user - should fail': function(){
2011-06-21 00:22:46 +08:00
assert.response(app, {
url: "/api/v1/?sql=DROP%20TABLE%20cartodb_test_user_1_db&database=cartodb_test_user_1_db",
2011-06-21 00:22:46 +08:00
method: 'GET'
},{
status: 400
});
2011-06-20 21:39:12 +08:00
}
2011-06-21 00:22:46 +08:00
};