Browse Source

Merge branch 'staging' into production

pull/745/head
Julian Simioni 9 years ago
parent
commit
59fdc3ad12
  1. 28
      Dockerfile
  2. 18
      pelias.json.docker
  3. 8
      sanitiser/_ids.js
  4. 32
      test/unit/sanitiser/_ids.js

28
Dockerfile

@ -0,0 +1,28 @@
FROM node:0.12
MAINTAINER Pelias
EXPOSE 3100
LABEL io.openshift.expose-services 3100:http
# Where the app is built and run inside the docker fs
ENV WORK=/opt/pelias
# Used indirectly for saving npm logs etc.
ENV HOME=/opt/pelias
WORKDIR ${WORK}
ADD . ${WORK}
# Build and set permissions for arbitary non-root user
RUN npm install && \
npm test && \
chmod -R a+rwX .
ADD pelias.json.docker pelias.json
# Don't run as root, because there's no reason to (https://docs.docker.com/engine/articles/dockerfile_best-practices/#user).
# This also reveals permission problems on local Docker.
RUN chown -R 9999:9999 ${WORK}
USER 9999
CMD npm start

18
pelias.json.docker

@ -0,0 +1,18 @@
{
"esclient": {
"hosts": [
{
"env": "production",
"protocol": "http",
"host": "pelias-data-container",
"port": 9200
},
{
"env": "production",
"protocol": "http",
"host": "pelias-data-container",
"port": 9300
}
]
}
}

8
sanitiser/_ids.js

@ -45,7 +45,13 @@ function sanitizeId(rawId, messages) {
return;
}
var types = type_mapping.source_and_layer_to_type(source, layer);
//TODO: remove this once we have a better set of layers for Geonames
var types;
if (source === 'gn' || source === 'geonames') {
types = ['geoname'];
} else {
types = type_mapping.source_and_layer_to_type(source, layer);
}
return {
id: id,

32
test/unit/sanitiser/_ids.js

@ -2,10 +2,6 @@ var sanitize = require('../../../sanitiser/_ids');
var delimiter = ':';
var type_mapping = require('../../../helper/type_mapping');
var inputs = {
valid: [ 'geoname:1', 'osmnode:2', 'admin0:53', 'osmway:44', 'geoname:5' ],
invalid: [ ':', '', '::', 'geoname:', ':234', 'gibberish:23' ]
};
var formatError = function(input) {
return 'id `' + input + ' is invalid: must be of the format source:layer:id for ex: \'geonames:venue:4163334\'';
@ -126,6 +122,34 @@ module.exports.tests.valid_ids = function(test, common) {
});
};
module.exports.tests.geonames = function(test, common) {
test('geonames venue maps correctly as normal', function(t) {
var raw = { ids: 'geonames:venue:15' };
var clean = {};
var messages = sanitize( raw, clean);
var expected_clean = { ids: [ { id: '15', types: [ 'geoname' ] } ] };
t.deepEqual( messages.errors, [], 'no errors' );
t.deepEqual( messages.warnings, [], 'no warnings' );
t.deepEqual(clean, expected_clean, 'clean set correctly');
t.end();
});
test('arbitrary geonames layer maps to geoname type', function(t) {
var raw = { ids: 'geonames:address:16' }; // geonames technically has no address records!
var clean = {};
var messages = sanitize( raw, clean);
var expected_clean = { ids: [ { id: '16', types: [ 'geoname' ] } ] };
t.deepEqual( messages.errors, [], 'no errors' );
t.deepEqual( messages.warnings, [], 'no warnings' );
t.deepEqual(clean, expected_clean, 'clean set correctly');
t.end();
});
};
module.exports.tests.multiple_ids = function(test, common) {
test('multiple ids', function(t) {
var raw = { ids: 'geonames:venue:1,osm:venue:2' };

Loading…
Cancel
Save