Commit f44fbbbb authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Merge branch 'release-0.21.0' into 'master'

Release-0.21.0

See merge request redmic-project/client/web!94
parents 8b8e7801 70490321
Loading
Loading
Loading
Loading

.gitlab-ci.build.yml

0 → 100644
+56 −0
Original line number Diff line number Diff line
.web-build:
  image: ${WEB_BUILD_IMAGE_NAME}:${WEB_BUILD_IMAGE_TAG}
  variables:
    GIT_SUBMODULE_STRATEGY: normal
    WEB_BUILD_IMAGE_NAME: registry.gitlab.com/redmic-project/docker/web-build
    WEB_BUILD_IMAGE_TAG: latest
  before_script:
    - type yarn grunt java
    - yarn install
    - grunt preBuild
  cache:
    paths:
      - node_modules/
      - public/javascript/redmic-widgets/node_modules/
      - public/javascript/templates/node_modules/
      - public/stylesheets/node_modules/

prepare-unbuilt-version:
  extends: .web-build
  stage: pre-build
  script: ':'
  artifacts:
    name: ${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}
    expire_in: 1 week
    paths:
      - node_modules/
      - public/javascript/proj4js/dist/proj4.js
      - public/javascript/redmic-widgets/src/app/
      - public/javascript/templates/dist/
      - public/stylesheets/style.styl
      - public/stylesheets/src/
      - public/stylesheets/submodules/
  rules:
    - if: $CI_MERGE_REQUEST_ID ||
          $CI_COMMIT_TAG ||
          $CI_PIPELINE_SOURCE == "schedule" ||
          $CI_COMMIT_BRANCH == "master"
      when: never
    - if: $CI_COMMIT_BRANCH

prepare-built-version:
  extends: .web-build
  stage: build
  script:
    - grunt
  dependencies: []
  artifacts:
    name: ${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}
    expire_in: 1 month
    paths:
      - dist*.tar.gz
  rules:
    - if: $CI_MERGE_REQUEST_ID ||
          $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - if: $CI_COMMIT_BRANCH || $CI_COMMIT_TAG

.gitlab-ci.test.yml

0 → 100644
+125 −0
Original line number Diff line number Diff line
.run-tests:
  extends: .web-build
  tags:
    - custom-runner
  cache:
    policy: pull

.run-pre-build-tests:
  extends: .run-tests
  stage: pre-build
  rules:
    - if: $CI_MERGE_REQUEST_ID ||
          $CI_COMMIT_TAG ||
          $CI_PIPELINE_SOURCE == "schedule" ||
          $CI_COMMIT_BRANCH == "master"
      when: never
    - if: $CI_COMMIT_BRANCH
  allow_failure: true

.run-local-tests:
  variables: &run-local-tests-variables
    TEST_BROWSER: chrome

.run-remote-tests:
  variables: &run-remote-tests-variables
    TEST_REMOTE_HOST: selenium-hub

.run-unit-tests:
  extends: .run-pre-build-tests
  after_script:
    - coverage=$(grep '^All files.*' test.out | cut -d '|' -f 2 | tr -d ' ')
    - echo "Coverage - ${coverage}%"
    - rm test.out

run-local-unit-tests:
  extends: .run-unit-tests
  variables:
    <<: *run-local-tests-variables
  script:
    - >
      grunt test-unit-local --headless --browser=${TEST_BROWSER} --seleniumVersion=${LOCAL_SELENIUM_VERSION}
      --chromeVersion=${LOCAL_CHROME_VERSION} | tee test.out

.run-remote-unit-tests:
  extends: .run-unit-tests
  variables:
    <<: *run-remote-tests-variables
  script:
    - >
      grunt test-unit-remote --headless --browser=${TEST_BROWSER} --ownServerHost="${TEST_OWN_SERVER_HOST}"
      --remoteHost=${TEST_REMOTE_HOST} --seleniumVersion=${REMOTE_SELENIUM_VERSION}
      --chromeVersion=${REMOTE_CHROME_VERSION} --firefoxVersion=${REMOTE_FIREFOX_VERSION} | tee test.out

