scimgateway 4.2.13 → 4.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1170,6 +1170,12 @@ MIT © [Jarle Elshaug](https://www.elshaug.xyz)
1170
1170
 
1171
1171
  ## Change log
1172
1172
 
1173
+ ### v4.2.14
1174
+
1175
+ [Fixed]
1176
+
1177
+ - PUT now returning 404 instead of 500 when trying to update a user/group that does not exist
1178
+
1173
1179
  ### v4.2.13
1174
1180
 
1175
1181
  [Fixed]
@@ -1370,11 +1370,21 @@ const ScimGateway = function () {
1370
1370
  logger.debug(`${gwName}[${pluginName}] calling "${handle.getMethod}" and awaiting result`)
1371
1371
  let res = await this[handle.getMethod](ctx.params.baseEntity, { attribute: 'id', operator: 'eq', value: id }, [], ctx.ctxCopy)
1372
1372
 
1373
- let currentObj = {}
1374
- if (res && res.Resources && Array.isArray(res.Resources) && res.Resources.length === 1) currentObj = res.Resources[0]
1375
- else if (Array.isArray(res) && res.length === 1) currentObj = res[0]
1373
+ let currentObj
1374
+ if (res && res.Resources && Array.isArray(res.Resources)) {
1375
+ if (res.Resources.length === 1) currentObj = res.Resources[0]
1376
+ else currentObj = {}
1377
+ } else if (Array.isArray(res) && res.length === 1) currentObj = res[0]
1376
1378
  else if (res && typeof (res) === 'object' && Object.keys(res).length > 0) currentObj = res
1377
- else throw Error(`put using method ${handle.getMethod} got unexpected response: ${JSON.stringify(res)}`)
1379
+ else currentObj = {}
1380
+
1381
+ if (typeof (currentObj) !== 'object' || Object.keys(currentObj).length === 0) {
1382
+ ctx.status = 404
1383
+ let err = new Error(`put using method ${handle.getMethod} error: ${handle.description.toLowerCase()} id=${id} does not exist`)
1384
+ err = jsonErr(config.scim.version, pluginName, ctx.status, err)
1385
+ ctx.body = err
1386
+ return
1387
+ }
1378
1388
 
1379
1389
  const clearedObj = clearObjectValues(currentObj)
1380
1390
  delete clearedObj.active
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scimgateway",
3
- "version": "4.2.13",
3
+ "version": "4.2.14",
4
4
  "description": "Using SCIM protocol as a gateway for user provisioning to other endpoints",
5
5
  "author": "Jarle Elshaug <jarle.elshaug@gmail.com> (https://elshaug.xyz)",
6
6
  "homepage": "https://elshaug.xyz",