@@ -28,7 +28,7 @@ describe('Validator: Integrity', () => {
2828
2929 it ( 'validator should fail if not allowed hash type is used for a resource' , ( ) => {
3030 const mockedPackages = {
31- bolt11 : {
31+ ' bolt11@1.4.1-3e38a8b13f29678e59705efec18f590e50272676' : {
3232 integrity : 'sha1-1ZNEUixLxGSmWnMKxpUAf9tm3Yg='
3333 }
3434 }
@@ -39,20 +39,20 @@ describe('Validator: Integrity', () => {
3939 errors : [
4040 {
4141 message :
42- 'detected invalid integrity hash type for package: bolt11\n expected: sha512\n actual: sha1-1ZNEUixLxGSmWnMKxpUAf9tm3Yg=\n' ,
43- package : 'bolt11'
42+ 'detected invalid integrity hash type for package: bolt11@1.4.1-3e38a8b13f29678e59705efec18f590e50272676 \n expected: sha512\n actual: sha1-1ZNEUixLxGSmWnMKxpUAf9tm3Yg=\n' ,
43+ package : 'bolt11@1.4.1-3e38a8b13f29678e59705efec18f590e50272676 '
4444 }
4545 ]
4646 } )
4747 } )
4848
4949 it ( 'validator should succeed if all resources are from an allowed hash type' , ( ) => {
5050 const mockedPackages = {
51- '@types/node' : {
51+ '@types/node@20.11.17-14733ac8d7ad65e47f20fc8c2b20bd58ef37c9f5 ' : {
5252 integrity :
5353 'sha512-CK2fnrQlIgKlCV3N2kM+Gznb5USlwA1KFX3rJVHmgVk6NJxFPuQ86pAcvKnu37IA4BGlSRz7sEE1lHL1aLZ/eQ=='
5454 } ,
55- typescript : {
55+ ' typescript@5.0.0-d5998c40b92db6ac7b06359242cf43afc8b499f4' : {
5656 integrity :
5757 'sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig=='
5858 }
@@ -67,11 +67,11 @@ describe('Validator: Integrity', () => {
6767
6868 it ( 'validator should not fail even if one of the packages has no `integrity` field' , ( ) => {
6969 const mockedPackages = {
70- typescript : {
70+ ' typescript@5.0.0-d5998c40b92db6ac7b06359242cf43afc8b499f4' : {
7171 integrity :
7272 'sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig=='
7373 } ,
74- meow : { }
74+ ' meow@13.0.0-0478ab49a1d0b9808d0ea088db43c980a15dfc4b' : { }
7575 }
7676 const validator = new ValidateIntegrity ( { packages : mockedPackages } )
7777
@@ -83,7 +83,7 @@ describe('Validator: Integrity', () => {
8383
8484 it ( 'validator should not fail if an excluded package has an invalid integrity hash type' , ( ) => {
8585 const mockedPackages = {
86- typescript : {
86+ ' typescript@5.0.0-d5998c40b92db6ac7b06359242cf43afc8b499f4' : {
8787 integrity : 'sha1-1ZNEUixLxGSmWnMKxpUAf9tm3Yg='
8888 }
8989 }
@@ -98,6 +98,29 @@ describe('Validator: Integrity', () => {
9898 } )
9999 } )
100100
101+ it ( 'validator should not match excluded package by partial name' , ( ) => {
102+ const mockedPackages = {
103+ 'common-prefix-package@1.0.0-30f09ab54e1d572758bd0673b8b96b5df96ec1fa' : {
104+ integrity : 'sha1-1ZNEUixLxGSmWnMKxpUAf9tm3Yg='
105+ }
106+ }
107+ const options = {
108+ integrityExclude : [ 'common-prefix' ]
109+ }
110+
111+ const validator = new ValidateIntegrity ( { packages : mockedPackages } )
112+ expect ( validator . validate ( options ) ) . toEqual ( {
113+ type : 'error' ,
114+ errors : [
115+ {
116+ message :
117+ 'detected invalid integrity hash type for package: common-prefix-package@1.0.0-30f09ab54e1d572758bd0673b8b96b5df96ec1fa\n expected: sha512\n actual: sha1-1ZNEUixLxGSmWnMKxpUAf9tm3Yg=\n' ,
118+ package : 'common-prefix-package@1.0.0-30f09ab54e1d572758bd0673b8b96b5df96ec1fa'
119+ }
120+ ]
121+ } )
122+ } )
123+
101124 it ( 'validator should return true for a single package with a valid URL' , ( ) => {
102125 const mockedPackages = {
103126 typescript : {
0 commit comments