@contrail/flexplm 1.7.1-alpha.e5225c7 → 1.7.1
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.
|
@@ -183,9 +183,12 @@ class BaseEntityProcessor {
|
|
|
183
183
|
return undefined;
|
|
184
184
|
}
|
|
185
185
|
const entityReference = identityEntity.entityReference;
|
|
186
|
+
if (typeof entityReference !== 'string' || !entityReference.includes(':')) {
|
|
187
|
+
throw new Error(`Invalid identity entityReference: ${String(entityReference)}`);
|
|
188
|
+
}
|
|
186
189
|
const firstColonIndex = entityReference.indexOf(':');
|
|
187
|
-
if (firstColonIndex ===
|
|
188
|
-
throw new Error('Invalid entityReference: ' + entityReference);
|
|
190
|
+
if (firstColonIndex === 0 || firstColonIndex === entityReference.length - 1) {
|
|
191
|
+
throw new Error('Invalid identity entityReference: ' + entityReference);
|
|
189
192
|
}
|
|
190
193
|
const entityName = entityReference.slice(0, firstColonIndex);
|
|
191
194
|
const id = entityReference.slice(firstColonIndex + 1);
|
|
@@ -623,7 +623,25 @@ describe('BaseEntityProcessor', () => {
|
|
|
623
623
|
poolKey: 'item',
|
|
624
624
|
propertyName: 'itemNumber',
|
|
625
625
|
propertyValue: '12345'
|
|
626
|
-
})).rejects.toThrow('Invalid entityReference: item1');
|
|
626
|
+
})).rejects.toThrow('Invalid identity entityReference: item1');
|
|
627
|
+
expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
|
|
628
|
+
});
|
|
629
|
+
it('should throw error when entityReference is not a string', async () => {
|
|
630
|
+
mockEntitiesGet.mockResolvedValue([{ entityReference: 12345 }]);
|
|
631
|
+
await expect(btep.getEntityUsingIdentityService({
|
|
632
|
+
poolKey: 'item',
|
|
633
|
+
propertyName: 'itemNumber',
|
|
634
|
+
propertyValue: '12345'
|
|
635
|
+
})).rejects.toThrow('Invalid identity entityReference: 12345');
|
|
636
|
+
expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
|
|
637
|
+
});
|
|
638
|
+
it('should throw error when entityReference is undefined', async () => {
|
|
639
|
+
mockEntitiesGet.mockResolvedValue([{}]);
|
|
640
|
+
await expect(btep.getEntityUsingIdentityService({
|
|
641
|
+
poolKey: 'item',
|
|
642
|
+
propertyName: 'itemNumber',
|
|
643
|
+
propertyValue: '12345'
|
|
644
|
+
})).rejects.toThrow('Invalid identity entityReference: undefined');
|
|
627
645
|
expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
|
|
628
646
|
});
|
|
629
647
|
it('should throw error when entityReference starts with a colon (missing entityName)', async () => {
|
|
@@ -632,7 +650,7 @@ describe('BaseEntityProcessor', () => {
|
|
|
632
650
|
poolKey: 'item',
|
|
633
651
|
propertyName: 'itemNumber',
|
|
634
652
|
propertyValue: '12345'
|
|
635
|
-
})).rejects.toThrow('Invalid entityReference: :1');
|
|
653
|
+
})).rejects.toThrow('Invalid identity entityReference: :1');
|
|
636
654
|
expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
|
|
637
655
|
});
|
|
638
656
|
it('should throw error when entityReference ends with a colon (missing id)', async () => {
|
|
@@ -641,7 +659,7 @@ describe('BaseEntityProcessor', () => {
|
|
|
641
659
|
poolKey: 'item',
|
|
642
660
|
propertyName: 'itemNumber',
|
|
643
661
|
propertyValue: '12345'
|
|
644
|
-
})).rejects.toThrow('Invalid entityReference: item:');
|
|
662
|
+
})).rejects.toThrow('Invalid identity entityReference: item:');
|
|
645
663
|
expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
|
|
646
664
|
});
|
|
647
665
|
});
|