run-remote-unit-tests-chrome:
  extends: .run-remote-unit-tests
  variables:
    TEST_BROWSER: chrome

run-remote-unit-tests-firefox:
  extends: .run-remote-unit-tests
  variables:
    TEST_BROWSER: firefox

.run-functional-tests:
  artifacts: &run-functional-tests-artifacts
    name: ${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}
    expire_in: 1 month
    when: always
    paths:
      - 'test_reports/test-functional*'

run-local-modules-functional-tests:
  extends: .run-pre-build-tests
  variables:
    <<: *run-local-tests-variables
  script:
    - grunt buildStyles
    - npm start &
    - >
      grunt test-functional-local --functionalSuites=tests/functional/modules/**/!\(*Script\).js --headless
      --browser=${TEST_BROWSER} --seleniumVersion=${LOCAL_SELENIUM_VERSION} --chromeVersion=${LOCAL_CHROME_VERSION}
  artifacts: &run-functional-tests-artifacts

.run-remote-modules-functional-tests:
  extends: .run-pre-build-tests
  variables:
    <<: *run-remote-tests-variables
  script:
    - grunt buildStyles
    - npm start &
    - >
      grunt test-functional-remote --functionalSuites=tests/functional/modules/**/!\(*Script\).js --headless
      --browser=${TEST_BROWSER} --ownServerHost="${TEST_OWN_SERVER_HOST}" --remoteHost=${TEST_REMOTE_HOST}
      --seleniumVersion=${REMOTE_SELENIUM_VERSION} --chromeVersion=${REMOTE_CHROME_VERSION}
      --firefoxVersion=${REMOTE_FIREFOX_VERSION}
  artifacts: &run-functional-tests-artifacts

run-remote-modules-functional-tests-chrome:
  extends: .run-remote-modules-functional-tests
  variables:
    TEST_BROWSER: chrome

run-remote-modules-functional-tests-firefox:
  extends: .run-remote-modules-functional-tests
  variables:
    TEST_BROWSER: firefox

run-scheduled-remote-functional-tests:
  extends: .run-tests
  stage: test-deploy
  variables:
    <<: *run-remote-tests-variables
    SERVER_URL: https://${DEV_PUBLIC_HOSTNAME}
    TEST_BROWSER: chrome
    TEST_ROLE: administrator
  script:
    - >
      grunt test-functional-remote --serverUrl="${SERVER_URL}" --user="${REDMIC_TEST_USER}" --pass="${REDMIC_TEST_PASS}"
      --role=${TEST_ROLE} --suitesGroups="${SUITES_GROUPS}" --browser=${TEST_BROWSER} --remoteHost=${TEST_REMOTE_HOST}
      --seleniumVersion=${REMOTE_SELENIUM_VERSION} --chromeVersion=${REMOTE_CHROME_VERSION}
      --firefoxVersion=${REMOTE_FIREFOX_VERSION}
  dependencies: []
  artifacts: &run-functional-tests-artifacts
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
+3 −106
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ include:
  - project: 'redmic-project/gitlab-ci-templates'
    ref: master
    file: '/deployment-custom-image.yml'
  - local: '/.gitlab-ci.build.yml'
  - local: '/.gitlab-ci.test.yml'

stages:
  - pre-build
@@ -22,113 +24,8 @@ stages:
  - deploy
  - test-deploy

variables:
  PROJECT_PARENT_NAME: client

.web-build:
  image: ${WEB_BUILD_IMAGE_NAME}:${WEB_BUILD_IMAGE_TAG}
  variables:
    GIT_SUBMODULE_STRATEGY: normal
    WEB_BUILD_IMAGE_NAME: registry.gitlab.com/redmic-project/docker/web-build
    WEB_BUILD_IMAGE_TAG: latest
  before_script:
    - type yarn grunt java
    - yarn install
    - grunt preBuild
  cache:
    paths:
      - node_modules/
      - public/javascript/redmic-widgets/node_modules/
      - public/javascript/templates/node_modules/
      - public/stylesheets/node_modules/

