Browse Source

Merge pull request #969 from pelias/master

Merge master into staging
pull/970/head
Julian Simioni 7 years ago committed by GitHub
parent
commit
2a8ef37dbc
  1. 50
      .dockerignore
  2. 15
      sanitizer/_request_language.js
  3. 3
      sanitizer/autocomplete.js
  4. 3
      sanitizer/nearby.js
  5. 3
      sanitizer/place.js
  6. 3
      sanitizer/reverse.js
  7. 3
      sanitizer/search.js
  8. 3
      sanitizer/structured_geocoding.js
  9. 1
      test/unit/run.js
  10. 35
      test/unit/sanitizer/_request_language.js
  11. 11
      test/unit/sanitizer/autocomplete.js
  12. 11
      test/unit/sanitizer/nearby.js
  13. 11
      test/unit/sanitizer/place.js
  14. 11
      test/unit/sanitizer/reverse.js
  15. 11
      test/unit/sanitizer/search.js
  16. 11
      test/unit/sanitizer/structured_geocoding.js

50
.dockerignore

@ -1 +1,51 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# Git
.git

15
sanitizer/_request_language.js

@ -0,0 +1,15 @@
// this sanitizer exists solely to allow `lang` as a request parameter
function _sanitize( raw, clean ){
// error & warning messages
return { errors: [], warnings: [] };
}
function _expected(){
return [{ 'name': 'lang' }];
}
// export function
module.exports = () => ({
sanitize: _sanitize,
expected: _expected
});

3
sanitizer/autocomplete.js

@ -17,7 +17,8 @@ module.exports.middleware = (_api_pelias_config) => {
location_bias: require('../sanitizer/_location_bias')(_api_pelias_config.defaultParameters),
geo_autocomplete: require('../sanitizer/_geo_autocomplete')(),
boundary_country: require('../sanitizer/_boundary_country')(),
categories: require('../sanitizer/_categories')()
categories: require('../sanitizer/_categories')(),
request_language: require('../sanitizer/_request_language')()
};
return ( req, res, next ) => {

3
sanitizer/nearby.js

@ -15,7 +15,8 @@ var sanitizers = {
private: require('../sanitizer/_flag_bool')('private', false),
geo_reverse: require('../sanitizer/_geo_reverse')(),
boundary_country: require('../sanitizer/_boundary_country')(),
categories: require('../sanitizer/_categories')()
categories: require('../sanitizer/_categories')(),
request_language: require('../sanitizer/_request_language')()
};
// middleware

3
sanitizer/place.js

@ -4,7 +4,8 @@ var sanitizeAll = require('../sanitizer/sanitizeAll'),
singleScalarParameters: require('../sanitizer/_single_scalar_parameters')(),
debug: require('../sanitizer/_debug')(),
ids: require('../sanitizer/_ids')(),
private: require('../sanitizer/_flag_bool')('private', false)
private: require('../sanitizer/_flag_bool')('private', false),
request_language: require('../sanitizer/_request_language')()
};
// middleware

3
sanitizer/reverse.js

@ -13,7 +13,8 @@ var sanitizeAll = require('../sanitizer/sanitizeAll'),
size: require('../sanitizer/_size')(/* use defaults*/),
private: require('../sanitizer/_flag_bool')('private', false),
geo_reverse: require('../sanitizer/_geo_reverse')(),
boundary_country: require('../sanitizer/_boundary_country')()
boundary_country: require('../sanitizer/_boundary_country')(),
request_language: require('../sanitizer/_request_language')()
};
// middleware

3
sanitizer/search.js

