Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add versioning components #1385

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
cc49002
Added new endpoints for virtual components
Jan 21, 2022
a93cb55
Fixed get load virtual component
Jan 24, 2022
b53d214
Added patch and get by id in virtual components
Jan 24, 2022
68f390a
added the action trigger and config endpoints
changreta Jan 24, 2022
735e3f1
Merge branch 'feat/add-versioning-components' of github.com:CloudEcos…
changreta Jan 24, 2022
a99d6d2
corrected the component config endpoints
changreta Jan 24, 2022
181b607
corrected the trigger naming
changreta Jan 24, 2022
210994a
semi colons
changreta Jan 24, 2022
69a8e51
removed double get virt comp
changreta Jan 24, 2022
6642ad5
Added default query
Jan 25, 2022
17500d3
working getAction and trigger endpoint
changreta Jan 25, 2022
b07c0af
Merge branch 'feat/add-versioning-components' of github.com:CloudEcos…
changreta Jan 25, 2022
1331e25
update config
changreta Jan 25, 2022
c57e3f6
removed false config and console.logs
changreta Jan 25, 2022
f271be5
implemented the changes from the comments
changreta Jan 26, 2022
cabe2a3
changed the Component config
changreta Jan 26, 2022
4e0b6c2
corrected the model
changreta Jan 26, 2022
95c3c7c
corrected the model
changreta Jan 26, 2022
0d20a15
added the index to the config
changreta Jan 26, 2022
03b0368
configs endpoint
changreta Jan 27, 2022
fb477b2
Added test for gets endpoints and create virtual component
Jan 27, 2022
9a39966
changes of the last comments
changreta Jan 28, 2022
d45c197
added the validation and the corrections
changreta Jan 28, 2022
9293bbe
added permissions and corrected the patch
changreta Jan 28, 2022
a268719
added the updated at in config patch
changreta Jan 28, 2022
a6abba2
Added tests to get virtual component by id
Jan 28, 2022
b69f99d
corrected the action trigger file wrong exceptions
changreta Jan 28, 2022
62c1c30
Merge branch 'feat/add-versioning-components' into falseConfig
IoannisLafiotis Jan 28, 2022
a160afe
Merge pull request #56 from CloudEcosystemDev/falseConfig
IoannisLafiotis Jan 28, 2022
c6282dc
Added tests for patch virtual component
Jan 31, 2022
01610cc
Merge branch 'feat/add-versioning-components' of github.com:CloudEcos…
Jan 31, 2022
c17fe24
Added tests to create new component versions
Jan 31, 2022
0c2778d
Added update component version
Jan 31, 2022
3a42368
added tests for functions
changreta Feb 1, 2022
c2c7350
Merge branch 'feat/add-versioning-components' of github.com:CloudEcos…
changreta Feb 1, 2022
2006dd0
fixed the componennt config error
changreta Feb 1, 2022
cb24ad8
patch 200 response
changreta Feb 1, 2022
0d90746
Added package lock json witht faker
Feb 1, 2022
2392563
Merge branch 'feat/add-versioning-components' of github.com:CloudEcos…
Feb 1, 2022
b700a2f
Added tests for delete and update virtual component
Feb 1, 2022
48ccf59
added the delete version
changreta Feb 2, 2022
5102fa7
Merge branch 'feat/add-versioning-components' of github.com:CloudEcos…
changreta Feb 2, 2022
38baabc
Code review with last improvements
Feb 2, 2022
4dbbc0b
Added componentVersion and apiVersion to the version schema
Feb 3, 2022
25a0eb0
Added write pemission in virtual components endpoint
Feb 8, 2022
cff7d5e
Fixed component create permission
Feb 8, 2022
b02d7c1
Replaced faker and use express json parser
Feb 14, 2022
9dd6252
Merge remote-tracking branch 'upstream/master' into feat/add-versioni…
Feb 14, 2022
9f0118d
Run npm install
Feb 14, 2022
3ba7b1c
Fixed permissions for component repository
Feb 15, 2022
0ea182d
Removed ce scripts
Feb 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/component-repository/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"node": ">=12"
},
"scripts": {
"lint": "eslint index.js src spec",
"lint": "eslint ./src/**/*.js",
"pretest": "npm run lint",
"test": "mocha spec --recursive"
"test": "mocha spec --recursive"
},
"dependencies": {
"@openintegrationhub/iam-utils": "*",
Expand All @@ -23,6 +23,7 @@
"swagger-ui-express": "4.0.2"
},
"devDependencies": {
"@faker-js/faker": "^6.0.0-alpha.6",
"bunyan": "1.8.14",
"chai": "4.3.4",
"eslint": "7.32.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { can, hasOneOf } = require('@openintegrationhub/iam-utils');
const tokens = require('./tokens');

const userWithComponents = {
sub: '61f13960e88b288fd905c8ab',
tenant: '61f13992a4a0ad3c113c7c65',
permissions: [],
};

const iam = {
middleware(req, _, next) {
const tokenName = req.headers.authorization;
if (!tokens[tokenName]) {
throw new Error('User not valid');
}
req.user = tokens[tokenName].value;
return next();
},
can,
hasOneOf,
};

module.exports = {
iam,
userWithComponents,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const VirtualComponent = require('../../../../../src/models/VirtualComponent');
const Component = require('../../../../../src/models/Component');
const ComponentVersion = require('../../../../../src/models/ComponentVersion');
const ComponentConfig = require('../../../../../src/models/ComponentConfig');

const {
component1,
component2,
component3,
inactiveComponent,
componentNotDefault,
virtualComponent1,
virtualComponent2,
virtualComponent3,
inactiveVirtualComponent,
componentVersion1,
componentVersion2,
componentVersion3,
inactiveComponentVersion,
componentVersionNotDefaultVersion,
componentConfig1,
componentConfig2,
componentConfig3,
componentΝοConfig,
componentVersionNoConfig,
virtualComponentNoConfig,
} = require('./virtualComponentsData');

const insertDatainDb = async () => {
await VirtualComponent.insertMany([
virtualComponent1,
virtualComponent2,
virtualComponent3,
inactiveVirtualComponent,
virtualComponentNoConfig,
]);
await Component.insertMany([
component1,
component2,
component3,
componentNotDefault,
inactiveComponent,
componentΝοConfig,
]);
await ComponentVersion.insertMany([
componentVersion1,
componentVersion2,
componentVersion3,
inactiveComponentVersion,
componentVersionNotDefaultVersion,
componentVersionNoConfig,
]);
await ComponentConfig.insertMany([
componentConfig1,
componentConfig2,
componentConfig3,
]);
};

const deleteAllData = async () => {
await VirtualComponent.deleteMany({});
await Component.deleteMany({});
await ComponentVersion.deleteMany({});
await ComponentConfig.deleteMany({});
};

module.exports = {
insertDatainDb,
deleteAllData,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const logger = {
info: () => {},
debug: () => {},
warn: () => {},
error: () => {},
trace: () => {},
};

module.exports = {
logger,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const config = require('../../../../../src/config');

const tenantId = '60f922418ced69c612df63ff';
const tenantWithoutComponents = '60f922418ced69c612df63fg';

module.exports = {
tenantId,
adminToken: {
token: 'adminToken',
value: {
sub: 'TestAdmin',
username: 'admin@example.com',
role: 'ADMIN',
permissions: ['all'],
iat: 1337,
isAdmin: true,
},
},

permitToken: {
token: 'permitToken',
value: {
sub: 'PermitGuy',
username: 'admin@example.com',
permissions: [
config.componentsCreatePermission,
config.componentsUpdatePermission,
config.componentDeletePermission,
config.componentWritePermission,
],
tenant: tenantId,
iat: 1337,
},
},

unpermitToken: {
token: 'unpermitToken',
value: {
sub: 'UnpermitGuy',
username: 'guest@example.com',
tenant: tenantId,
permissions: ['müsli.riegel', 'schoko.riegel'],
iat: 1337,
},
},

partpermitToken: {
token: 'partpermitToken',
value: {
sub: 'PartpermitGuy',
username: 'guest@example.com',
tenant: tenantId,
permissions: [
config.componentsCreatePermission,
config.componentsUpdatePermission,
],
iat: 1337,
},
},

otherTenantToken: {
token: 'otherTenantToken',
value: {
sub: 'OtherTenantToken',
username: 'guest@example.com',
tenant: tenantWithoutComponents,
permissions: [
config.componentsCreatePermission,
config.componentsUpdatePermission,
],
iat: 1337,
},
},
};