feat: [IDS-7232] Rule template update#439
Conversation
| user.permissions = mergeRecords(user.permissions, data.permissions);<% } %> | ||
|
|
||
| <% if (config.persistGroups || config.persistRoles || config.persistPermissions) { %> | ||
| await saveToMetadata(user, data.groups, data.roles, data.permissions); |
There was a problem hiding this comment.
In the previous version, if saveToAppMetadata fails, it was returning return callback(err, user, context);. Now it returns just callback(new UnauthorizedError('Authorization Extension: ' + err.message));. Is that done intentionally?
There was a problem hiding this comment.
@nkavtur yes - the second two arguments are ignored when the first is an error
async function (user, context, callback) {
try {
throw new Error("Fake test error in rule");
return callback(null, user, context);
} catch (err) {
return callback(err, user, context);
}
}
in fact any non-null first argument results in a 403
async function (user, context, callback) {
return callback("a non-null value");
}
The new version does result in Unauthorized (401) rather than Forbidden (403) but I think this is better because it's consistent with other errors returned by the rule
async function (user, context, callback) {
try {
throw new Error("Fake test error in rule");
return callback(null, user, context);
} catch (err) {
return callback(new UnauthorizedError('Authorization Extension: ' + err.message));
}
}
Looking in tenants logs, it also seems to include the connection, which the other errors did not, which is also an advantage. Looking in the log details, the bodies looked similar
✏️ Changes
Built rule
🔗 References
🎯 Testing
Functional tests
/extensions/developLocal Unit Tests
run all unit tests locally
npm run testrun rules unit tests locally
npx mocha tests/unit/mocha.js 'tests/unit/server/lib/rules/authorize.tests.js'now to prove that the tests demonstrate that the rule has not changed functionally, run the tests against the old version of the rule
authorize.jswith the original version from master hereauthorize.test.js, comment back in// if (mod === 'lodash') return _;✅ This change has been tested in a Webtask
✅ This change has unit test coverage
🚫 This change has integration test coverage
🚫 This change has been tested for performance
🚀 Deployment
✅ This can be deployed any time
🎡 Rollout
In order to verify that the deployment was successful we will test in a prod tenant
🔥 Rollback
If there are issues with this change, we will revert the PR and deploy a new version of the extension