@@ -41,7 +41,9 @@ suite('Factories.PackageUrlFactory', () => {
41
41
''
42
42
)
43
43
const expected = undefined
44
+
44
45
const actual = sut . makeFromComponent ( component )
46
+
45
47
assert . strictEqual ( actual , expected )
46
48
} )
47
49
@@ -58,7 +60,9 @@ suite('Factories.PackageUrlFactory', () => {
58
60
}
59
61
)
60
62
const expected = new PackageURL ( 'testing' , `@group-${ salt } ` , `name-${ salt } ` , `v1+${ salt } ` , { } , undefined )
63
+
61
64
const actual = sut . makeFromComponent ( component )
65
+
62
66
assert . deepStrictEqual ( actual , expected )
63
67
} )
64
68
@@ -68,12 +72,14 @@ suite('Factories.PackageUrlFactory', () => {
68
72
`name-${ salt } ` ,
69
73
{
70
74
externalReferences : new Models . ExternalReferenceRepository ( [
71
- new Models . ExternalReference ( 'git://foo.bar' , Enums . ExternalReferenceType . VCS )
75
+ new Models . ExternalReference ( 'git+https ://foo.bar/repo.git ' , Enums . ExternalReferenceType . VCS )
72
76
] )
73
77
}
74
78
)
75
- const expected = new PackageURL ( 'testing' , undefined , `name-${ salt } ` , undefined , { vcs_url : 'git://foo.bar' } , undefined )
79
+ const expected = new PackageURL ( 'testing' , undefined , `name-${ salt } ` , undefined , { vcs_url : 'git+https://foo.bar/repo.git' } , undefined )
80
+
76
81
const actual = sut . makeFromComponent ( component )
82
+
77
83
assert . deepStrictEqual ( actual , expected )
78
84
} )
79
85
@@ -83,27 +89,80 @@ suite('Factories.PackageUrlFactory', () => {
83
89
`name-${ salt } ` ,
84
90
{
85
91
externalReferences : new Models . ExternalReferenceRepository ( [
86
- new Models . ExternalReference ( 'git://foo.bar#sub/path' , Enums . ExternalReferenceType . VCS )
92
+ new Models . ExternalReference ( 'git+https ://foo.bar/repo.git #sub/path' , Enums . ExternalReferenceType . VCS )
87
93
] )
88
94
}
89
95
)
90
- const expected = new PackageURL ( 'testing' , undefined , `name-${ salt } ` , undefined , { vcs_url : 'git://foo.bar' } , 'sub/path' )
96
+ const expected = new PackageURL ( 'testing' , undefined , `name-${ salt } ` , undefined , { vcs_url : 'git+https://foo.bar/repo.git' } , 'sub/path' )
97
+
91
98
const actual = sut . makeFromComponent ( component )
99
+
92
100
assert . deepStrictEqual ( actual , expected )
93
101
} )
94
102
95
103
test ( 'extRef[distribution] -> qualifiers.download_url' , ( ) => {
96
- assert . strictEqual ( false , true , 'TODO' )
104
+ const component = new Models . Component (
105
+ Enums . ComponentType . Library ,
106
+ `name-${ salt } ` ,
107
+ {
108
+ externalReferences : new Models . ExternalReferenceRepository ( [
109
+ new Models . ExternalReference ( 'https://foo.bar/download' , Enums . ExternalReferenceType . Distribution )
110
+ ] )
111
+ }
112
+ )
113
+ const expected = new PackageURL ( 'testing' , undefined , `name-${ salt } ` , undefined , { download_url : 'https://foo.bar/download' } , undefined )
114
+
115
+ const actual = sut . makeFromComponent ( component )
116
+
117
+ assert . deepStrictEqual ( actual , expected )
97
118
} )
98
119
99
120
test ( 'hashes -> qualifiers.checksum' , ( ) => {
100
- assert . strictEqual ( false , true , 'TODO' )
121
+ const component = new Models . Component (
122
+ Enums . ComponentType . Library ,
123
+ `name-${ salt } ` ,
124
+ {
125
+ hashes : new Models . HashRepository ( [
126
+ [ Enums . HashAlgorithm [ 'SHA-256' ] , 'C3AB8FF13720E8AD9047DD39466B3C8974E592C2FA383D4A3960714CAEF0C4F2' ]
127
+ ] )
128
+ }
129
+ )
130
+ const expected = new PackageURL ( 'testing' , undefined , `name-${ salt } ` , undefined , { checksum : 'sha-256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2' } , undefined )
131
+
132
+ const actual = sut . makeFromComponent ( component )
133
+
134
+ assert . deepStrictEqual ( actual , expected )
101
135
} )
102
136
103
137
test ( 'sorted' , ( ) => {
104
- assert . strictEqual ( false , true , 'TODO' )
138
+ const component = new Models . Component (
139
+ Enums . ComponentType . Library ,
140
+ `name-${ salt } ` ,
141
+ {
142
+ externalReferences : new Models . ExternalReferenceRepository ( [
143
+ new Models . ExternalReference ( 'git+https://foo.bar/repo.git' , Enums . ExternalReferenceType . VCS ) ,
144
+ new Models . ExternalReference ( 'https://foo.bar/download' , Enums . ExternalReferenceType . Distribution )
145
+ ] ) ,
146
+ hashes : new Models . HashRepository ( [
147
+ [ Enums . HashAlgorithm [ 'SHA-256' ] , 'C3AB8FF13720E8AD9047DD39466B3C8974E592C2FA383D4A3960714CAEF0C4F2' ] ,
148
+ [ Enums . HashAlgorithm . BLAKE3 , 'aa51dcd43d5c6c5203ee16906fd6b35db298b9b2e1de3fce81811d4806b76b7d' ]
149
+ ] )
150
+ }
151
+ )
152
+ const expectedObject = new PackageURL ( 'testing' , undefined , 'name' , undefined ,
153
+ {
154
+ // expect sorted hash list
155
+ checksum : 'blake3:aa51dcd43d5c6c5203ee16906fd6b35db298b9b2e1de3fce81811d4806b76b7d,sha-256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2' ,
156
+ download_url : 'https://foo.bar/download' ,
157
+ vcs_url : 'git+https://foo.bar/repo.git'
158
+ } , undefined )
159
+ // expect objet's keys in alphabetical oder, expect sorted hash list
160
+ const expectedString = 'pkg:testing/name?checksum=blake3:aa51dcd43d5c6c5203ee16906fd6b35db298b9b2e1de3fce81811d4806b76b7d,sha-256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2&download_url=https://foo.bar/download&vcs_url=git+https://foo.bar/repo.git'
161
+
162
+ const actual = sut . makeFromComponent ( component , true )
163
+
164
+ assert . deepStrictEqual ( actual , expectedObject )
165
+ assert . deepStrictEqual ( actual . toString ( ) , expectedString )
105
166
} )
106
167
} )
107
-
108
-
109
168
} )
0 commit comments