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