Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 1 | // Copyright 2021 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package compliance |
| 16 | |
| 17 | import ( |
| 18 | "bytes" |
| 19 | "testing" |
| 20 | ) |
| 21 | |
| 22 | func TestWalkResolutionsForCondition(t *testing.T) { |
| 23 | tests := []struct { |
| 24 | name string |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 25 | condition LicenseConditionSet |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 26 | roots []string |
| 27 | edges []annotated |
| 28 | expectedResolutions []res |
| 29 | }{ |
| 30 | { |
| 31 | name: "firstparty", |
| 32 | condition: ImpliesNotice, |
| 33 | roots: []string{"apacheBin.meta_lic"}, |
| 34 | edges: []annotated{ |
| 35 | {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 36 | }, |
| 37 | expectedResolutions: []res{ |
| 38 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 39 | {"apacheBin.meta_lic", "apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 40 | }, |
| 41 | }, |
| 42 | { |
| 43 | name: "notice", |
| 44 | condition: ImpliesNotice, |
| 45 | roots: []string{"mitBin.meta_lic"}, |
| 46 | edges: []annotated{ |
| 47 | {"mitBin.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 48 | }, |
| 49 | expectedResolutions: []res{ |
| 50 | {"mitBin.meta_lic", "mitBin.meta_lic", "mitBin.meta_lic", "notice"}, |
| 51 | {"mitBin.meta_lic", "mitLib.meta_lic", "mitLib.meta_lic", "notice"}, |
| 52 | }, |
| 53 | }, |
| 54 | { |
| 55 | name: "fponlgplnotice", |
| 56 | condition: ImpliesNotice, |
| 57 | roots: []string{"apacheBin.meta_lic"}, |
| 58 | edges: []annotated{ |
| 59 | {"apacheBin.meta_lic", "lgplLib.meta_lic", []string{"static"}}, |
| 60 | }, |
| 61 | expectedResolutions: []res{ |
| 62 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 63 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "lgplLib.meta_lic", "restricted"}, |
| 64 | {"apacheBin.meta_lic", "lgplLib.meta_lic", "lgplLib.meta_lic", "restricted"}, |
| 65 | }, |
| 66 | }, |
| 67 | { |
| 68 | name: "fponlgpldynamicnotice", |
| 69 | condition: ImpliesNotice, |
| 70 | roots: []string{"apacheBin.meta_lic"}, |
| 71 | edges: []annotated{ |
| 72 | {"apacheBin.meta_lic", "lgplLib.meta_lic", []string{"dynamic"}}, |
| 73 | }, |
| 74 | expectedResolutions: []res{ |
| 75 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 76 | }, |
| 77 | }, |
| 78 | { |
| 79 | name: "independentmodulenotice", |
| 80 | condition: ImpliesNotice, |
| 81 | roots: []string{"apacheBin.meta_lic"}, |
| 82 | edges: []annotated{ |
| 83 | {"apacheBin.meta_lic", "gplWithClasspathException.meta_lic", []string{"dynamic"}}, |
| 84 | }, |
| 85 | expectedResolutions: []res{ |
| 86 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 87 | }, |
| 88 | }, |
| 89 | { |
| 90 | name: "independentmodulerestricted", |
| 91 | condition: ImpliesRestricted, |
| 92 | roots: []string{"apacheBin.meta_lic"}, |
| 93 | edges: []annotated{ |
| 94 | {"apacheBin.meta_lic", "gplWithClasspathException.meta_lic", []string{"dynamic"}}, |
| 95 | }, |
| 96 | expectedResolutions: []res{}, |
| 97 | }, |
| 98 | { |
| 99 | name: "independentmodulestaticnotice", |
| 100 | condition: ImpliesNotice, |
| 101 | roots: []string{"apacheBin.meta_lic"}, |
| 102 | edges: []annotated{ |
| 103 | {"apacheBin.meta_lic", "gplWithClasspathException.meta_lic", []string{"static"}}, |
| 104 | }, |
| 105 | expectedResolutions: []res{ |
| 106 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 107 | {"apacheBin.meta_lic", "gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "permissive"}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 108 | }, |
| 109 | }, |
| 110 | { |
| 111 | name: "independentmodulestaticrestricted", |
| 112 | condition: ImpliesRestricted, |
| 113 | roots: []string{"apacheBin.meta_lic"}, |
| 114 | edges: []annotated{ |
| 115 | {"apacheBin.meta_lic", "gplWithClasspathException.meta_lic", []string{"static"}}, |
| 116 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 117 | expectedResolutions: []res{}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 118 | }, |
| 119 | { |
| 120 | name: "dependentmodulenotice", |
| 121 | condition: ImpliesNotice, |
| 122 | roots: []string{"dependentModule.meta_lic"}, |
| 123 | edges: []annotated{ |
| 124 | {"dependentModule.meta_lic", "gplWithClasspathException.meta_lic", []string{"dynamic"}}, |
| 125 | }, |
| 126 | expectedResolutions: []res{ |
| 127 | {"dependentModule.meta_lic", "dependentModule.meta_lic", "dependentModule.meta_lic", "notice"}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 128 | }, |
| 129 | }, |
| 130 | { |
| 131 | name: "dependentmodulerestricted", |
| 132 | condition: ImpliesRestricted, |
| 133 | roots: []string{"dependentModule.meta_lic"}, |
| 134 | edges: []annotated{ |
| 135 | {"dependentModule.meta_lic", "gplWithClasspathException.meta_lic", []string{"dynamic"}}, |
| 136 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 137 | expectedResolutions: []res{}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 138 | }, |
| 139 | { |
| 140 | name: "lgplonfpnotice", |
| 141 | condition: ImpliesNotice, |
| 142 | roots: []string{"lgplBin.meta_lic"}, |
| 143 | edges: []annotated{ |
| 144 | {"lgplBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 145 | }, |
| 146 | expectedResolutions: []res{ |
| 147 | {"lgplBin.meta_lic", "lgplBin.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 148 | {"lgplBin.meta_lic", "apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 149 | {"lgplBin.meta_lic", "apacheLib.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 150 | }, |
| 151 | }, |
| 152 | { |
| 153 | name: "lgplonfprestricted", |
| 154 | condition: ImpliesRestricted, |
| 155 | roots: []string{"lgplBin.meta_lic"}, |
| 156 | edges: []annotated{ |
| 157 | {"lgplBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 158 | }, |
| 159 | expectedResolutions: []res{ |
| 160 | {"lgplBin.meta_lic", "lgplBin.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 161 | {"lgplBin.meta_lic", "apacheLib.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 162 | }, |
| 163 | }, |
| 164 | { |
| 165 | name: "lgplonfpdynamicnotice", |
| 166 | condition: ImpliesNotice, |
| 167 | roots: []string{"lgplBin.meta_lic"}, |
| 168 | edges: []annotated{ |
| 169 | {"lgplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 170 | }, |
| 171 | expectedResolutions: []res{ |
| 172 | {"lgplBin.meta_lic", "lgplBin.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 173 | }, |
| 174 | }, |
| 175 | { |
| 176 | name: "lgplonfpdynamicrestricted", |
| 177 | condition: ImpliesRestricted, |
| 178 | roots: []string{"lgplBin.meta_lic"}, |
| 179 | edges: []annotated{ |
| 180 | {"lgplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 181 | }, |
| 182 | expectedResolutions: []res{ |
| 183 | {"lgplBin.meta_lic", "lgplBin.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 184 | }, |
| 185 | }, |
| 186 | { |
| 187 | name: "gplonfpnotice", |
| 188 | condition: ImpliesNotice, |
| 189 | roots: []string{"gplBin.meta_lic"}, |
| 190 | edges: []annotated{ |
| 191 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 192 | }, |
| 193 | expectedResolutions: []res{ |
| 194 | {"gplBin.meta_lic", "gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 195 | {"gplBin.meta_lic", "apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 196 | {"gplBin.meta_lic", "apacheLib.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 197 | }, |
| 198 | }, |
| 199 | { |
| 200 | name: "gplonfprestricted", |
| 201 | condition: ImpliesRestricted, |
| 202 | roots: []string{"gplBin.meta_lic"}, |
| 203 | edges: []annotated{ |
| 204 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 205 | }, |
| 206 | expectedResolutions: []res{ |
| 207 | {"gplBin.meta_lic", "gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 208 | {"gplBin.meta_lic", "apacheLib.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 209 | }, |
| 210 | }, |
| 211 | { |
| 212 | name: "gplcontainernotice", |
| 213 | condition: ImpliesNotice, |
| 214 | roots: []string{"gplContainer.meta_lic"}, |
| 215 | edges: []annotated{ |
| 216 | {"gplContainer.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 217 | }, |
| 218 | expectedResolutions: []res{ |
| 219 | {"gplContainer.meta_lic", "gplContainer.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 220 | {"gplContainer.meta_lic", "apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 221 | {"gplContainer.meta_lic", "apacheLib.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 222 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 223 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 224 | }, |
| 225 | }, |
| 226 | { |
| 227 | name: "gplcontainerrestricted", |
| 228 | condition: ImpliesRestricted, |
| 229 | roots: []string{"gplContainer.meta_lic"}, |
| 230 | edges: []annotated{ |
| 231 | {"gplContainer.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 232 | }, |
| 233 | expectedResolutions: []res{ |
| 234 | {"gplContainer.meta_lic", "gplContainer.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 235 | {"gplContainer.meta_lic", "apacheLib.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 236 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 237 | }, |
| 238 | }, |
| 239 | { |
| 240 | name: "gploncontainernotice", |
| 241 | condition: ImpliesNotice, |
| 242 | roots: []string{"apacheContainer.meta_lic"}, |
| 243 | edges: []annotated{ |
| 244 | {"apacheContainer.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 245 | {"apacheContainer.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 246 | }, |
| 247 | expectedResolutions: []res{ |
| 248 | {"apacheContainer.meta_lic", "apacheContainer.meta_lic", "apacheContainer.meta_lic", "notice"}, |
| 249 | {"apacheContainer.meta_lic", "apacheContainer.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 250 | {"apacheContainer.meta_lic", "apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 251 | {"apacheContainer.meta_lic", "gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 252 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 253 | {"gplLib.meta_lic", "gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 254 | }, |
| 255 | }, |
| 256 | { |
| 257 | name: "gploncontainerrestricted", |
| 258 | condition: ImpliesRestricted, |
| 259 | roots: []string{"apacheContainer.meta_lic"}, |
| 260 | edges: []annotated{ |
| 261 | {"apacheContainer.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 262 | {"apacheContainer.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 263 | }, |
| 264 | expectedResolutions: []res{ |
| 265 | {"apacheContainer.meta_lic", "apacheContainer.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 266 | {"apacheContainer.meta_lic", "gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 267 | {"gplLib.meta_lic", "gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 268 | }, |
| 269 | }, |
| 270 | { |
| 271 | name: "gplonbinnotice", |
| 272 | condition: ImpliesNotice, |
| 273 | roots: []string{"apacheBin.meta_lic"}, |
| 274 | edges: []annotated{ |
| 275 | {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 276 | {"apacheBin.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 277 | }, |
| 278 | expectedResolutions: []res{ |
| 279 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 280 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 281 | {"apacheBin.meta_lic", "apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 282 | {"apacheBin.meta_lic", "apacheLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 283 | {"apacheBin.meta_lic", "gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 284 | }, |
| 285 | }, |
| 286 | { |
| 287 | name: "gplonbinrestricted", |
| 288 | condition: ImpliesRestricted, |
| 289 | roots: []string{"apacheBin.meta_lic"}, |
| 290 | edges: []annotated{ |
| 291 | {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 292 | {"apacheBin.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 293 | }, |
| 294 | expectedResolutions: []res{ |
| 295 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 296 | {"apacheBin.meta_lic", "apacheLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 297 | {"apacheBin.meta_lic", "gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 298 | }, |
| 299 | }, |
| 300 | { |
| 301 | name: "gplonfpdynamicnotice", |
| 302 | condition: ImpliesNotice, |
| 303 | roots: []string{"gplBin.meta_lic"}, |
| 304 | edges: []annotated{ |
| 305 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 306 | }, |
| 307 | expectedResolutions: []res{ |
| 308 | {"gplBin.meta_lic", "gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 309 | }, |
| 310 | }, |
| 311 | { |
| 312 | name: "gplonfpdynamicrestricted", |
| 313 | condition: ImpliesRestricted, |
| 314 | roots: []string{"gplBin.meta_lic"}, |
| 315 | edges: []annotated{ |
| 316 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 317 | }, |
| 318 | expectedResolutions: []res{ |
| 319 | {"gplBin.meta_lic", "gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 320 | }, |
| 321 | }, |
| 322 | { |
| 323 | name: "gplonfpdynamicrestrictedshipped", |
| 324 | condition: ImpliesRestricted, |
| 325 | roots: []string{"gplBin.meta_lic", "apacheLib.meta_lic"}, |
| 326 | edges: []annotated{ |
| 327 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 328 | }, |
| 329 | expectedResolutions: []res{ |
| 330 | {"gplBin.meta_lic", "gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 331 | {"gplBin.meta_lic", "apacheLib.meta_lic", "gplBin.meta_lic", "restricted"}, |
Bob Badour | b285515 | 2021-12-08 12:52:59 -0800 | [diff] [blame] | 332 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "gplBin.meta_lic", "restricted"}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 333 | }, |
| 334 | }, |
| 335 | { |
| 336 | name: "independentmodulereversenotice", |
| 337 | condition: ImpliesNotice, |
| 338 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 339 | edges: []annotated{ |
| 340 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"dynamic"}}, |
| 341 | }, |
| 342 | expectedResolutions: []res{ |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 343 | {"gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "permissive"}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 344 | }, |
| 345 | }, |
| 346 | { |
| 347 | name: "independentmodulereverserestricted", |
| 348 | condition: ImpliesRestricted, |
| 349 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 350 | edges: []annotated{ |
| 351 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"dynamic"}}, |
| 352 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 353 | expectedResolutions: []res{}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 354 | }, |
| 355 | { |
| 356 | name: "independentmodulereverserestrictedshipped", |
| 357 | condition: ImpliesRestricted, |
| 358 | roots: []string{"gplWithClasspathException.meta_lic", "apacheBin.meta_lic"}, |
| 359 | edges: []annotated{ |
| 360 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"dynamic"}}, |
| 361 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 362 | expectedResolutions: []res{}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 363 | }, |
| 364 | { |
| 365 | name: "independentmodulereversestaticnotice", |
| 366 | condition: ImpliesNotice, |
| 367 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 368 | edges: []annotated{ |
| 369 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"static"}}, |
| 370 | }, |
| 371 | expectedResolutions: []res{ |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 372 | {"gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "permissive"}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 373 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 374 | }, |
| 375 | }, |
| 376 | { |
| 377 | name: "independentmodulereversestaticrestricted", |
| 378 | condition: ImpliesRestricted, |
| 379 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 380 | edges: []annotated{ |
| 381 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"static"}}, |
| 382 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 383 | expectedResolutions: []res{}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 384 | }, |
| 385 | { |
| 386 | name: "dependentmodulereversenotice", |
| 387 | condition: ImpliesNotice, |
| 388 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 389 | edges: []annotated{ |
| 390 | {"gplWithClasspathException.meta_lic", "dependentModule.meta_lic", []string{"dynamic"}}, |
| 391 | }, |
| 392 | expectedResolutions: []res{ |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 393 | {"gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "permissive"}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 394 | }, |
| 395 | }, |
| 396 | { |
| 397 | name: "dependentmodulereverserestricted", |
| 398 | condition: ImpliesRestricted, |
| 399 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 400 | edges: []annotated{ |
| 401 | {"gplWithClasspathException.meta_lic", "dependentModule.meta_lic", []string{"dynamic"}}, |
| 402 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 403 | expectedResolutions: []res{}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 404 | }, |
| 405 | { |
| 406 | name: "dependentmodulereverserestrictedshipped", |
| 407 | condition: ImpliesRestricted, |
| 408 | roots: []string{"gplWithClasspathException.meta_lic", "dependentModule.meta_lic"}, |
| 409 | edges: []annotated{ |
| 410 | {"gplWithClasspathException.meta_lic", "dependentModule.meta_lic", []string{"dynamic"}}, |
| 411 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 412 | expectedResolutions: []res{}, |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 413 | }, |
| 414 | { |
| 415 | name: "ponrnotice", |
| 416 | condition: ImpliesNotice, |
| 417 | roots: []string{"proprietary.meta_lic"}, |
| 418 | edges: []annotated{ |
| 419 | {"proprietary.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 420 | }, |
| 421 | expectedResolutions: []res{ |
| 422 | {"proprietary.meta_lic", "proprietary.meta_lic", "proprietary.meta_lic", "proprietary"}, |
| 423 | {"proprietary.meta_lic", "proprietary.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 424 | {"proprietary.meta_lic", "gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 425 | }, |
| 426 | }, |
| 427 | { |
| 428 | name: "ponrrestricted", |
| 429 | condition: ImpliesRestricted, |
| 430 | roots: []string{"proprietary.meta_lic"}, |
| 431 | edges: []annotated{ |
| 432 | {"proprietary.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 433 | }, |
| 434 | expectedResolutions: []res{ |
| 435 | {"proprietary.meta_lic", "gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 436 | {"proprietary.meta_lic", "proprietary.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 437 | }, |
| 438 | }, |
| 439 | { |
| 440 | name: "ponrproprietary", |
| 441 | condition: ImpliesProprietary, |
| 442 | roots: []string{"proprietary.meta_lic"}, |
| 443 | edges: []annotated{ |
| 444 | {"proprietary.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 445 | }, |
| 446 | expectedResolutions: []res{ |
| 447 | {"proprietary.meta_lic", "proprietary.meta_lic", "proprietary.meta_lic", "proprietary"}, |
| 448 | }, |
| 449 | }, |
| 450 | { |
| 451 | name: "ronpnotice", |
| 452 | condition: ImpliesNotice, |
| 453 | roots: []string{"gplBin.meta_lic"}, |
| 454 | edges: []annotated{ |
| 455 | {"gplBin.meta_lic", "proprietary.meta_lic", []string{"static"}}, |
| 456 | }, |
| 457 | expectedResolutions: []res{ |
| 458 | {"gplBin.meta_lic", "gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 459 | {"gplBin.meta_lic", "proprietary.meta_lic", "proprietary.meta_lic", "proprietary"}, |
| 460 | {"gplBin.meta_lic", "proprietary.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 461 | }, |
| 462 | }, |
| 463 | { |
| 464 | name: "ronprestricted", |
| 465 | condition: ImpliesRestricted, |
| 466 | roots: []string{"gplBin.meta_lic"}, |
| 467 | edges: []annotated{ |
| 468 | {"gplBin.meta_lic", "proprietary.meta_lic", []string{"static"}}, |
| 469 | }, |
| 470 | expectedResolutions: []res{ |
| 471 | {"gplBin.meta_lic", "gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 472 | {"gplBin.meta_lic", "proprietary.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 473 | }, |
| 474 | }, |
| 475 | { |
| 476 | name: "ronpproprietary", |
| 477 | condition: ImpliesProprietary, |
| 478 | roots: []string{"gplBin.meta_lic"}, |
| 479 | edges: []annotated{ |
| 480 | {"gplBin.meta_lic", "proprietary.meta_lic", []string{"static"}}, |
| 481 | }, |
| 482 | expectedResolutions: []res{ |
| 483 | {"gplBin.meta_lic", "proprietary.meta_lic", "proprietary.meta_lic", "proprietary"}, |
| 484 | }, |
| 485 | }, |
| 486 | { |
| 487 | name: "noticeonb_e_onotice", |
| 488 | condition: ImpliesNotice, |
| 489 | roots: []string{"mitBin.meta_lic"}, |
| 490 | edges: []annotated{ |
| 491 | {"mitBin.meta_lic", "by_exception.meta_lic", []string{"static"}}, |
| 492 | }, |
| 493 | expectedResolutions: []res{ |
| 494 | {"mitBin.meta_lic", "mitBin.meta_lic", "mitBin.meta_lic", "notice"}, |
| 495 | {"mitBin.meta_lic", "by_exception.meta_lic", "by_exception.meta_lic", "by_exception_only"}, |
| 496 | }, |
| 497 | }, |
| 498 | { |
| 499 | name: "noticeonb_e_orestricted", |
| 500 | condition: ImpliesRestricted, |
| 501 | roots: []string{"mitBin.meta_lic"}, |
| 502 | edges: []annotated{ |
| 503 | {"mitBin.meta_lic", "by_exception.meta_lic", []string{"static"}}, |
| 504 | }, |
| 505 | expectedResolutions: []res{}, |
| 506 | }, |
| 507 | { |
| 508 | name: "noticeonb_e_ob_e_o", |
| 509 | condition: ImpliesByExceptionOnly, |
| 510 | roots: []string{"mitBin.meta_lic"}, |
| 511 | edges: []annotated{ |
| 512 | {"mitBin.meta_lic", "by_exception.meta_lic", []string{"static"}}, |
| 513 | }, |
| 514 | expectedResolutions: []res{ |
| 515 | {"mitBin.meta_lic", "by_exception.meta_lic", "by_exception.meta_lic", "by_exception_only"}, |
| 516 | }, |
| 517 | }, |
| 518 | { |
| 519 | name: "b_e_oonnoticenotice", |
| 520 | condition: ImpliesNotice, |
| 521 | roots: []string{"by_exception.meta_lic"}, |
| 522 | edges: []annotated{ |
| 523 | {"by_exception.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 524 | }, |
| 525 | expectedResolutions: []res{ |
| 526 | {"by_exception.meta_lic", "by_exception.meta_lic", "by_exception.meta_lic", "by_exception_only"}, |
| 527 | {"by_exception.meta_lic", "mitLib.meta_lic", "mitLib.meta_lic", "notice"}, |
| 528 | }, |
| 529 | }, |
| 530 | { |
| 531 | name: "b_e_oonnoticerestricted", |
| 532 | condition: ImpliesRestricted, |
| 533 | roots: []string{"by_exception.meta_lic"}, |
| 534 | edges: []annotated{ |
| 535 | {"by_exception.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 536 | }, |
| 537 | expectedResolutions: []res{}, |
| 538 | }, |
| 539 | { |
| 540 | name: "b_e_oonnoticeb_e_o", |
| 541 | condition: ImpliesByExceptionOnly, |
| 542 | roots: []string{"by_exception.meta_lic"}, |
| 543 | edges: []annotated{ |
| 544 | {"by_exception.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 545 | }, |
| 546 | expectedResolutions: []res{ |
| 547 | {"by_exception.meta_lic", "by_exception.meta_lic", "by_exception.meta_lic", "by_exception_only"}, |
| 548 | }, |
| 549 | }, |
| 550 | { |
| 551 | name: "noticeonrecipnotice", |
| 552 | condition: ImpliesNotice, |
| 553 | roots: []string{"mitBin.meta_lic"}, |
| 554 | edges: []annotated{ |
| 555 | {"mitBin.meta_lic", "mplLib.meta_lic", []string{"static"}}, |
| 556 | }, |
| 557 | expectedResolutions: []res{ |
| 558 | {"mitBin.meta_lic", "mitBin.meta_lic", "mitBin.meta_lic", "notice"}, |
| 559 | {"mitBin.meta_lic", "mplLib.meta_lic", "mplLib.meta_lic", "reciprocal"}, |
| 560 | }, |
| 561 | }, |
| 562 | { |
| 563 | name: "noticeonreciprecip", |
| 564 | condition: ImpliesReciprocal, |
| 565 | roots: []string{"mitBin.meta_lic"}, |
| 566 | edges: []annotated{ |
| 567 | {"mitBin.meta_lic", "mplLib.meta_lic", []string{"static"}}, |
| 568 | }, |
| 569 | expectedResolutions: []res{ |
| 570 | {"mitBin.meta_lic", "mplLib.meta_lic", "mplLib.meta_lic", "reciprocal"}, |
| 571 | }, |
| 572 | }, |
| 573 | { |
| 574 | name: "reciponnoticenotice", |
| 575 | condition: ImpliesNotice, |
| 576 | roots: []string{"mplBin.meta_lic"}, |
| 577 | edges: []annotated{ |
| 578 | {"mplBin.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 579 | }, |
| 580 | expectedResolutions: []res{ |
| 581 | {"mplBin.meta_lic", "mplBin.meta_lic", "mplBin.meta_lic", "reciprocal"}, |
| 582 | {"mplBin.meta_lic", "mitLib.meta_lic", "mitLib.meta_lic", "notice"}, |
| 583 | }, |
| 584 | }, |
| 585 | { |
| 586 | name: "reciponnoticerecip", |
| 587 | condition: ImpliesReciprocal, |
| 588 | roots: []string{"mplBin.meta_lic"}, |
| 589 | edges: []annotated{ |
| 590 | {"mplBin.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 591 | }, |
| 592 | expectedResolutions: []res{ |
| 593 | {"mplBin.meta_lic", "mplBin.meta_lic", "mplBin.meta_lic", "reciprocal"}, |
| 594 | }, |
| 595 | }, |
| 596 | } |
| 597 | for _, tt := range tests { |
| 598 | t.Run(tt.name, func(t *testing.T) { |
| 599 | stderr := &bytes.Buffer{} |
| 600 | lg, err := toGraph(stderr, tt.roots, tt.edges) |
| 601 | if err != nil { |
Colin Cross | 179ec3e | 2022-01-27 15:47:09 -0800 | [diff] [blame] | 602 | t.Errorf("unexpected test data error: got %s, want no error", err) |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 603 | return |
| 604 | } |
| 605 | expectedRs := toResolutionSet(lg, tt.expectedResolutions) |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 606 | ResolveTopDownConditions(lg) |
| 607 | actualRs := WalkResolutionsForCondition(lg, tt.condition) |
| 608 | checkResolves(actualRs, expectedRs, t) |
| 609 | }) |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | func TestWalkActionsForCondition(t *testing.T) { |
| 614 | tests := []struct { |
| 615 | name string |
| 616 | condition LicenseConditionSet |
| 617 | roots []string |
| 618 | edges []annotated |
| 619 | expectedActions []act |
| 620 | }{ |
| 621 | { |
| 622 | name: "firstparty", |
| 623 | condition: ImpliesNotice, |
| 624 | roots: []string{"apacheBin.meta_lic"}, |
| 625 | edges: []annotated{ |
| 626 | {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 627 | }, |
| 628 | expectedActions: []act{ |
| 629 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 630 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 631 | }, |
| 632 | }, |
| 633 | { |
| 634 | name: "notice", |
| 635 | condition: ImpliesNotice, |
| 636 | roots: []string{"mitBin.meta_lic"}, |
| 637 | edges: []annotated{ |
| 638 | {"mitBin.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 639 | }, |
| 640 | expectedActions: []act{ |
| 641 | {"mitBin.meta_lic", "mitBin.meta_lic", "notice"}, |
| 642 | {"mitLib.meta_lic", "mitLib.meta_lic", "notice"}, |
| 643 | }, |
| 644 | }, |
| 645 | { |
| 646 | name: "fponlgplnotice", |
| 647 | condition: ImpliesNotice, |
| 648 | roots: []string{"apacheBin.meta_lic"}, |
| 649 | edges: []annotated{ |
| 650 | {"apacheBin.meta_lic", "lgplLib.meta_lic", []string{"static"}}, |
| 651 | }, |
| 652 | expectedActions: []act{ |
| 653 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 654 | {"apacheBin.meta_lic", "lgplLib.meta_lic", "restricted"}, |
| 655 | {"lgplLib.meta_lic", "lgplLib.meta_lic", "restricted"}, |
| 656 | }, |
| 657 | }, |
| 658 | { |
| 659 | name: "fponlgpldynamicnotice", |
| 660 | condition: ImpliesNotice, |
| 661 | roots: []string{"apacheBin.meta_lic"}, |
| 662 | edges: []annotated{ |
| 663 | {"apacheBin.meta_lic", "lgplLib.meta_lic", []string{"dynamic"}}, |
| 664 | }, |
| 665 | expectedActions: []act{ |
| 666 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 667 | }, |
| 668 | }, |
| 669 | { |
| 670 | name: "independentmodulenotice", |
| 671 | condition: ImpliesNotice, |
| 672 | roots: []string{"apacheBin.meta_lic"}, |
| 673 | edges: []annotated{ |
| 674 | {"apacheBin.meta_lic", "gplWithClasspathException.meta_lic", []string{"dynamic"}}, |
| 675 | }, |
| 676 | expectedActions: []act{ |
| 677 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 678 | }, |
| 679 | }, |
| 680 | { |
| 681 | name: "independentmodulerestricted", |
| 682 | condition: ImpliesRestricted, |
| 683 | roots: []string{"apacheBin.meta_lic"}, |
| 684 | edges: []annotated{ |
| 685 | {"apacheBin.meta_lic", "gplWithClasspathException.meta_lic", []string{"dynamic"}}, |
| 686 | }, |
| 687 | expectedActions: []act{}, |
| 688 | }, |
| 689 | { |
| 690 | name: "independentmodulestaticnotice", |
| 691 | condition: ImpliesNotice, |
| 692 | roots: []string{"apacheBin.meta_lic"}, |
| 693 | edges: []annotated{ |
| 694 | {"apacheBin.meta_lic", "gplWithClasspathException.meta_lic", []string{"static"}}, |
| 695 | }, |
| 696 | expectedActions: []act{ |
| 697 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 698 | {"gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "permissive"}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 699 | }, |
| 700 | }, |
| 701 | { |
| 702 | name: "independentmodulestaticrestricted", |
| 703 | condition: ImpliesRestricted, |
| 704 | roots: []string{"apacheBin.meta_lic"}, |
| 705 | edges: []annotated{ |
| 706 | {"apacheBin.meta_lic", "gplWithClasspathException.meta_lic", []string{"static"}}, |
| 707 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 708 | expectedActions: []act{}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 709 | }, |
| 710 | { |
| 711 | name: "dependentmodulenotice", |
| 712 | condition: ImpliesNotice, |
| 713 | roots: []string{"dependentModule.meta_lic"}, |
| 714 | edges: []annotated{ |
| 715 | {"dependentModule.meta_lic", "gplWithClasspathException.meta_lic", []string{"dynamic"}}, |
| 716 | }, |
| 717 | expectedActions: []act{ |
| 718 | {"dependentModule.meta_lic", "dependentModule.meta_lic", "notice"}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 719 | }, |
| 720 | }, |
| 721 | { |
| 722 | name: "dependentmodulerestricted", |
| 723 | condition: ImpliesRestricted, |
| 724 | roots: []string{"dependentModule.meta_lic"}, |
| 725 | edges: []annotated{ |
| 726 | {"dependentModule.meta_lic", "gplWithClasspathException.meta_lic", []string{"dynamic"}}, |
| 727 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 728 | expectedActions: []act{}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 729 | }, |
| 730 | { |
| 731 | name: "lgplonfpnotice", |
| 732 | condition: ImpliesNotice, |
| 733 | roots: []string{"lgplBin.meta_lic"}, |
| 734 | edges: []annotated{ |
| 735 | {"lgplBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 736 | }, |
| 737 | expectedActions: []act{ |
| 738 | {"lgplBin.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 739 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 740 | {"apacheLib.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 741 | }, |
| 742 | }, |
| 743 | { |
| 744 | name: "lgplonfprestricted", |
| 745 | condition: ImpliesRestricted, |
| 746 | roots: []string{"lgplBin.meta_lic"}, |
| 747 | edges: []annotated{ |
| 748 | {"lgplBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 749 | }, |
| 750 | expectedActions: []act{ |
| 751 | {"lgplBin.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 752 | {"apacheLib.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 753 | }, |
| 754 | }, |
| 755 | { |
| 756 | name: "lgplonfpdynamicnotice", |
| 757 | condition: ImpliesNotice, |
| 758 | roots: []string{"lgplBin.meta_lic"}, |
| 759 | edges: []annotated{ |
| 760 | {"lgplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 761 | }, |
| 762 | expectedActions: []act{ |
| 763 | {"lgplBin.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 764 | }, |
| 765 | }, |
| 766 | { |
| 767 | name: "lgplonfpdynamicrestricted", |
| 768 | condition: ImpliesRestricted, |
| 769 | roots: []string{"lgplBin.meta_lic"}, |
| 770 | edges: []annotated{ |
| 771 | {"lgplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 772 | }, |
| 773 | expectedActions: []act{ |
| 774 | {"lgplBin.meta_lic", "lgplBin.meta_lic", "restricted"}, |
| 775 | }, |
| 776 | }, |
| 777 | { |
| 778 | name: "gplonfpnotice", |
| 779 | condition: ImpliesNotice, |
| 780 | roots: []string{"gplBin.meta_lic"}, |
| 781 | edges: []annotated{ |
| 782 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 783 | }, |
| 784 | expectedActions: []act{ |
| 785 | {"gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 786 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 787 | {"apacheLib.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 788 | }, |
| 789 | }, |
| 790 | { |
| 791 | name: "gplonfprestricted", |
| 792 | condition: ImpliesRestricted, |
| 793 | roots: []string{"gplBin.meta_lic"}, |
| 794 | edges: []annotated{ |
| 795 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 796 | }, |
| 797 | expectedActions: []act{ |
| 798 | {"gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 799 | {"apacheLib.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 800 | }, |
| 801 | }, |
| 802 | { |
| 803 | name: "gplcontainernotice", |
| 804 | condition: ImpliesNotice, |
| 805 | roots: []string{"gplContainer.meta_lic"}, |
| 806 | edges: []annotated{ |
| 807 | {"gplContainer.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 808 | }, |
| 809 | expectedActions: []act{ |
| 810 | {"gplContainer.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 811 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 812 | {"apacheLib.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 813 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 814 | {"apacheLib.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 815 | }, |
| 816 | }, |
| 817 | { |
| 818 | name: "gplcontainerrestricted", |
| 819 | condition: ImpliesRestricted, |
| 820 | roots: []string{"gplContainer.meta_lic"}, |
| 821 | edges: []annotated{ |
| 822 | {"gplContainer.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 823 | }, |
| 824 | expectedActions: []act{ |
| 825 | {"gplContainer.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 826 | {"apacheLib.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 827 | {"apacheLib.meta_lic", "gplContainer.meta_lic", "restricted"}, |
| 828 | }, |
| 829 | }, |
| 830 | { |
| 831 | name: "gploncontainernotice", |
| 832 | condition: ImpliesNotice, |
| 833 | roots: []string{"apacheContainer.meta_lic"}, |
| 834 | edges: []annotated{ |
| 835 | {"apacheContainer.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 836 | {"apacheContainer.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 837 | }, |
| 838 | expectedActions: []act{ |
| 839 | {"apacheContainer.meta_lic", "apacheContainer.meta_lic", "notice"}, |
| 840 | {"apacheContainer.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 841 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 842 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 843 | {"gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 844 | }, |
| 845 | }, |
| 846 | { |
| 847 | name: "gploncontainerrestricted", |
| 848 | condition: ImpliesRestricted, |
| 849 | roots: []string{"apacheContainer.meta_lic"}, |
| 850 | edges: []annotated{ |
| 851 | {"apacheContainer.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 852 | {"apacheContainer.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 853 | }, |
| 854 | expectedActions: []act{ |
| 855 | {"apacheContainer.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 856 | {"gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 857 | }, |
| 858 | }, |
| 859 | { |
| 860 | name: "gplonbinnotice", |
| 861 | condition: ImpliesNotice, |
| 862 | roots: []string{"apacheBin.meta_lic"}, |
| 863 | edges: []annotated{ |
| 864 | {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 865 | {"apacheBin.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 866 | }, |
| 867 | expectedActions: []act{ |
| 868 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
| 869 | {"apacheBin.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 870 | {"apacheLib.meta_lic", "apacheLib.meta_lic", "notice"}, |
| 871 | {"apacheLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 872 | {"gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 873 | }, |
| 874 | }, |
| 875 | { |
| 876 | name: "gplonbinrestricted", |
| 877 | condition: ImpliesRestricted, |
| 878 | roots: []string{"apacheBin.meta_lic"}, |
| 879 | edges: []annotated{ |
| 880 | {"apacheBin.meta_lic", "apacheLib.meta_lic", []string{"static"}}, |
| 881 | {"apacheBin.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 882 | }, |
| 883 | expectedActions: []act{ |
| 884 | {"apacheBin.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 885 | {"apacheLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 886 | {"gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 887 | }, |
| 888 | }, |
| 889 | { |
| 890 | name: "gplonfpdynamicnotice", |
| 891 | condition: ImpliesNotice, |
| 892 | roots: []string{"gplBin.meta_lic"}, |
| 893 | edges: []annotated{ |
| 894 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 895 | }, |
| 896 | expectedActions: []act{ |
| 897 | {"gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 898 | }, |
| 899 | }, |
| 900 | { |
| 901 | name: "gplonfpdynamicrestricted", |
| 902 | condition: ImpliesRestricted, |
| 903 | roots: []string{"gplBin.meta_lic"}, |
| 904 | edges: []annotated{ |
| 905 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 906 | }, |
| 907 | expectedActions: []act{ |
| 908 | {"gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 909 | }, |
| 910 | }, |
| 911 | { |
| 912 | name: "gplonfpdynamicrestrictedshipped", |
| 913 | condition: ImpliesRestricted, |
| 914 | roots: []string{"gplBin.meta_lic", "apacheLib.meta_lic"}, |
| 915 | edges: []annotated{ |
| 916 | {"gplBin.meta_lic", "apacheLib.meta_lic", []string{"dynamic"}}, |
| 917 | }, |
| 918 | expectedActions: []act{ |
| 919 | {"gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 920 | {"apacheLib.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 921 | }, |
| 922 | }, |
| 923 | { |
| 924 | name: "independentmodulereversenotice", |
| 925 | condition: ImpliesNotice, |
| 926 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 927 | edges: []annotated{ |
| 928 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"dynamic"}}, |
| 929 | }, |
| 930 | expectedActions: []act{ |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 931 | {"gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "permissive"}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 932 | }, |
| 933 | }, |
| 934 | { |
| 935 | name: "independentmodulereverserestricted", |
| 936 | condition: ImpliesRestricted, |
| 937 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 938 | edges: []annotated{ |
| 939 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"dynamic"}}, |
| 940 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 941 | expectedActions: []act{}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 942 | }, |
| 943 | { |
| 944 | name: "independentmodulereverserestrictedshipped", |
| 945 | condition: ImpliesRestricted, |
| 946 | roots: []string{"gplWithClasspathException.meta_lic", "apacheBin.meta_lic"}, |
| 947 | edges: []annotated{ |
| 948 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"dynamic"}}, |
| 949 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 950 | expectedActions: []act{}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 951 | }, |
| 952 | { |
| 953 | name: "independentmodulereversestaticnotice", |
| 954 | condition: ImpliesNotice, |
| 955 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 956 | edges: []annotated{ |
| 957 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"static"}}, |
| 958 | }, |
| 959 | expectedActions: []act{ |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 960 | {"gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "permissive"}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 961 | {"apacheBin.meta_lic", "apacheBin.meta_lic", "notice"}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 962 | }, |
| 963 | }, |
| 964 | { |
| 965 | name: "independentmodulereversestaticrestricted", |
| 966 | condition: ImpliesRestricted, |
| 967 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 968 | edges: []annotated{ |
| 969 | {"gplWithClasspathException.meta_lic", "apacheBin.meta_lic", []string{"static"}}, |
| 970 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 971 | expectedActions: []act{}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 972 | }, |
| 973 | { |
| 974 | name: "dependentmodulereversenotice", |
| 975 | condition: ImpliesNotice, |
| 976 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 977 | edges: []annotated{ |
| 978 | {"gplWithClasspathException.meta_lic", "dependentModule.meta_lic", []string{"dynamic"}}, |
| 979 | }, |
| 980 | expectedActions: []act{ |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 981 | {"gplWithClasspathException.meta_lic", "gplWithClasspathException.meta_lic", "permissive"}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 982 | }, |
| 983 | }, |
| 984 | { |
| 985 | name: "dependentmodulereverserestricted", |
| 986 | condition: ImpliesRestricted, |
| 987 | roots: []string{"gplWithClasspathException.meta_lic"}, |
| 988 | edges: []annotated{ |
| 989 | {"gplWithClasspathException.meta_lic", "dependentModule.meta_lic", []string{"dynamic"}}, |
| 990 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 991 | expectedActions: []act{}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 992 | }, |
| 993 | { |
| 994 | name: "dependentmodulereverserestrictedshipped", |
| 995 | condition: ImpliesRestricted, |
| 996 | roots: []string{"gplWithClasspathException.meta_lic", "dependentModule.meta_lic"}, |
| 997 | edges: []annotated{ |
| 998 | {"gplWithClasspathException.meta_lic", "dependentModule.meta_lic", []string{"dynamic"}}, |
| 999 | }, |
Bob Badour | 10f5c48 | 2022-09-20 21:44:17 -0700 | [diff] [blame^] | 1000 | expectedActions: []act{}, |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 1001 | }, |
| 1002 | { |
| 1003 | name: "ponrnotice", |
| 1004 | condition: ImpliesNotice, |
| 1005 | roots: []string{"proprietary.meta_lic"}, |
| 1006 | edges: []annotated{ |
| 1007 | {"proprietary.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 1008 | }, |
| 1009 | expectedActions: []act{ |
| 1010 | {"proprietary.meta_lic", "proprietary.meta_lic", "proprietary"}, |
| 1011 | {"proprietary.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 1012 | {"gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 1013 | }, |
| 1014 | }, |
| 1015 | { |
| 1016 | name: "ponrrestricted", |
| 1017 | condition: ImpliesRestricted, |
| 1018 | roots: []string{"proprietary.meta_lic"}, |
| 1019 | edges: []annotated{ |
| 1020 | {"proprietary.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 1021 | }, |
| 1022 | expectedActions: []act{ |
| 1023 | {"gplLib.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 1024 | {"proprietary.meta_lic", "gplLib.meta_lic", "restricted"}, |
| 1025 | }, |
| 1026 | }, |
| 1027 | { |
| 1028 | name: "ponrproprietary", |
| 1029 | condition: ImpliesProprietary, |
| 1030 | roots: []string{"proprietary.meta_lic"}, |
| 1031 | edges: []annotated{ |
| 1032 | {"proprietary.meta_lic", "gplLib.meta_lic", []string{"static"}}, |
| 1033 | }, |
| 1034 | expectedActions: []act{ |
| 1035 | {"proprietary.meta_lic", "proprietary.meta_lic", "proprietary"}, |
| 1036 | }, |
| 1037 | }, |
| 1038 | { |
| 1039 | name: "ronpnotice", |
| 1040 | condition: ImpliesNotice, |
| 1041 | roots: []string{"gplBin.meta_lic"}, |
| 1042 | edges: []annotated{ |
| 1043 | {"gplBin.meta_lic", "proprietary.meta_lic", []string{"static"}}, |
| 1044 | }, |
| 1045 | expectedActions: []act{ |
| 1046 | {"gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 1047 | {"proprietary.meta_lic", "proprietary.meta_lic", "proprietary"}, |
| 1048 | {"proprietary.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 1049 | }, |
| 1050 | }, |
| 1051 | { |
| 1052 | name: "ronprestricted", |
| 1053 | condition: ImpliesRestricted, |
| 1054 | roots: []string{"gplBin.meta_lic"}, |
| 1055 | edges: []annotated{ |
| 1056 | {"gplBin.meta_lic", "proprietary.meta_lic", []string{"static"}}, |
| 1057 | }, |
| 1058 | expectedActions: []act{ |
| 1059 | {"gplBin.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 1060 | {"proprietary.meta_lic", "gplBin.meta_lic", "restricted"}, |
| 1061 | }, |
| 1062 | }, |
| 1063 | { |
| 1064 | name: "ronpproprietary", |
| 1065 | condition: ImpliesProprietary, |
| 1066 | roots: []string{"gplBin.meta_lic"}, |
| 1067 | edges: []annotated{ |
| 1068 | {"gplBin.meta_lic", "proprietary.meta_lic", []string{"static"}}, |
| 1069 | }, |
| 1070 | expectedActions: []act{ |
| 1071 | {"proprietary.meta_lic", "proprietary.meta_lic", "proprietary"}, |
| 1072 | }, |
| 1073 | }, |
| 1074 | { |
| 1075 | name: "noticeonb_e_onotice", |
| 1076 | condition: ImpliesNotice, |
| 1077 | roots: []string{"mitBin.meta_lic"}, |
| 1078 | edges: []annotated{ |
| 1079 | {"mitBin.meta_lic", "by_exception.meta_lic", []string{"static"}}, |
| 1080 | }, |
| 1081 | expectedActions: []act{ |
| 1082 | {"mitBin.meta_lic", "mitBin.meta_lic", "notice"}, |
| 1083 | {"by_exception.meta_lic", "by_exception.meta_lic", "by_exception_only"}, |
| 1084 | }, |
| 1085 | }, |
| 1086 | { |
| 1087 | name: "noticeonb_e_orestricted", |
| 1088 | condition: ImpliesRestricted, |
| 1089 | roots: []string{"mitBin.meta_lic"}, |
| 1090 | edges: []annotated{ |
| 1091 | {"mitBin.meta_lic", "by_exception.meta_lic", []string{"static"}}, |
| 1092 | }, |
| 1093 | expectedActions: []act{}, |
| 1094 | }, |
| 1095 | { |
| 1096 | name: "noticeonb_e_ob_e_o", |
| 1097 | condition: ImpliesByExceptionOnly, |
| 1098 | roots: []string{"mitBin.meta_lic"}, |
| 1099 | edges: []annotated{ |
| 1100 | {"mitBin.meta_lic", "by_exception.meta_lic", []string{"static"}}, |
| 1101 | }, |
| 1102 | expectedActions: []act{ |
| 1103 | {"by_exception.meta_lic", "by_exception.meta_lic", "by_exception_only"}, |
| 1104 | }, |
| 1105 | }, |
| 1106 | { |
| 1107 | name: "b_e_oonnoticenotice", |
| 1108 | condition: ImpliesNotice, |
| 1109 | roots: []string{"by_exception.meta_lic"}, |
| 1110 | edges: []annotated{ |
| 1111 | {"by_exception.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 1112 | }, |
| 1113 | expectedActions: []act{ |
| 1114 | {"by_exception.meta_lic", "by_exception.meta_lic", "by_exception_only"}, |
| 1115 | {"mitLib.meta_lic", "mitLib.meta_lic", "notice"}, |
| 1116 | }, |
| 1117 | }, |
| 1118 | { |
| 1119 | name: "b_e_oonnoticerestricted", |
| 1120 | condition: ImpliesRestricted, |
| 1121 | roots: []string{"by_exception.meta_lic"}, |
| 1122 | edges: []annotated{ |
| 1123 | {"by_exception.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 1124 | }, |
| 1125 | expectedActions: []act{}, |
| 1126 | }, |
| 1127 | { |
| 1128 | name: "b_e_oonnoticeb_e_o", |
| 1129 | condition: ImpliesByExceptionOnly, |
| 1130 | roots: []string{"by_exception.meta_lic"}, |
| 1131 | edges: []annotated{ |
| 1132 | {"by_exception.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 1133 | }, |
| 1134 | expectedActions: []act{ |
| 1135 | {"by_exception.meta_lic", "by_exception.meta_lic", "by_exception_only"}, |
| 1136 | }, |
| 1137 | }, |
| 1138 | { |
| 1139 | name: "noticeonrecipnotice", |
| 1140 | condition: ImpliesNotice, |
| 1141 | roots: []string{"mitBin.meta_lic"}, |
| 1142 | edges: []annotated{ |
| 1143 | {"mitBin.meta_lic", "mplLib.meta_lic", []string{"static"}}, |
| 1144 | }, |
| 1145 | expectedActions: []act{ |
| 1146 | {"mitBin.meta_lic", "mitBin.meta_lic", "notice"}, |
| 1147 | {"mplLib.meta_lic", "mplLib.meta_lic", "reciprocal"}, |
| 1148 | }, |
| 1149 | }, |
| 1150 | { |
| 1151 | name: "noticeonreciprecip", |
| 1152 | condition: ImpliesReciprocal, |
| 1153 | roots: []string{"mitBin.meta_lic"}, |
| 1154 | edges: []annotated{ |
| 1155 | {"mitBin.meta_lic", "mplLib.meta_lic", []string{"static"}}, |
| 1156 | }, |
| 1157 | expectedActions: []act{ |
| 1158 | {"mplLib.meta_lic", "mplLib.meta_lic", "reciprocal"}, |
| 1159 | }, |
| 1160 | }, |
| 1161 | { |
| 1162 | name: "reciponnoticenotice", |
| 1163 | condition: ImpliesNotice, |
| 1164 | roots: []string{"mplBin.meta_lic"}, |
| 1165 | edges: []annotated{ |
| 1166 | {"mplBin.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 1167 | }, |
| 1168 | expectedActions: []act{ |
| 1169 | {"mplBin.meta_lic", "mplBin.meta_lic", "reciprocal"}, |
| 1170 | {"mitLib.meta_lic", "mitLib.meta_lic", "notice"}, |
| 1171 | }, |
| 1172 | }, |
| 1173 | { |
| 1174 | name: "reciponnoticerecip", |
| 1175 | condition: ImpliesReciprocal, |
| 1176 | roots: []string{"mplBin.meta_lic"}, |
| 1177 | edges: []annotated{ |
| 1178 | {"mplBin.meta_lic", "mitLib.meta_lic", []string{"static"}}, |
| 1179 | }, |
| 1180 | expectedActions: []act{ |
| 1181 | {"mplBin.meta_lic", "mplBin.meta_lic", "reciprocal"}, |
| 1182 | }, |
| 1183 | }, |
| 1184 | } |
| 1185 | for _, tt := range tests { |
| 1186 | t.Run(tt.name, func(t *testing.T) { |
| 1187 | stderr := &bytes.Buffer{} |
| 1188 | lg, err := toGraph(stderr, tt.roots, tt.edges) |
| 1189 | if err != nil { |
Colin Cross | 179ec3e | 2022-01-27 15:47:09 -0800 | [diff] [blame] | 1190 | t.Errorf("unexpected test data error: got %s, want no error", err) |
Bob Badour | 103eb0f | 2022-01-10 13:50:57 -0800 | [diff] [blame] | 1191 | return |
| 1192 | } |
| 1193 | expectedAs := toActionSet(lg, tt.expectedActions) |
| 1194 | ResolveTopDownConditions(lg) |
| 1195 | actualAs := WalkActionsForCondition(lg, tt.condition) |
| 1196 | checkResolvesActions(lg, actualAs, expectedAs, t) |
Bob Badour | 9ee7d03 | 2021-10-25 16:51:48 -0700 | [diff] [blame] | 1197 | }) |
| 1198 | } |
| 1199 | } |