@contrail/flexplm 1.7.1-alpha.a7e0d3c → 1.7.1-alpha.e5225c7

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.
@@ -184,6 +184,9 @@ class BaseEntityProcessor {
184
184
  }
185
185
  const entityReference = identityEntity.entityReference;
186
186
  const firstColonIndex = entityReference.indexOf(':');
187
+ if (firstColonIndex === -1 || firstColonIndex === 0 || firstColonIndex === entityReference.length - 1) {
188
+ throw new Error('Invalid entityReference: ' + entityReference);
189
+ }
187
190
  const entityName = entityReference.slice(0, firstColonIndex);
188
191
  const id = entityReference.slice(firstColonIndex + 1);
189
192
  const entity = await this.entities.get({
@@ -617,5 +617,32 @@ describe('BaseEntityProcessor', () => {
617
617
  id: 'e5g8ugusNWOuCvdw:nju12Jw2jGFvcQSf'
618
618
  });
619
619
  });
620
+ it('should throw error when entityReference has no colon', async () => {
621
+ mockEntitiesGet.mockResolvedValue([{ entityReference: 'item1' }]);
622
+ await expect(btep.getEntityUsingIdentityService({
623
+ poolKey: 'item',
624
+ propertyName: 'itemNumber',
625
+ propertyValue: '12345'
626
+ })).rejects.toThrow('Invalid entityReference: item1');
627
+ expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
628
+ });
629
+ it('should throw error when entityReference starts with a colon (missing entityName)', async () => {
630
+ mockEntitiesGet.mockResolvedValue([{ entityReference: ':1' }]);
631
+ await expect(btep.getEntityUsingIdentityService({
632
+ poolKey: 'item',
633
+ propertyName: 'itemNumber',
634
+ propertyValue: '12345'
635
+ })).rejects.toThrow('Invalid entityReference: :1');
636
+ expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
637
+ });
638
+ it('should throw error when entityReference ends with a colon (missing id)', async () => {
639
+ mockEntitiesGet.mockResolvedValue([{ entityReference: 'item:' }]);
640
+ await expect(btep.getEntityUsingIdentityService({
641
+ poolKey: 'item',
642
+ propertyName: 'itemNumber',
643
+ propertyValue: '12345'
644
+ })).rejects.toThrow('Invalid entityReference: item:');
645
+ expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
646
+ });
620
647
  });
621
648
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.7.1-alpha.a7e0d3c",
3
+ "version": "1.7.1-alpha.e5225c7",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",