@ -18,7 +18,8 @@ module.exports.middleware = (_api_pelias_config) => {
boundary_country: require('../sanitizer/_boundary_country')(),
categories: require('../sanitizer/_categories')(),
// this can go away once geonames has been abrogated
geonames_warnings: require('../sanitizer/_geonames_warnings')()
geonames_warnings: require('../sanitizer/_geonames_warnings')(),
request_language: require('../sanitizer/_request_language')()
};
return ( req, res, next ) => {

3
sanitizer/structured_geocoding.js

@ -19,7 +19,8 @@ module.exports.middleware = (_api_pelias_config) => {
location_bias: require('../sanitizer/_location_bias')(_api_pelias_config.defaultParameters),
geo_search: require('../sanitizer/_geo_search')(),
boundary_country: require('../sanitizer/_boundary_country')(),
categories: require('../sanitizer/_categories')()
categories: require('../sanitizer/_categories')(),
request_language: require('../sanitizer/_request_language')()
};
return ( req, res, next ) => {

1
test/unit/run.js

@ -76,6 +76,7 @@ var tests = [
require('./sanitizer/_layers'),
require('./sanitizer/_location_bias'),
require('./sanitizer/_city_name_standardizer'),
require('./sanitizer/_request_language'),
require('./sanitizer/_single_scalar_parameters'),
require('./sanitizer/_size'),
require('./sanitizer/_sources'),

35
test/unit/sanitizer/_request_language.js

@ -0,0 +1,35 @@
const sanitizer = require('../../../sanitizer/_request_language')();
module.exports.tests = {};
module.exports.tests.do_nothing = (test, common) => {
test('sanitize should return empty warnings/erros', t => {
const messages = sanitizer.sanitize();
t.deepEquals(messages.errors, [], 'no errors');
t.deepEquals(messages.warnings, [], 'no warnings');
t.end();
});
};
module.exports.tests.expected = (test, common) => {
test('expected should contain only \'lang\'', t => {
const expected = sanitizer.expected();
t.deepEquals(expected, [{'name': 'lang'}]);
t.end();
});
};
module.exports.all = (tape, common) => {
function test(name, testFunction) {
return tape(`SANITIZE _request_language: ${name}`, testFunction);
}
for( const testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};

11
test/unit/sanitizer/autocomplete.js

@ -120,6 +120,14 @@ module.exports.tests.sanitizers = function(test, common) {
return { errors: [], warnings: [] };
}
};
},
'../sanitizer/_request_language': () => {
return {
sanitize: () => {
called_sanitizers.push('_request_language');
return { errors: [], warnings: [] };
}
};
}
});
@ -136,7 +144,8 @@ module.exports.tests.sanitizers = function(test, common) {
'_location_bias',
'_geo_autocomplete',
'_boundary_country',
'_categories'
'_categories',
'_request_language'
];
const req = {};

11
test/unit/sanitizer/nearby.js

@ -109,6 +109,14 @@ module.exports.tests.sanitize = function(test, common) {
return { errors: [], warnings: [] };
}
};
},
'../sanitizer/_request_language': () => {
return {
sanitize: () => {
called_sanitizers.push('_request_language');
return { errors: [], warnings: [] };
}
};
}
});
@ -124,7 +132,8 @@ module.exports.tests.sanitize = function(test, common) {
'_flag_bool',
'_geo_reverse',
'_boundary_country',
'_categories'
'_categories',
'_request_language'
];
const req = {};

11
test/unit/sanitizer/place.js

@ -45,6 +45,14 @@ module.exports.tests.sanitize = function(test, common) {
} else {
throw new Error('incorrect parameters passed to _flag_bool');
}
},
'../sanitizer/_request_language': () => {
return {
sanitize: () => {
called_sanitizers.push('_request_language');
return { errors: [], warnings: [] };
}
};
}
});
@ -52,7 +60,8 @@ module.exports.tests.sanitize = function(test, common) {
'_single_scalar_parameters',
'_debug',
'_ids',
'_flag_bool'
'_flag_bool',
'_request_language'
];
const req = {};

11
test/unit/sanitizer/reverse.js

@ -101,6 +101,14 @@ module.exports.tests.sanitize = function(test, common) {
return { errors: [], warnings: [] };
}
};
},
'../sanitizer/_request_language': () => {
return {
sanitize: () => {
called_sanitizers.push('_request_language');
return { errors: [], warnings: [] };
}
};
}
});
@ -115,7 +123,8 @@ module.exports.tests.sanitize = function(test, common) {
'_size',
'_flag_bool',
'_geo_reverse',
'_boundary_country'
'_boundary_country',
'_request_language'
];
const req = {};

11
test/unit/sanitizer/search.js

@ -133,6 +133,14 @@ module.exports.tests.sanitize = (test, common) => {
}
}
};
},
'../sanitizer/_request_language': () => {
return {
sanitize: () => {
called_sanitizers.push('_request_language');
return { errors: [], warnings: [] };
}
};
}
});
@ -151,7 +159,8 @@ module.exports.tests.sanitize = (test, common) => {
'_geo_search',
'_boundary_country',
'_categories',
'_geonames_warnings'
'_geonames_warnings',
'_request_language'
];
const req = {};

11
test/unit/sanitizer/structured_geocoding.js

@ -137,6 +137,14 @@ module.exports.tests.sanitize = function(test, common) {
}
}
};
},
'../sanitizer/_request_language': () => {
return {
sanitize: () => {
called_sanitizers.push('_request_language');
return { errors: [], warnings: [] };
}
};
}
});
@ -155,7 +163,8 @@ module.exports.tests.sanitize = function(test, common) {
'_location_bias',
'_geo_search',
'_boundary_country',
'_categories'
'_categories',
'_request_language'
];
var req = {};

Loading…
Cancel
Save