Skip to content

Commit

Permalink
Fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
vamsee committed Oct 25, 2018
2 parents 8eece3e + 1fecf6a commit c8132b8
Show file tree
Hide file tree
Showing 43 changed files with 1,123 additions and 9,126 deletions.
6 changes: 4 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ npminstall:
- status_eslint=0
- exit_status=0
- npm set progress=false
- time npm install eslint babel-eslint --no-optional
- time npm install eslint babel-eslint grunt grunt-cli grunt-check-copyright --no-optional
- if npm run lint; then status_eslint=0; else status_eslint=1; fi
- if npm run check-copyright; then status_copyright=0; else status_copyright=1; fi
- if [ $status_eslint == 1 ]; then exit_status=1 && echo "esLint errors exist"; fi
- if [ $status_copyright == 1 ]; then exit_status=1 && echo "copyright not present in files"; fi
- if [ $exit_status == 1 ]; then exit $exit_status; fi
- echo "Code style check done successfully"
- echo "Code style and copyright check done successfully"
- time npm install --no-optional
- sed 's/\$REGISTRY/'"$REGISTRY"'/g' Dockerfile > Dockerfile2
- mv -f Dockerfile2 Dockerfile
Expand Down
21 changes: 17 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ module.exports = function GruntConfig(grunt) {
}
},

check_copyright: {
options: {
// Task-specific options go here.
copyrights: [/EdgeVerve Systems Limited \(a fully owned Infosys subsidiary\).*Bangalore, India.*All Rights Reserved.*/],
lines: 10
},
files: {
// Target-specific file lists and/or options go here.
src: ['**/*.js', '**/*.html', '!node_modules/**', '!bower_components/**', '!client/bower_components/**', '!coverage/**']
}
},

