@@ -30,68 +30,66 @@ const {
30
30
}
31
31
} = require ( '../../' )
32
32
33
- suite ( 'unit: Utils.NpmjsUtility' , ( ) => {
34
- suite ( 'defaultRegistryMatcher' , ( ) => {
35
- test ( 'matches pure domain' , ( ) => {
36
- const actual = NpmjsUtility . defaultRegistryMatcher . test ( 'https://registry.npmjs.org' )
37
- assert . strictEqual ( actual , true )
38
- } )
39
- test ( 'matches with path' , ( ) => {
40
- const actual = NpmjsUtility . defaultRegistryMatcher . test ( 'https://registry.npmjs.org/foo/bar' )
41
- assert . strictEqual ( actual , true )
42
- } )
43
- suite ( 'not match unexpected' , ( ) => {
44
- for ( const c of [
45
- 'https://my-own=registry.local' ,
46
- 'https://registry.npmjs.org.uk' ,
47
- 'https://registry.npmjs.org.uk/foo/bar'
48
- ] ) {
49
- test ( c , ( ) => {
50
- const actual = NpmjsUtility . defaultRegistryMatcher . test ( c )
51
- assert . strictEqual ( actual , false )
52
- } )
53
- }
54
- } )
33
+ suite ( 'unit: Utils.NpmjsUtility.defaultRegistryMatcher' , ( ) => {
34
+ test ( 'matches pure domain' , ( ) => {
35
+ const actual = NpmjsUtility . defaultRegistryMatcher . test ( 'https://registry.npmjs.org' )
36
+ assert . strictEqual ( actual , true )
37
+ } )
38
+ test ( 'matches with path' , ( ) => {
39
+ const actual = NpmjsUtility . defaultRegistryMatcher . test ( 'https://registry.npmjs.org/foo/bar' )
40
+ assert . strictEqual ( actual , true )
41
+ } )
42
+ suite ( 'not match unexpected' , ( ) => {
43
+ for ( const c of [
44
+ 'https://my-own=registry.local' ,
45
+ 'https://registry.npmjs.org.uk' ,
46
+ 'https://registry.npmjs.org.uk/foo/bar'
47
+ ] ) {
48
+ test ( c , ( ) => {
49
+ const actual = NpmjsUtility . defaultRegistryMatcher . test ( c )
50
+ assert . strictEqual ( actual , false )
51
+ } )
52
+ }
55
53
} )
54
+ } )
56
55
57
- suite ( 'parsePackageIntegrity' , ( ) => {
58
- suite ( 'as expected' , ( ) => {
59
- for ( const [ c , ...expected ] of [
60
- [ 'sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==' ,
61
- HashAlgorithm [ 'SHA-512' ] ,
62
- 'cef8fae53905788b778ba6a3e5b22f243ce38d0406b38a3fb0da1ece0d45d6461aa7d36eda3714769c334522531cc3331b41fb6d9927e2b350a489a1bb1597d8'
63
- ] ,
64
- [ 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0=' ,
65
- HashAlgorithm [ 'SHA-1' ] ,
66
- '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
67
- ] ,
68
- [ 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' ,
69
- HashAlgorithm [ 'SHA-256' ] ,
70
- 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
71
- ] ,
72
- [ 'sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC' ,
73
- HashAlgorithm [ 'SHA-384' ] ,
74
- 'a2a56e01f5d129aa7b7dd81c098e6eca433af91f46a90f0afeec72f6bc7b1cd42519897590fcd0868d70c7827063cc02'
75
- ] ,
76
- ] ) {
77
- test ( c , ( ) => {
78
- const actual = NpmjsUtility . parsePackageIntegrity ( c )
79
- assert . deepStrictEqual ( actual , expected )
80
- } )
81
- }
82
- } )
83
- suite ( 'fails' , ( ) => {
84
- for ( const c of [
85
- 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0' , // missing character
86
- 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0==' , // additional character
87
- 'sha512-Kq5sNclPz7QV2+lfQIuc6R7oRu0=' , // alg and hash dont match
88
- ] ) {
89
- test ( c , ( ) => {
90
- assert . throws ( ( ) => {
91
- NpmjsUtility . parsePackageIntegrity ( c )
92
- } )
56
+ suite ( 'unit: Utils.NpmjsUtility.parsePackageIntegrity' , ( ) => {
57
+ suite ( 'as expected' , ( ) => {
58
+ for ( const [ c , ...expected ] of [
59
+ [ 'sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==' ,
60
+ HashAlgorithm [ 'SHA-512' ] ,
61
+ 'cef8fae53905788b778ba6a3e5b22f243ce38d0406b38a3fb0da1ece0d45d6461aa7d36eda3714769c334522531cc3331b41fb6d9927e2b350a489a1bb1597d8'
62
+ ] ,
63
+ [ 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0=' ,
64
+ HashAlgorithm [ 'SHA-1' ] ,
65
+ '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
66
+ ] ,
67
+ [ 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' ,
68
+ HashAlgorithm [ 'SHA-256' ] ,
69
+ 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
70
+ ] ,
71
+ [ 'sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC' ,
72
+ HashAlgorithm [ 'SHA-384' ] ,
73
+ 'a2a56e01f5d129aa7b7dd81c098e6eca433af91f46a90f0afeec72f6bc7b1cd42519897590fcd0868d70c7827063cc02'
74
+ ] ,
75
+ ] ) {
76
+ test ( c , ( ) => {
77
+ const actual = NpmjsUtility . parsePackageIntegrity ( c )
78
+ assert . deepStrictEqual ( actual , expected )
79
+ } )
80
+ }
81
+ } )
82
+ suite ( 'fails' , ( ) => {
83
+ for ( const c of [
84
+ 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0' , // missing character
85
+ 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0==' , // additional character
86
+ 'sha512-Kq5sNclPz7QV2+lfQIuc6R7oRu0=' , // alg and hash dont match
87
+ ] ) {
88
+ test ( c , ( ) => {
89
+ assert . throws ( ( ) => {
90
+ NpmjsUtility . parsePackageIntegrity ( c )
93
91
} )
94
- }
95
- } )
92
+ } )
93
+ }
96
94
} )
97
95
} )
0 commit comments