| 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 | 
|  | 25 | condition           ConditionNames | 
|  | 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 { | 
|  | 623 | t.Errorf("unexpected test data error: got %w, want no error", err) | 
|  | 624 | return | 
|  | 625 | } | 
|  | 626 | expectedRs := toResolutionSet(lg, tt.expectedResolutions) | 
|  | 627 | actualRs := WalkResolutionsForCondition(lg, ResolveTopDownConditions(lg), tt.condition) | 
|  | 628 | checkSame(actualRs, expectedRs, t) | 
|  | 629 | }) | 
|  | 630 | } | 
|  | 631 | } |