Skip to content

Commit

Permalink
commit for version 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vamsee committed Apr 30, 2020
2 parents ae52102 + 7f55791 commit 3a375fc
Show file tree
Hide file tree
Showing 18 changed files with 363 additions and 346 deletions.
13 changes: 6 additions & 7 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/client/
/coverage/
/node_modules/
server/dropdb.js
/lib/expression-language/expression-syntax-parser.js
/test/
build/
client/
coverage/
node_modules/
test/
drop.js

Gruntfile.js
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"no-undefined": 1, // http://eslint.org/docs/rules/no-undefined
"no-with": 2, // http://eslint.org/docs/rules/no-with
"handle-callback-err": 1, // http://eslint.org/docs/rules/handle-callback-err
"radix": 2, // http://eslint.org/docs/rules/radix
"radix": 0, // http://eslint.org/docs/rules/radix
"wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife
"yoda": 2, // http://eslint.org/docs/rules/yoda

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ out/
*.zip
/common/models/test
package-lock.json
oracle-user.sh
7 changes: 2 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = function GruntConfig(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

clean: {
coverage: {
src: ['coverage/']
Expand Down Expand Up @@ -39,12 +40,8 @@ module.exports = function GruntConfig(grunt) {
});

// Add the grunt-mocha-test tasks.
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-mocha-istanbul');
grunt.loadNpmTasks('grunt-contrib-clean');

grunt.loadNpmTasks('grunt-mkdir');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-mocha-istanbul');

grunt.registerTask('test-with-coverage', ['clean:coverage', 'mocha_istanbul']);
};
17 changes: 6 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oe-common-mixins",
"version": "2.1.1",
"version": "2.2.0",
"description": "oe-cloud modularization project aka oecloud.io",
"engines": {
"node": ">=6"
Expand All @@ -20,26 +20,21 @@
"devDependencies": {
"babel-eslint": "7.2.3",
"chai": "3.4.1",
"chai-datetime": "1.4.0",
"chai-things": "0.2.0",
"chalk": "1.1.1",
"eslint": "4.10.0",
"grunt": "1.0.4",
"grunt-banner": "0.6.0",
"grunt-cli": "1.3.2",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-copy": "1.0.0",
"grunt-jsbeautifier": "0.2.13",
"grunt-mkdir": "1.0.0",
"grunt-mocha-istanbul": "5.0.2",
"grunt-mocha-test": "0.13.3",
"istanbul": "0.4.5",
"mocha": "5.2.0",
"superagent-defaults": "0.1.14",
"supertest": "3.4.2",
"loopback-connector-mongodb": "3.9.2",
"oe-cloud": "^2.0.0",
"oe-connector-postgresql": "^2.0.0"
"oe-connector-mongodb": "^2.0.0",
"oe-connector-oracle": "^2.0.0",
"oe-connector-postgresql": "^2.0.0",
"superagent-defaults": "0.1.14",
"supertest": "3.4.2"
},
"repository": {
"type": "git",
Expand Down
72 changes: 33 additions & 39 deletions test/audit-field-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var url = basePath + '/Employees';
var models = oecloud.models;

function deleteAllUsers(done) {
var userModel = loopback.findModel("User");
var userModel = loopback.findModel('User');
userModel.destroyAll({}, {}, function (err) {
if (err) {
return done(err);
Expand All @@ -38,7 +38,7 @@ function deleteAllUsers(done) {
return done(err2);
}
if (r2 && r2.length > 0) {
return done(new Error("Error : users were not deleted"));
return done(new Error('Error : users were not deleted'));
}
});
return done(err);
Expand All @@ -52,7 +52,7 @@ var globalCtx = {
describe(chalk.blue('Audit Field Mixin Test Started'), function (done) {
this.timeout(15000);
before('wait for boot scripts to complete', function (done) {
Customer = loopback.findModel("Customer");
Customer = loopback.findModel('Customer');
deleteAllUsers(function () {
return done();
});
Expand All @@ -65,44 +65,42 @@ describe(chalk.blue('Audit Field Mixin Test Started'), function (done) {
it('t1-0 create user admin/admin with /default tenant', function (done) {
var url = basePath + '/users';
api.set('Accept', 'application/json')
.post(url)
.send([{ username: "admin", password: "admin", email: "[email protected]" },
{ username: "evuser", password: "evuser", email: "[email protected]" },
{ username: "infyuser", password: "infyuser", email: "[email protected]" },
{ username: "bpouser", password: "bpouser", email: "[email protected]" }
])
.end(function (err, response) {

var result = response.body;
expect(result[0].id).to.be.defined;
expect(result[1].id).to.be.defined;
expect(result[2].id).to.be.defined;
expect(result[3].id).to.be.defined;
done();
});
.post(url)
.send([{ username: 'admin', password: 'admin', email: '[email protected]' },
{ username: 'evuser', password: 'evuser', email: '[email protected]' },
{ username: 'infyuser', password: 'infyuser', email: '[email protected]' },
{ username: 'bpouser', password: 'bpouser', email: '[email protected]' }
])
.end(function (err, response) {
var result = response.body;
expect(result[0].id).to.be.defined;
expect(result[1].id).to.be.defined;
expect(result[2].id).to.be.defined;
expect(result[3].id).to.be.defined;
done();
});
});

var adminToken;
it('t2 Login with admin credentials', function (done) {
var url = basePath + '/users/login';
api.set('Accept', 'application/json')
.post(url)
.send({ username: "admin", password: "admin" })
.end(function (err, response) {
var result = response.body;
adminToken = result.id;
expect(adminToken).to.be.defined;
done();
});
.post(url)
.send({ username: 'admin', password: 'admin' })
.end(function (err, response) {
var result = response.body;
adminToken = result.id;
expect(adminToken).to.be.defined;
done();
});
});

it('t3-1 clean up Customer models', function (done) {
Customer.settings.mixins.SoftDeleteMixin = false;
Customer.destroyAll({}, { notify: false }, function (err, results) {
Customer.settings.mixins.SoftDeleteMixin = true;
console.log(results);
if (err)
return done(err);
if (err) {return done(err);}
var CustomerAddress = loopback.getModel('CustomerAddress', globalCtx);
CustomerAddress.destroyAll({}, { notify: false}, function (err) {
return done(err);
Expand All @@ -111,14 +109,14 @@ describe(chalk.blue('Audit Field Mixin Test Started'), function (done) {
});

it('t3-2 create records in Customer models', function (done) {
Customer.create([{name: "Smith", age: 30, id: 1 }, {name: "Atul", age: 30, id: 2 }, {name: "John", age: 30, id: 3 }], globalCtx, function (err, r) {
Customer.create([{name: 'Smith', age: 30, id: 1 }, {name: 'Atul', age: 30, id: 2 }, {name: 'John', age: 30, id: 3 }], globalCtx, function (err, r) {
if (err) {
return done(err);
}
expect(r.length).to.be.equal(3);
expect(r[0]._createdBy).to.be.equal("system");
expect(r[0]._modifiedBy).to.be.equal("system");
expect(r[0]._type).to.be.equal("Customer");
expect(r[0]._createdBy).to.be.equal('system');
expect(r[0]._modifiedBy).to.be.equal('system');
expect(r[0]._type).to.be.equal('Customer');
return done();
});
});
Expand All @@ -128,19 +126,15 @@ describe(chalk.blue('Audit Field Mixin Test Started'), function (done) {
var url = basePath + '/customers?access_token=' + adminToken;
api.set('Accept', 'application/json')
.post(url)
.send({name : "Atul" , age : 30})
.send({name: 'Atul', age: 30})
.end(function (err, response) {
var result = response.body;
expect(response.status).to.be.equal(200);
expect(result._createdBy).to.be.equal("admin");
expect(result._modifiedBy).to.be.equal("admin");
expect(result._createdBy).to.be.equal('admin');
expect(result._modifiedBy).to.be.equal('admin');
done();
});

});
});





17 changes: 8 additions & 9 deletions test/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ var oecloud = require('oe-cloud');
var loopback = require('loopback');

oecloud.observe('loaded', function (ctx, next) {
oecloud.attachMixinsToBaseEntity("VersionMixin");
oecloud.attachMixinsToBaseEntity("AuditFieldsMixin");
oecloud.attachMixinsToBaseEntity("HistoryMixin");
oecloud.attachMixinsToBaseEntity("SoftDeleteMixin");
oecloud.attachMixinsToBaseEntity("CryptoMixin");
oecloud.attachMixinsToBaseEntity('VersionMixin');
oecloud.attachMixinsToBaseEntity('AuditFieldsMixin');
oecloud.attachMixinsToBaseEntity('HistoryMixin');
oecloud.attachMixinsToBaseEntity('SoftDeleteMixin');
oecloud.attachMixinsToBaseEntity('CryptoMixin');


return next();
})
});


oecloud.boot(__dirname, function (err) {
Expand All @@ -40,4 +40,3 @@ describe('Common Mixins Test Started', function () {
});



128 changes: 64 additions & 64 deletions test/common/models/Migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,77 +6,77 @@
*/

module.exports = function MigrationFunction(Migration) {
Migration.getzip = function (exportAllTables, tableList, cb) {
};
Migration.getzip = function (exportAllTables, tableList, cb) {
};


// var methods = methods || [];
// Migration.sharedClass.methods().forEach(function (method) {
// method.shared = methods.indexOf(method.name) > -1;
// });

// var methods = methods || [];
// Migration.sharedClass.methods().forEach(function (method) {
// method.shared = methods.indexOf(method.name) > -1;
// });

Migration.disableRemoteMethodByName('create');
Migration.disableRemoteMethodByName('upsert');
Migration.disableRemoteMethodByName('updateAll');
Migration.disableRemoteMethodByName('prototype.updateAttributes');

Migration.disableRemoteMethodByName('find');
Migration.disableRemoteMethodByName('findById');
Migration.disableRemoteMethodByName('findOne');
Migration.disableRemoteMethodByName('create');
Migration.disableRemoteMethodByName('upsert');
Migration.disableRemoteMethodByName('updateAll');
Migration.disableRemoteMethodByName('prototype.updateAttributes');

Migration.disableRemoteMethodByName('deleteById');
Migration.disableRemoteMethodByName('find');
Migration.disableRemoteMethodByName('findById');
Migration.disableRemoteMethodByName('findOne');

Migration.disableRemoteMethodByName('confirm');
Migration.disableRemoteMethodByName('count');
Migration.disableRemoteMethodByName('exists');
Migration.disableRemoteMethodByName('resetPassword');
Migration.disableRemoteMethodByName('deleteById');

Migration.disableRemoteMethodByName('prototype.__count__accessTokens');
Migration.disableRemoteMethodByName('prototype.__create__accessTokens');
Migration.disableRemoteMethodByName('prototype.__delete__accessTokens');
Migration.disableRemoteMethodByName('prototype.__destroyById__accessTokens');
Migration.disableRemoteMethodByName('prototype.__findById__accessTokens');
Migration.disableRemoteMethodByName('prototype.__get__accessTokens');
Migration.disableRemoteMethodByName('prototype.__updateById__accessTokens');

Migration.remoteMethod('getzip', {
description: 'Gets a zip file of the exported data',
accessType: 'READ',
accepts: [{
arg: 'exportAllTables',
type: 'string'
},
{
arg: 'tableList',
type: 'string'
}
],
http: {
verb: 'GET',
path: '/getzip'
},
returns: [{
arg: 'body',
type: 'file',
root: true
},
{
arg: 'Content-Type',
type: 'string',
http: {
target: 'header'
}
},
{
arg: 'Content-Disposition',
type: 'string',
http: {
target: 'header'
}
}
]
Migration.disableRemoteMethodByName('confirm');
Migration.disableRemoteMethodByName('count');
Migration.disableRemoteMethodByName('exists');
Migration.disableRemoteMethodByName('resetPassword');

});
Migration.disableRemoteMethodByName('prototype.__count__accessTokens');
Migration.disableRemoteMethodByName('prototype.__create__accessTokens');
Migration.disableRemoteMethodByName('prototype.__delete__accessTokens');
Migration.disableRemoteMethodByName('prototype.__destroyById__accessTokens');
Migration.disableRemoteMethodByName('prototype.__findById__accessTokens');
Migration.disableRemoteMethodByName('prototype.__get__accessTokens');
Migration.disableRemoteMethodByName('prototype.__updateById__accessTokens');

Migration.remoteMethod('getzip', {
description: 'Gets a zip file of the exported data',
accessType: 'READ',
accepts: [{
arg: 'exportAllTables',
type: 'string'
},
{
arg: 'tableList',
type: 'string'
}
],
http: {
verb: 'GET',
path: '/getzip'
},
returns: [{
arg: 'body',
type: 'file',
root: true
},
{
arg: 'Content-Type',
type: 'string',
http: {
target: 'header'
}
},
{
arg: 'Content-Disposition',
type: 'string',
http: {
target: 'header'
}
}
]

});
};

Loading

0 comments on commit 3a375fc

Please sign in to comment.