.only-non-master-branches-job:
  rules: &only-non-master-branches-job-rules
    - if: $CI_MERGE_REQUEST_ID ||
          $CI_COMMIT_TAG ||
          $CI_PIPELINE_SOURCE == "schedule" ||
          $CI_COMMIT_BRANCH == "master"
      when: never
    - if: $CI_COMMIT_BRANCH

prepare-unbuilt-version:
  extends: .web-build
  stage: pre-build
  script: ':'
  artifacts:
    name: ${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}
    expire_in: 1 week
    paths:
      - node_modules/
      - public/javascript/proj4js/dist/proj4.js
      - public/javascript/redmic-widgets/src/app/
      - public/javascript/templates/dist/
      - public/stylesheets/style.styl
      - public/stylesheets/src/
      - public/stylesheets/submodules/
  rules: *only-non-master-branches-job-rules

run-unit-tests:
  extends: .web-build
  stage: pre-build
  script:
    - grunt test | tee test.out
    - coverage=$(grep '^All files.*' test.out | cut -d '|' -f 2 | tr -d ' ')
    - echo "Coverage - ${coverage}%"
    - rm test.out
  cache:
    policy: pull
  rules: *only-non-master-branches-job-rules

run-modules-functional-tests:
  extends: .web-build
  stage: pre-build
  script:
    - npm start &
    - grunt test-functional-local --functionalSuites=tests/functional/modules/**/!\(*Script\).js --headless
  cache:
    policy: pull
  rules: *only-non-master-branches-job-rules

prepare-built-version:
  extends: .web-build
  stage: build
  script:
    - grunt
  dependencies: []
  artifacts:
    name: ${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}
    expire_in: 1 month
    paths:
      - dist*.tar.gz
  rules:
    - if: $CI_MERGE_REQUEST_ID ||
          $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - if: $CI_COMMIT_BRANCH || $CI_COMMIT_TAG

.deploy:
  variables:
    STACK: ${PROJECT_PARENT_NAME}
    SERVICES_TO_CHECK: ${PROJECT_PARENT_NAME}_${CI_PROJECT_NAME}
    STACK: client
  environment:
    url: https://${PUBLIC_HOSTNAME}

run-functional-tests:
  extends: .web-build
  stage: test-deploy
  script:
    - >
      grunt test-functional-local --serverUrl="https://${DEV_PUBLIC_HOSTNAME}" --user="${REDMIC_TEST_USER}"
      --pass="${REDMIC_TEST_PASS}" --role=administrator --suitesGroups="${SUITES_GROUPS}" --headless
  dependencies: []
  cache:
    policy: pull
  artifacts:
    name: ${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}
    expire_in: 1 month
    when: always
    paths:
      - 'test_reports/test-functional-local*'
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
+41 −32
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@ var express = require('express'),
	bodyParser = require('body-parser'),
	fs = require('fs'),
	path = require('path'),
	request = require('request');
	http = require('http'),
	https = require('https');

var logger, params, version,
	oauthUrl = process.env.OAUTH_URL,
	getTokenUrl = oauthUrl + '/token',
	oauthClientSecret = process.env.OAUTH_CLIENT_SECRET,
	production = !!parseInt(process.env.PRODUCTION, 10),
	apiUrl = process.env.API_URL;
@@ -75,6 +75,11 @@ function onRobotsRequest(req, res) {
	res.send(fileData);
}

function onApiRequest(req, res) {

	res.redirect('/404');
}