mochaTest: {
test: {
options: {
Expand All @@ -71,7 +83,7 @@ module.exports = function GruntConfig(grunt) {
clearRequireCache: true,
timeout: 100000
},
src: ['test/audit-field-mixin-test.js', 'test/auto-fields-test.js', 'test/basic-api-test.js', 'test/basic-test.js', 'test/batch-job-test.js', 'test/bootstrap.js', 'test/business-rule-mixin-test.js', 'test/caching-test.js', 'test/composite-model-test.js', 'test/concurrency-test.js', 'test/config-merge-test.js', 'test/cr-model-test.js', 'test/crypto-test.js', 'test/data-acl-test.js', 'test/data-hierarchy-test.js', 'test/data-personalization-test.js', 'test/datasource-personalization.js', 'test/decision-table-test.js', 'test/delete-test.js', 'test/designer-boot-test.js', 'test/embedded-many-test.js', 'test/enum-test.js', 'test/failsafe-observer-test.js', 'test/fail-test.js', 'test/gridconfig-test.js', 'test/gridmetadata-test.js', 'test/health-test.js', 'test/history-mixin-test.js', 'test/idempotent-behavior-test.js', 'test/idempotent-mixin-test.js', 'test/import-export-test.js', 'test/integration-test.js', 'test/job-scheduler-test.js', 'test/literal-test.js', 'test/misclaneous-test.js', 'test/model-collection-test.js', 'test/model-definition-ACL-test.js', 'test/model-definition-inheritance-test.js', 'test/model-definition-relation-test.js', 'test/model-definition-test.js', 'test/model-definition-test2.js', 'test/model-definition-validation-test.js', 'test/model-personalization-test.js', 'test/model-transaction-test.js', 'test/model-validation-composite-uniqueness-test.js', 'test/model-validation-embeddedModel-test.js', 'test/model-validation-evValidation-custom-test.js', 'test/model-validation-evValidation-test.js', 'test/model-validation-relation-test.js', 'test/model-validation-test.js', 'test/model-validation-validateWhen.js', 'test/model-validation-xmodelvalidate-test.js', 'test/model-variant-of-test.js', 'test/multi-tenancy-test.js', 'test/node-red-test.js', 'test/otp-mixin-test.js', 'test/property-expressions-test.js', 'test/relation-has-one-test.js', 'test/service-personalization-relation-test.js', 'test/service-personalization-test.js', 'test/soft-delete-mixin-test.js', 'test/switch-data-source-test.js', 'test/uicomponent-test.js', 'test/uimetadata-test.js', 'test/unauthorised-write.js', 'test/update-data-acl-test.js', 'test/version-mixin-test.js', 'test/z-jwt-assertion-test.js', 'test/z-remove-demo-user-test.js', 'test/z-z-ap-state-test.js', 'test/z-z-business-validations-tests.js', 'test/z-z-rest-api-actors-mixin-tests.js', 'test/z-z-z-actor-pattern-activity-check-test.js', 'test/z-z-z-actor-pattern-test.js', 'test/z-z-z-actor-pattern-db-lock-test.js', 'test/z-z-journal-retry-tests.js', 'test/z-z-z-actor-startup-test.js', 'test/z-z-z-logger-config-test.js', 'test/z-z-z-z-mark-as-cache-able-test.js', 'test/instance-caching-test.js']
src: ['test/audit-field-mixin-test.js', 'test/auto-fields-test.js', 'test/basic-api-test.js', 'test/basic-test.js', 'test/batch-job-test.js', 'test/bootstrap.js', 'test/business-rule-mixin-test.js', 'test/caching-test.js', 'test/composite-model-test.js', 'test/concurrency-test.js', 'test/config-merge-test.js', 'test/cr-model-test.js', 'test/crypto-test.js', 'test/data-acl-test.js', 'test/data-hierarchy-test.js', 'test/data-personalization-test.js', 'test/datasource-personalization.js', 'test/decision-table-test.js', 'test/delete-test.js', 'test/designer-boot-test.js', 'test/embedded-many-test.js', 'test/enum-test.js', 'test/failsafe-observer-test.js', 'test/fail-test.js', 'test/gridconfig-test.js', 'test/gridmetadata-test.js', 'test/health-test.js', 'test/history-mixin-test.js', 'test/idempotent-behavior-test.js', 'test/idempotent-mixin-test.js', 'test/import-export-test.js', 'test/integration-test.js', 'test/job-scheduler-test.js', 'test/literal-test.js', 'test/misclaneous-test.js', 'test/model-collection-test.js', 'test/model-definition-ACL-test.js', 'test/model-definition-inheritance-test.js', 'test/model-definition-relation-test.js', 'test/model-definition-test.js', 'test/model-definition-test2.js', 'test/model-definition-validation-test.js', 'test/model-personalization-test.js', 'test/model-transaction-test.js', 'test/model-validation-composite-uniqueness-test.js', 'test/model-validation-embeddedModel-test.js', 'test/model-validation-evValidation-custom-test.js', 'test/model-validation-evValidation-test.js', 'test/model-validation-relation-test.js', 'test/model-validation-test.js', 'test/model-validation-validateWhen.js', 'test/model-validation-xmodelvalidate-test.js', 'test/model-variant-of-test.js', 'test/multi-tenancy-test.js', 'test/node-red-test.js', 'test/property-expressions-test.js', 'test/relation-has-one-test.js', 'test/service-personalization-relation-test.js', 'test/service-personalization-test.js', 'test/soft-delete-mixin-test.js', 'test/switch-data-source-test.js', 'test/uicomponent-test.js', 'test/uimetadata-test.js', 'test/unauthorised-write.js', 'test/update-data-acl-test.js', 'test/version-mixin-test.js', 'test/z-jwt-assertion-test.js', 'test/z-remove-demo-user-test.js', 'test/z-z-ap-state-test.js', 'test/z-z-business-validations-tests.js', 'test/z-z-rest-api-actors-mixin-tests.js', 'test/z-z-z-actor-pattern-activity-check-test.js', 'test/z-z-z-actor-pattern-test.js', 'test/z-z-z-actor-pattern-db-lock-test.js', 'test/z-z-journal-retry-tests.js', 'test/z-z-z-actor-startup-test.js', 'test/z-z-z-logger-config-test.js', 'test/z-z-z-z-mark-as-cache-able-test.js', 'test/instance-caching-test.js']
},
oracle: {
options: {
Expand Down Expand Up @@ -99,10 +111,10 @@ module.exports = function GruntConfig(grunt) {
excludes: ['lib/expression-language/expression-syntax-parser.js', 'lib/ev-tenant-util.js', 'common/models/framework/cache-manager.js', 'lib/common/broadcaster-client.js', 'server/boot/uws-boot.js', 'lib/uws-client.js', 'lib/proxy-context.js', 'common/models/framework/base-user-identity.js'],
timeout: 60000,
check: {
lines: 78,
statements: 78,
lines: 75,
statements: 75,
branches: 65,
functions: 84
functions: 75
},
reportFormats: ['lcov']
}
Expand All @@ -117,6 +129,7 @@ module.exports = function GruntConfig(grunt) {

grunt.loadNpmTasks('grunt-mkdir');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-check-copyright');
grunt.loadNpmTasks('grunt-banner');

grunt.registerTask('test-with-coverage', ['clean:coverage', 'mocha_istanbul']);
Expand Down
14 changes: 7 additions & 7 deletions common/mixins/expression-ast-populator-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ module.exports = function ExpressionAstPopulator(Model) {
}
});

var otpEnabledMethods = Model.definition.settings.enableOTP || [];
otpEnabledMethods.forEach(function otpMethodIterate(otpConfig) {
var expression = otpConfig.authWhen;
if (expression) {
Model._ast[expression] = exprLang.createAST(expression);
}
});
// var otpEnabledMethods = Model.definition.settings.enableOTP || [];
// otpEnabledMethods.forEach(function otpMethodIterate(otpConfig) {
// var expression = otpConfig.authWhen;
// if (expression) {
// Model._ast[expression] = exprLang.createAST(expression);
// }
// });
};
48 changes: 47 additions & 1 deletion common/mixins/model-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ The EdgeVerve proprietary software program ("Program"), is protected by copyrigh
The Program may contain/reference third party or open source components, the rights to which continue to remain with the applicable third party licensors or the open source community as the case may be and nothing here transfers the rights to the third party and open source components, except as expressly permitted.
Any unauthorized reproduction, storage, transmission in any form or by any means (including without limitation to electronic, mechanical, printing, photocopying, recording or otherwise), or any distribution of this Program, or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under the law.
*/
/* eslint-disable no-eval */
/**
* This mixin is for validations, where we override the isValid function of loopback.
* All the validations defined on the model will be aggregated and attached to the model,
Expand All @@ -22,7 +23,25 @@ var exprLang = require('../../lib/expression-language/expression-language.js');
var getError = require('../../lib/common/error-utils').attachValidationError;
var loopback = require('loopback');
var util = require('../../lib/common/util.js');
// design-break this is experimental, may break functionality of expression validation
function isSimpleValidation(expression) {
var regex = new RegExp('(@m)|( where )|(if[ ]{0,1}\\()|(while[ ]{0,1}\\()|(switch[ ]{0,1}\\()|(void )|(delete )|(typeof )|(alert[ ]{0,1}\\()|(eval[ ]{0,1}\\()');
return !regex.test(expression);
}

// design-break this is experimental, may break functionality of expression validation
function generateSimpleValidation(expression) {
var regex = new RegExp('@i.', 'g');
return expression.replace(regex, 'data.');
}

// design-break this is experimental, may break functionality of expression validation
function evalSimpleValidation(value, data) {
// this eval value is validated with possible validation expression and it returns a boolean value which is not inserted in DB
var res = eval(value);
if (typeof (res) === typeof (true) ) {return res;}
return false;
}
module.exports = function ModelValidations(Model) {
if (Model.modelName === 'BaseEntity') {
// No need to apply the "isValid" change at BaseEntity level
Expand Down Expand Up @@ -94,7 +113,34 @@ module.exports = function ModelValidations(Model) {
// construct an array of promises for validateWhen and wait for expression language to resolve all the promises
inst.constructor.validationRules.forEach(function modelValidationsRulesForEachFn(obj) {
if (obj.args.validateWhen) {
validateWhenPromises.push(exprLang.traverseAST(ast[obj.args.validateWhen], data, options));
// design-break this is experimental implementation, may break functionality of expression validation
// check self.constructor._simpleValidation[obj.args.validateWhen] true
// if true, eval(inst.constructor._simpleValidation[obj.args.validateWhen]);
// check if simple expression true,
// if true, replace "@i.property" with "data.property"
// eval the result and self.constructor._simpleValidation[obj.args.validateWhen] = result
if (self.constructor._simpleValidation && self.constructor._simpleValidation[obj.args.validateWhen]) {
// console.log('already there -----', obj.args.validateWhen)
validateWhenPromises.push((function validateWhenPromisesCb() {
return q.fcall(function fCallCb() {
return evalSimpleValidation(self.constructor._simpleValidation[obj.args.validateWhen], data);
});
})());
} else if (isSimpleValidation(obj.args.validateWhen)) {
// console.log('simple -----', obj.args.validateWhen)
var res = generateSimpleValidation(obj.args.validateWhen);
self.constructor._simpleValidation = {};
self.constructor._simpleValidation[obj.args.validateWhen] = res;
validateWhenPromises.push((function validateWhenPromisesCb() {
return q.fcall(function fCallCb() {
return evalSimpleValidation(res, data);
});
})());
} else {
// not a simple validation need to traverse the AST
// console.log('not simple *****', obj.args.validateWhen)
validateWhenPromises.push(exprLang.traverseAST(ast[obj.args.validateWhen], data, options));
}
} else {
validateWhenPromises.push((function validateWhenPromisesCb() {
return q.fcall(function fCallCb() {
Expand Down
7 changes: 6 additions & 1 deletion common/mixins/read-only-mixin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

/**
*
* ©2017-2018 EdgeVerve Systems Limited (a fully owned Infosys subsidiary),
* Bangalore, India. All Rights Reserved.
*
*/
var logger = require('oe-logger');
var log = logger('read-only-mixin');

Expand Down
3 changes: 0 additions & 3 deletions common/models/dirlist.txt

This file was deleted.

2 changes: 2 additions & 0 deletions common/models/framework/auth-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,7 @@ function getFromCookie(r, p) {
}
});
return result ? result.substring(4, 68) : null;
} else if (r.cookies && r.cookies[p]) {
return r.cookies[p];
}
}
25 changes: 0 additions & 25 deletions common/models/framework/author.json

This file was deleted.

Loading

0 comments on commit c8132b8

Please sign in to comment.