function onJqueryRequest(req, res) {

	res.set('Content-Type', 'application/json');
@@ -94,57 +99,61 @@ function onOauthTokenRequest(req, res) {
		password = body.password,
		username = body.username,

		getTokenUrl = oauthUrl + '/token',
		clientCredentials = clientId + ':' + oauthClientSecret,
		base64ClientCredentials = Buffer.from(clientCredentials).toString('base64'),

		authorization = 'Basic ' + base64ClientCredentials,
		bodyData = 'grant_type=password&username=' + username + '&password=' + password + '&scope=write',

		options = {
			url: getTokenUrl,
			method: 'POST',
			body: bodyData,
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded',
				'Authorization': authorization
				'Authorization': 'Basic ' + base64ClientCredentials
			}
		};
		},

	request(options, (function(originalRes, err, res, body) {
		reqLibrary = getTokenUrl.indexOf('https') === -1 ? http : https,
		internalReq = reqLibrary.request(getTokenUrl, options, (function(originalRes, internalRes) {

		if (err) {
			logger.error(err);
			originalRes.sendStatus(500);
			return;
			var chunks = [];

			internalRes.on('data', (function(nestedChunks, chunk) {

				nestedChunks.push(chunk);
			}).bind(this, chunks));

			internalRes.on('end', (function(nestedOriginalRes, nestedChunks) {

				var content = "";
				for (var i = 0; i < nestedChunks.length; i++) {
					content += nestedChunks[i].toString();
				}
				nestedOriginalRes.status(this.statusCode).send(content);
			}).bind(internalRes, originalRes, chunks));
		}).bind(this, res));

	internalReq.on('error', (function(originalRes, err) {

		originalRes.statusCode = res.statusCode;
		originalRes.send(body);
		logger.error(err);
		originalRes.sendStatus(500);
	}).bind(this, res));

	var bodyData = 'grant_type=password&username=' + username + '&password=' + password + '&scope=write';
	internalReq.write(bodyData);
	internalReq.end();
}

function exposeRoutes(app) {

	app.get(
		/^((?!\/(activateAccount|resetting|noSupportBrowser|404|sitemap.xml|robots.txt|node_modules|env|.*\/jquery.js)))(\/.*)$/,
		onGeneralRequest)

		.get('/env', onEnvRequest)

	app.get('/env', onEnvRequest)
		.get('/activateAccount/:token', onActivateAccountRequest)

		.get('/noSupportBrowser', onNoSupportBrowserRequest)

		.get('/404', on404Request)

		.get('/sitemap.xml', onSitemapRequest)

		.get('/robots.txt', onRobotsRequest)

		.get(/\/api\/.*/, onApiRequest)
		.get(/.*\/jquery.js/, onJqueryRequest)

		.get(/.*/, onGeneralRequest)
		.post('/oauth/token', onOauthTokenRequest)

		.use(onUnknownRequest);
}

@@ -156,7 +165,8 @@ function exposeContents(app, directoryName) {
	};

	var exposedPath = path.join(__dirname, '..', directoryName),
		servedPath = express['static'](exposedPath, pathOptions);
		staticPropName = 'static',
		servedPath = express[staticPropName](exposedPath, pathOptions);

	app.use(servedPath)
		.use('/' + directoryName, servedPath);
@@ -171,7 +181,6 @@ function expose(app) {
	} else {
		require('./styles')(app);
		exposeContents(app, 'public');
		exposeContents(app, 'tests');
		exposeContents(app, 'node_modules');
	}

+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ module.exports = function(grunt) {
	var directoriesToDelete = [
		'alertify', 'awesome-markers', 'cbtree', 'd3', 'd3Tip', 'dijit', 'dojo', 'dojox', 'deepmerge', 'dropzone',
		'dstore', 'handlebars', 'L-areaselect', 'L-coordinates', 'L-draw', 'L-miniMap', 'L-navBar', 'leaflet',
		'leaflet-measure', 'leaflet-wms', 'mediatorjs', 'moment', 'node-uuid', 'proj4js', 'pruneCluster',
		'put-selector', 'redmic', 'RWidgets', 'sockjs', 'stompjs', 'templates', 'tv4'
		'leaflet-measure', 'leaflet-nontiledlayer', 'mediatorjs', 'moment', 'node-uuid', 'proj4js', 'pruneCluster',
		'put-selector', 'redmic', 'RWidgets', 'sockjs', 'stompjs', 'templates', 'tv4', 'wicket'
	];

	var recursiveDirectoriesToDelete = [
Loading