dependabot-nuget 0.297.2 → 0.299.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,12 +14,17 @@ using Xunit;
14
14
 
15
15
  namespace NuGetUpdater.Core.Test.Run;
16
16
 
17
+ using static NuGetUpdater.Core.Utilities.EOLHandling;
18
+
17
19
  using TestFile = (string Path, string Content);
18
20
 
19
21
  public class RunWorkerTests
20
22
  {
21
- [Fact]
22
- public async Task UpdateSinglePackageProducedExpectedAPIMessages()
23
+ [Theory]
24
+ [InlineData(EOLType.CR)]
25
+ [InlineData(EOLType.LF)]
26
+ [InlineData(EOLType.CRLF)]
27
+ public async Task UpdateSinglePackageProducedExpectedAPIMessages(EOLType EOL)
23
28
  {
24
29
  await RunAsync(
25
30
  packages: [],
@@ -43,7 +48,7 @@ public class RunWorkerTests
43
48
  <PackageReference Include="Some.Package" Version="1.0.0" />
44
49
  </ItemGroup>
45
50
  </Project>
46
- """)
51
+ """.SetEOL(EOL))
47
52
  ],
48
53
  discoveryWorker: new TestDiscoveryWorker(_input =>
49
54
  {
@@ -94,7 +99,7 @@ public class RunWorkerTests
94
99
  <PackageReference Include="Some.Package" Version="1.0.1" />
95
100
  </ItemGroup>
96
101
  </Project>
97
- """);
102
+ """.SetEOL(EOL));
98
103
  return new UpdateOperationResult();
99
104
  }),
100
105
  expectedResult: new RunResult()
@@ -114,7 +119,7 @@ public class RunWorkerTests
114
119
  <PackageReference Include="Some.Package" Version="1.0.0" />
115
120
  </ItemGroup>
116
121
  </Project>
117
- """))
122
+ """.SetEOL(EOL)))
118
123
  }
119
124
  ],
120
125
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -199,7 +204,7 @@ public class RunWorkerTests
199
204
  <PackageReference Include="Some.Package" Version="1.0.1" />
200
205
  </ItemGroup>
201
206
  </Project>
202
- """,
207
+ """.SetEOL(EOL),
203
208
  },
204
209
  ],
205
210
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -212,11 +217,14 @@ public class RunWorkerTests
212
217
  );
213
218
  }
214
219
 
215
- [Fact]
216
- public async Task UpdateHandlesSemicolonsInPackageReference()
220
+ [Theory]
221
+ [InlineData(EOLType.CR)]
222
+ [InlineData(EOLType.LF)]
223
+ [InlineData(EOLType.CRLF)]
224
+ public async Task UpdateHandlesSemicolonsInPackageReference(EOLType EOL)
217
225
  {
218
- var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
219
- var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
226
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""".SetEOL(EOL));
227
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""".SetEOL(EOL));
220
228
  await RunAsync(
221
229
  packages:
222
230
  [
@@ -246,7 +254,7 @@ public class RunWorkerTests
246
254
  <PackageReference Include="Some.Package;Some.Package2" Version="1.0.0" />
247
255
  </ItemGroup>
248
256
  </Project>
249
- """)
257
+ """.SetEOL(EOL))
250
258
  ],
251
259
  discoveryWorker: new TestDiscoveryWorker(_input =>
252
260
  {
@@ -299,7 +307,7 @@ public class RunWorkerTests
299
307
  <PackageReference Include="Some.Package;Some.Package2" Version="1.0.1" />
300
308
  </ItemGroup>
301
309
  </Project>
302
- """);
310
+ """.SetEOL(EOL));
303
311
  return new UpdateOperationResult();
304
312
  }),
305
313
  expectedResult: new RunResult()
@@ -319,7 +327,7 @@ public class RunWorkerTests
319
327
  <PackageReference Include="Some.Package;Some.Package2" Version="1.0.0" />
320
328
  </ItemGroup>
321
329
  </Project>
322
- """))
330
+ """.SetEOL(EOL)))
323
331
  }
324
332
  ],
325
333
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -447,7 +455,7 @@ public class RunWorkerTests
447
455
  <PackageReference Include="Some.Package;Some.Package2" Version="1.0.1" />
448
456
  </ItemGroup>
449
457
  </Project>
450
- """,
458
+ """.SetEOL(EOL),
451
459
  }
452
460
 
453
461
  ],
@@ -461,8 +469,11 @@ public class RunWorkerTests
461
469
  );
462
470
  }
463
471
 
464
- [Fact]
465
- public async Task PrivateSourceAuthenticationFailureIsForwaredToApiHandler()
472
+ [Theory]
473
+ [InlineData(EOLType.CR)]
474
+ [InlineData(EOLType.LF)]
475
+ [InlineData(EOLType.CRLF)]
476
+ public async Task PrivateSourceAuthenticationFailureIsForwaredToApiHandler(EOLType EOL)
466
477
  {
467
478
  await RunAsync(
468
479
  packages:
@@ -486,7 +497,7 @@ public class RunWorkerTests
486
497
  <add key="private_feed" value="http://example.com/nuget/index.json" allowInsecureConnections="true" />
487
498
  </packageSources>
488
499
  </configuration>
489
- """),
500
+ """.SetEOL(EOL)),
490
501
  ("project.csproj", """
491
502
  <Project Sdk="Microsoft.NET.Sdk">
492
503
  <PropertyGroup>
@@ -496,7 +507,7 @@ public class RunWorkerTests
496
507
  <PackageReference Include="Some.Package" Version="1.0.0" />
497
508
  </ItemGroup>
498
509
  </Project>
499
- """)
510
+ """.SetEOL(EOL))
500
511
  ],
501
512
  discoveryWorker: new TestDiscoveryWorker((_input) =>
502
513
  {
@@ -517,11 +528,14 @@ public class RunWorkerTests
517
528
  );
518
529
  }
519
530
 
520
- [Fact]
521
- public async Task UpdateHandlesPackagesConfigFiles()
531
+ [Theory]
532
+ [InlineData(EOLType.CR)]
533
+ [InlineData(EOLType.LF)]
534
+ [InlineData(EOLType.CRLF)]
535
+ public async Task UpdateHandlesPackagesConfigFiles(EOLType EOL)
522
536
  {
523
- var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
524
- var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
537
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""".SetEOL(EOL));
538
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""".SetEOL(EOL));
525
539
  await RunAsync(
526
540
  packages:
527
541
  [
@@ -551,13 +565,13 @@ public class RunWorkerTests
551
565
  <PackageReference Include="Some.Package" Version="1.0.0" />
552
566
  </ItemGroup>
553
567
  </Project>
554
- """),
568
+ """.SetEOL(EOL)),
555
569
  ("some-dir/packages.config", """
556
570
  <?xml version="1.0" encoding="utf-8"?>
557
571
  <packages>
558
572
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
559
573
  </packages>
560
- """),
574
+ """.SetEOL(EOL)),
561
575
  ],
562
576
  discoveryWorker: new TestDiscoveryWorker(_input =>
563
577
  {
@@ -630,7 +644,7 @@ public class RunWorkerTests
630
644
  <PackageReference Include="Some.Package" Version="1.0.1" />
631
645
  </ItemGroup>
632
646
  </Project>
633
- """);
647
+ """.SetEOL(EOL));
634
648
  break;
635
649
  case "Some.Package2":
636
650
  await File.WriteAllTextAsync(projectPath, """
@@ -648,14 +662,14 @@ public class RunWorkerTests
648
662
  </Reference>
649
663
  </ItemGroup>
650
664
  </Project>
651
- """);
665
+ """.SetEOL(EOL));
652
666
  var packagesConfigPath = Path.Join(Path.GetDirectoryName(projectPath)!, "packages.config");
653
667
  await File.WriteAllTextAsync(packagesConfigPath, """
654
668
  <?xml version="1.0" encoding="utf-8"?>
655
669
  <packages>
656
670
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
657
671
  </packages>
658
- """);
672
+ """.SetEOL(EOL));
659
673
  break;
660
674
  default:
661
675
  throw new NotSupportedException();
@@ -676,7 +690,7 @@ public class RunWorkerTests
676
690
  <packages>
677
691
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
678
692
  </packages>
679
- """))
693
+ """.SetEOL(EOL)))
680
694
  },
681
695
  new DependencyFile()
682
696
  {
@@ -691,7 +705,7 @@ public class RunWorkerTests
691
705
  <PackageReference Include="Some.Package" Version="1.0.0" />
692
706
  </ItemGroup>
693
707
  </Project>
694
- """))
708
+ """.SetEOL(EOL)))
695
709
  },
696
710
  ],
697
711
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -815,7 +829,7 @@ public class RunWorkerTests
815
829
  <packages>
816
830
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
817
831
  </packages>
818
- """,
832
+ """.SetEOL(EOL),
819
833
  },
820
834
  new DependencyFile()
821
835
  {
@@ -836,7 +850,7 @@ public class RunWorkerTests
836
850
  </Reference>
837
851
  </ItemGroup>
838
852
  </Project>
839
- """,
853
+ """.SetEOL(EOL),
840
854
  },
841
855
  ],
842
856
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -849,11 +863,14 @@ public class RunWorkerTests
849
863
  );
850
864
  }
851
865
 
852
- [Fact]
853
- public async Task UpdateHandlesPackagesConfigFromReferencedCsprojFiles()
866
+ [Theory]
867
+ [InlineData(EOLType.CR)]
868
+ [InlineData(EOLType.LF)]
869
+ [InlineData(EOLType.CRLF)]
870
+ public async Task UpdateHandlesPackagesConfigFromReferencedCsprojFiles(EOLType EOL)
854
871
  {
855
- var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
856
- var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
872
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""".SetEOL(EOL));
873
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""".SetEOL(EOL));
857
874
  await RunAsync(
858
875
  packages:
859
876
  [
@@ -886,13 +903,13 @@ public class RunWorkerTests
886
903
  <ProjectReference Include="../ProjectB/ProjectB.csproj" />
887
904
  </ItemGroup>
888
905
  </Project>
889
- """),
906
+ """.SetEOL(EOL)),
890
907
  ("some-dir/ProjectA/packages.config", """
891
908
  <?xml version="1.0" encoding="utf-8"?>
892
909
  <packages>
893
910
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
894
911
  </packages>
895
- """),
912
+ """.SetEOL(EOL)),
896
913
  ("some-dir/ProjectB/ProjectB.csproj", """
897
914
  <Project Sdk="Microsoft.NET.Sdk">
898
915
  <PropertyGroup>
@@ -902,13 +919,13 @@ public class RunWorkerTests
902
919
  <PackageReference Include="Some.Package" Version="1.0.0" />
903
920
  </ItemGroup>
904
921
  </Project>
905
- """),
922
+ """.SetEOL(EOL)),
906
923
  ("some-dir/ProjectB/packages.config", """
907
924
  <?xml version="1.0" encoding="utf-8"?>
908
925
  <packages>
909
926
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
910
927
  </packages>
911
- """),
928
+ """.SetEOL(EOL)),
912
929
  ],
913
930
  discoveryWorker: new TestDiscoveryWorker(_input =>
914
931
  {
@@ -999,7 +1016,7 @@ public class RunWorkerTests
999
1016
  <ProjectReference Include="../ProjectB/ProjectB.csproj" />
1000
1017
  </ItemGroup>
1001
1018
  </Project>
1002
- """);
1019
+ """.SetEOL(EOL));
1003
1020
  break;
1004
1021
  case ("ProjectA.csproj", "Some.Package2"):
1005
1022
  await File.WriteAllTextAsync(projectPath, """
@@ -1020,13 +1037,13 @@ public class RunWorkerTests
1020
1037
  </Reference>
1021
1038
  </ItemGroup>
1022
1039
  </Project>
1023
- """);
1040
+ """.SetEOL(EOL));
1024
1041
  await File.WriteAllTextAsync(packagesConfigPath, """
1025
1042
  <?xml version="1.0" encoding="utf-8"?>
1026
1043
  <packages>
1027
1044
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1028
1045
  </packages>
1029
- """);
1046
+ """.SetEOL(EOL));
1030
1047
  break;
1031
1048
  case ("ProjectB.csproj", "Some.Package"):
1032
1049
  await File.WriteAllTextAsync(projectPath, """
@@ -1038,7 +1055,7 @@ public class RunWorkerTests
1038
1055
  <PackageReference Include="Some.Package" Version="1.0.1" />
1039
1056
  </ItemGroup>
1040
1057
  </Project>
1041
- """);
1058
+ """.SetEOL(EOL));
1042
1059
  break;
1043
1060
  case ("ProjectB.csproj", "Some.Package2"):
1044
1061
  await File.WriteAllTextAsync(projectPath, """
@@ -1056,13 +1073,13 @@ public class RunWorkerTests
1056
1073
  </Reference>
1057
1074
  </ItemGroup>
1058
1075
  </Project>
1059
- """);
1076
+ """.SetEOL(EOL));
1060
1077
  await File.WriteAllTextAsync(packagesConfigPath, """
1061
1078
  <?xml version="1.0" encoding="utf-8"?>
1062
1079
  <packages>
1063
1080
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1064
1081
  </packages>
1065
- """);
1082
+ """.SetEOL(EOL));
1066
1083
  break;
1067
1084
  default:
1068
1085
  throw new NotSupportedException();
@@ -1083,7 +1100,7 @@ public class RunWorkerTests
1083
1100
  <packages>
1084
1101
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
1085
1102
  </packages>
1086
- """))
1103
+ """.SetEOL(EOL)))
1087
1104
  },
1088
1105
  new DependencyFile()
1089
1106
  {
@@ -1101,7 +1118,7 @@ public class RunWorkerTests
1101
1118
  <ProjectReference Include="../ProjectB/ProjectB.csproj" />
1102
1119
  </ItemGroup>
1103
1120
  </Project>
1104
- """))
1121
+ """.SetEOL(EOL)))
1105
1122
  },
1106
1123
  new DependencyFile()
1107
1124
  {
@@ -1112,7 +1129,7 @@ public class RunWorkerTests
1112
1129
  <packages>
1113
1130
  <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
1114
1131
  </packages>
1115
- """))
1132
+ """.SetEOL(EOL)))
1116
1133
  },
1117
1134
  new DependencyFile()
1118
1135
  {
@@ -1127,7 +1144,7 @@ public class RunWorkerTests
1127
1144
  <PackageReference Include="Some.Package" Version="1.0.0" />
1128
1145
  </ItemGroup>
1129
1146
  </Project>
1130
- """))
1147
+ """.SetEOL(EOL)))
1131
1148
  },
1132
1149
  ],
1133
1150
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1337,7 +1354,7 @@ public class RunWorkerTests
1337
1354
  <packages>
1338
1355
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1339
1356
  </packages>
1340
- """,
1357
+ """.SetEOL(EOL),
1341
1358
  },
1342
1359
  new DependencyFile()
1343
1360
  {
@@ -1361,7 +1378,7 @@ public class RunWorkerTests
1361
1378
  </Reference>
1362
1379
  </ItemGroup>
1363
1380
  </Project>
1364
- """,
1381
+ """.SetEOL(EOL),
1365
1382
  },
1366
1383
  new DependencyFile()
1367
1384
  {
@@ -1372,7 +1389,7 @@ public class RunWorkerTests
1372
1389
  <packages>
1373
1390
  <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
1374
1391
  </packages>
1375
- """,
1392
+ """.SetEOL(EOL),
1376
1393
  },
1377
1394
  new DependencyFile()
1378
1395
  {
@@ -1393,7 +1410,7 @@ public class RunWorkerTests
1393
1410
  </Reference>
1394
1411
  </ItemGroup>
1395
1412
  </Project>
1396
- """,
1413
+ """.SetEOL(EOL),
1397
1414
  },
1398
1415
  ],
1399
1416
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1406,8 +1423,11 @@ public class RunWorkerTests
1406
1423
  );
1407
1424
  }
1408
1425
 
1409
- [Fact]
1410
- public async Task UpdatedFilesAreOnlyReportedOnce()
1426
+ [Theory]
1427
+ [InlineData(EOLType.CR)]
1428
+ [InlineData(EOLType.LF)]
1429
+ [InlineData(EOLType.CRLF)]
1430
+ public async Task UpdatedFilesAreOnlyReportedOnce(EOLType EOL)
1411
1431
  {
1412
1432
  await RunAsync(
1413
1433
  job: new()
@@ -1434,14 +1454,14 @@ public class RunWorkerTests
1434
1454
  <ProjectFile Include="project2/project2.csproj" />
1435
1455
  </ItemGroup>
1436
1456
  </Project>
1437
- """),
1457
+ """.SetEOL(EOL)),
1438
1458
  ("Directory.Build.props", """
1439
1459
  <Project>
1440
1460
  <PropertyGroup>
1441
1461
  <SomePackageVersion>1.0.0</SomePackageVersion>
1442
1462
  </PropertyGroup>
1443
1463
  </Project>
1444
- """),
1464
+ """.SetEOL(EOL)),
1445
1465
  ("project1/project1.csproj", """
1446
1466
  <Project Sdk="Microsoft.NET.Sdk">
1447
1467
  <PropertyGroup>
@@ -1451,7 +1471,7 @@ public class RunWorkerTests
1451
1471
  <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1452
1472
  </ItemGroup>
1453
1473
  </Project>
1454
- """),
1474
+ """.SetEOL(EOL)),
1455
1475
  ("project2/project2.csproj", """
1456
1476
  <Project Sdk="Microsoft.NET.Sdk">
1457
1477
  <PropertyGroup>
@@ -1461,7 +1481,7 @@ public class RunWorkerTests
1461
1481
  <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1462
1482
  </ItemGroup>
1463
1483
  </Project>
1464
- """)
1484
+ """.SetEOL(EOL))
1465
1485
  ],
1466
1486
  discoveryWorker: new TestDiscoveryWorker(_input =>
1467
1487
  {
@@ -1526,7 +1546,7 @@ public class RunWorkerTests
1526
1546
  <SomePackageVersion>1.1.0</SomePackageVersion>
1527
1547
  </PropertyGroup>
1528
1548
  </Project>
1529
- """);
1549
+ """.SetEOL(EOL));
1530
1550
  return new UpdateOperationResult();
1531
1551
  }),
1532
1552
  expectedResult: new RunResult()
@@ -1543,7 +1563,7 @@ public class RunWorkerTests
1543
1563
  <SomePackageVersion>1.0.0</SomePackageVersion>
1544
1564
  </PropertyGroup>
1545
1565
  </Project>
1546
- """))
1566
+ """.SetEOL(EOL)))
1547
1567
  },
1548
1568
  new DependencyFile()
1549
1569
  {
@@ -1558,7 +1578,7 @@ public class RunWorkerTests
1558
1578
  <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1559
1579
  </ItemGroup>
1560
1580
  </Project>
1561
- """))
1581
+ """.SetEOL(EOL)))
1562
1582
  },
1563
1583
  new DependencyFile()
1564
1584
  {
@@ -1573,7 +1593,7 @@ public class RunWorkerTests
1573
1593
  <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1574
1594
  </ItemGroup>
1575
1595
  </Project>
1576
- """))
1596
+ """.SetEOL(EOL)))
1577
1597
  },
1578
1598
  ],
1579
1599
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1698,7 +1718,7 @@ public class RunWorkerTests
1698
1718
  <SomePackageVersion>1.1.0</SomePackageVersion>
1699
1719
  </PropertyGroup>
1700
1720
  </Project>
1701
- """,
1721
+ """.SetEOL(EOL),
1702
1722
  }
1703
1723
  ],
1704
1724
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -1711,8 +1731,11 @@ public class RunWorkerTests
1711
1731
  );
1712
1732
  }
1713
1733
 
1714
- [Fact]
1715
- public async Task UpdatePackageWithDifferentVersionsInDifferentDirectories()
1734
+ [Theory]
1735
+ [InlineData(EOLType.CR)]
1736
+ [InlineData(EOLType.LF)]
1737
+ [InlineData(EOLType.CRLF)]
1738
+ public async Task UpdatePackageWithDifferentVersionsInDifferentDirectories(EOLType EOL)
1716
1739
  {
1717
1740
  // this test passes `null` for discovery, analyze, and update workers to fully test the desired behavior
1718
1741
 
@@ -1754,7 +1777,7 @@ public class RunWorkerTests
1754
1777
  <ProjectFile Include="library3\library3.csproj" />
1755
1778
  </ItemGroup>
1756
1779
  </Project>
1757
- """),
1780
+ """.SetEOL(EOL)),
1758
1781
  ("Directory.Build.props", "<Project />"),
1759
1782
  ("Directory.Build.targets", "<Project />"),
1760
1783
  ("Directory.Packages.props", """
@@ -1763,7 +1786,7 @@ public class RunWorkerTests
1763
1786
  <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
1764
1787
  </PropertyGroup>
1765
1788
  </Project>
1766
- """),
1789
+ """.SetEOL(EOL)),
1767
1790
  ("library1/library1.csproj", """
1768
1791
  <Project Sdk="Microsoft.NET.Sdk">
1769
1792
  <PropertyGroup>
@@ -1773,7 +1796,7 @@ public class RunWorkerTests
1773
1796
  <PackageReference Include="Some.Package" Version="2.0.0" />
1774
1797
  </ItemGroup>
1775
1798
  </Project>
1776
- """),
1799
+ """.SetEOL(EOL)),
1777
1800
  ("library2/library2.csproj", """
1778
1801
  <Project Sdk="Microsoft.NET.Sdk">
1779
1802
  <PropertyGroup>
@@ -1783,7 +1806,7 @@ public class RunWorkerTests
1783
1806
  <PackageReference Include="Some.Package" Version="1.0.0" />
1784
1807
  </ItemGroup>
1785
1808
  </Project>
1786
- """),
1809
+ """.SetEOL(EOL)),
1787
1810
  ("library3/library3.csproj", """
1788
1811
  <Project Sdk="Microsoft.NET.Sdk">
1789
1812
  <PropertyGroup>
@@ -1793,7 +1816,7 @@ public class RunWorkerTests
1793
1816
  <PackageReference Include="Package.With.Transitive.Dependency" Version="0.1.0" />
1794
1817
  </ItemGroup>
1795
1818
  </Project>
1796
- """),
1819
+ """.SetEOL(EOL)),
1797
1820
  ],
1798
1821
  discoveryWorker: null,
1799
1822
  analyzeWorker: null,
@@ -1824,7 +1847,7 @@ public class RunWorkerTests
1824
1847
  <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
1825
1848
  </PropertyGroup>
1826
1849
  </Project>
1827
- """))
1850
+ """.SetEOL(EOL)))
1828
1851
  },
1829
1852
  new DependencyFile()
1830
1853
  {
@@ -1839,7 +1862,7 @@ public class RunWorkerTests
1839
1862
  <PackageReference Include="Some.Package" Version="2.0.0" />
1840
1863
  </ItemGroup>
1841
1864
  </Project>
1842
- """))
1865
+ """.SetEOL(EOL)))
1843
1866
  },
1844
1867
  new DependencyFile()
1845
1868
  {
@@ -1854,7 +1877,7 @@ public class RunWorkerTests
1854
1877
  <PackageReference Include="Some.Package" Version="1.0.0" />
1855
1878
  </ItemGroup>
1856
1879
  </Project>
1857
- """))
1880
+ """.SetEOL(EOL)))
1858
1881
  },
1859
1882
  new DependencyFile()
1860
1883
  {
@@ -1869,7 +1892,7 @@ public class RunWorkerTests
1869
1892
  <PackageReference Include="Package.With.Transitive.Dependency" Version="0.1.0" />
1870
1893
  </ItemGroup>
1871
1894
  </Project>
1872
- """))
1895
+ """.SetEOL(EOL)))
1873
1896
  }
1874
1897
  ],
1875
1898
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -2020,7 +2043,7 @@ public class RunWorkerTests
2020
2043
  <PackageReference Include="Some.Package" Version="2.0.0" />
2021
2044
  </ItemGroup>
2022
2045
  </Project>
2023
- """
2046
+ """.SetEOL(EOL)
2024
2047
  },
2025
2048
  new()
2026
2049
  {
@@ -2036,7 +2059,7 @@ public class RunWorkerTests
2036
2059
  <PackageReference Include="Some.Package" Version="2.0.0" />
2037
2060
  </ItemGroup>
2038
2061
  </Project>
2039
- """
2062
+ """.SetEOL(EOL)
2040
2063
  }
2041
2064
  ],
2042
2065
  BaseCommitSha = "TEST-COMMIT-SHA",
@@ -2049,6 +2072,391 @@ public class RunWorkerTests
2049
2072
  );
2050
2073
  }
2051
2074
 
2075
+ [Fact]
2076
+ public async Task PackageListedInSecurityAdvisoriesSectionIsNotVulnerable()
2077
+ {
2078
+ await RunAsync(
2079
+ job: new()
2080
+ {
2081
+ Source = new()
2082
+ {
2083
+ Provider = "github",
2084
+ Repo = "test/repo",
2085
+ },
2086
+ SecurityUpdatesOnly = true,
2087
+ SecurityAdvisories = [
2088
+ new()
2089
+ {
2090
+ DependencyName = "Package.Is.Not.Vulnerable",
2091
+ AffectedVersions = [Requirement.Parse("< 1.0.0")]
2092
+ }
2093
+ ]
2094
+ },
2095
+ files: [
2096
+ ("project.csproj", "contents irrelevant")
2097
+ ],
2098
+ discoveryWorker: new TestDiscoveryWorker(_input =>
2099
+ {
2100
+ return Task.FromResult(new WorkspaceDiscoveryResult()
2101
+ {
2102
+ Path = "",
2103
+ Projects = [
2104
+ new()
2105
+ {
2106
+ FilePath = "project.csproj",
2107
+ Dependencies = [
2108
+ new("Package.Is.Not.Vulnerable", "1.0.1", DependencyType.PackageReference)
2109
+ ],
2110
+ ImportedFiles = [],
2111
+ AdditionalFiles = [],
2112
+ }
2113
+ ]
2114
+ });
2115
+ }),
2116
+ analyzeWorker: new TestAnalyzeWorker(_input => throw new NotImplementedException("test shouldn't get this far")),
2117
+ updaterWorker: new TestUpdaterWorker(_input => throw new NotImplementedException("test shouldn't get this far")),
2118
+ expectedResult: new()
2119
+ {
2120
+ Base64DependencyFiles = [
2121
+ new()
2122
+ {
2123
+ Directory = "/",
2124
+ Name = "project.csproj",
2125
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("contents irrelevant"))
2126
+ }
2127
+ ],
2128
+ BaseCommitSha = "TEST-COMMIT-SHA",
2129
+ },
2130
+ expectedApiMessages: [
2131
+ new UpdatedDependencyList()
2132
+ {
2133
+ Dependencies = [
2134
+ new()
2135
+ {
2136
+ Name = "Package.Is.Not.Vulnerable",
2137
+ Version = "1.0.1",
2138
+ Requirements = [
2139
+ new()
2140
+ {
2141
+ Requirement = "1.0.1",
2142
+ File = "/project.csproj",
2143
+ Groups = ["dependencies"],
2144
+ }
2145
+ ]
2146
+ }
2147
+ ],
2148
+ DependencyFiles = ["/project.csproj"]
2149
+ },
2150
+ new IncrementMetric()
2151
+ {
2152
+ Metric = "updater.started",
2153
+ Tags = new()
2154
+ {
2155
+ ["operation"] = "create_security_pr"
2156
+ }
2157
+ },
2158
+ new SecurityUpdateNotNeeded("Package.Is.Not.Vulnerable"),
2159
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
2160
+ ]
2161
+ );
2162
+ }
2163
+
2164
+ [Fact]
2165
+ public async Task PackageListedInSecurityAdvisoriesSectionIsNotPresent()
2166
+ {
2167
+ await RunAsync(
2168
+ job: new()
2169
+ {
2170
+ Source = new()
2171
+ {
2172
+ Provider = "github",
2173
+ Repo = "test/repo",
2174
+ },
2175
+ SecurityUpdatesOnly = true,
2176
+ SecurityAdvisories = [
2177
+ new()
2178
+ {
2179
+ DependencyName = "Package.Is.Not.Vulnerable",
2180
+ AffectedVersions = [Requirement.Parse("< 1.0.0")]
2181
+ }
2182
+ ]
2183
+ },
2184
+ files: [
2185
+ ("project.csproj", "contents irrelevant")
2186
+ ],
2187
+ discoveryWorker: new TestDiscoveryWorker(_input =>
2188
+ {
2189
+ return Task.FromResult(new WorkspaceDiscoveryResult()
2190
+ {
2191
+ Path = "",
2192
+ Projects = [
2193
+ new()
2194
+ {
2195
+ FilePath = "project.csproj",
2196
+ Dependencies = [
2197
+ new("Unrelated.Package", "0.1.0", DependencyType.PackageReference)
2198
+ ],
2199
+ ImportedFiles = [],
2200
+ AdditionalFiles = [],
2201
+ }
2202
+ ]
2203
+ });
2204
+ }),
2205
+ analyzeWorker: new TestAnalyzeWorker(_input => throw new NotImplementedException("test shouldn't get this far")),
2206
+ updaterWorker: new TestUpdaterWorker(_input => throw new NotImplementedException("test shouldn't get this far")),
2207
+ expectedResult: new()
2208
+ {
2209
+ Base64DependencyFiles = [
2210
+ new()
2211
+ {
2212
+ Directory = "/",
2213
+ Name = "project.csproj",
2214
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("contents irrelevant"))
2215
+ }
2216
+ ],
2217
+ BaseCommitSha = "TEST-COMMIT-SHA",
2218
+ },
2219
+ expectedApiMessages: [
2220
+ new UpdatedDependencyList()
2221
+ {
2222
+ Dependencies = [
2223
+ new()
2224
+ {
2225
+ Name = "Unrelated.Package",
2226
+ Version = "0.1.0",
2227
+ Requirements = [
2228
+ new()
2229
+ {
2230
+ Requirement = "0.1.0",
2231
+ File = "/project.csproj",
2232
+ Groups = ["dependencies"],
2233
+ }
2234
+ ]
2235
+ }
2236
+ ],
2237
+ DependencyFiles = ["/project.csproj"]
2238
+ },
2239
+ new IncrementMetric()
2240
+ {
2241
+ Metric = "updater.started",
2242
+ Tags = new()
2243
+ {
2244
+ ["operation"] = "create_security_pr"
2245
+ }
2246
+ },
2247
+ new SecurityUpdateNotNeeded("Package.Is.Not.Vulnerable"),
2248
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
2249
+ ]
2250
+ );
2251
+ }
2252
+
2253
+ [Fact]
2254
+ public async Task NonProjectFilesAreIncludedInPullRequest()
2255
+ {
2256
+ await RunAsync(
2257
+ job: new()
2258
+ {
2259
+ Source = new()
2260
+ {
2261
+ Provider = "github",
2262
+ Repo = "test/repo",
2263
+ },
2264
+ },
2265
+ files: [
2266
+ (".config/dotnet-tools.json", "dotnet-tools.json content old"),
2267
+ ("global.json", "global.json content old")
2268
+ ],
2269
+ discoveryWorker: new TestDiscoveryWorker(input =>
2270
+ {
2271
+ return Task.FromResult(new WorkspaceDiscoveryResult()
2272
+ {
2273
+ Path = "",
2274
+ Projects = [],
2275
+ DotNetToolsJson = new()
2276
+ {
2277
+ FilePath = ".config/dotnet-tools.json",
2278
+ Dependencies = [
2279
+ new("some-tool", "2.0.0", DependencyType.DotNetTool),
2280
+ ]
2281
+ },
2282
+ GlobalJson = new()
2283
+ {
2284
+ FilePath = "global.json",
2285
+ Dependencies = [
2286
+ new("Some.MSBuild.Sdk", "1.0.0", DependencyType.MSBuildSdk),
2287
+ ],
2288
+ },
2289
+ });
2290
+ }),
2291
+ analyzeWorker: new TestAnalyzeWorker(input =>
2292
+ {
2293
+ var (_repoRoot, _discoveryResult, dependencyInfo) = input;
2294
+ var result = dependencyInfo.Name switch
2295
+ {
2296
+ "some-tool" => new AnalysisResult() { CanUpdate = true, UpdatedVersion = "2.0.1", UpdatedDependencies = [new("some-tool", "2.0.1", DependencyType.DotNetTool)] },
2297
+ "Some.MSBuild.Sdk" => new AnalysisResult() { CanUpdate = true, UpdatedVersion = "1.0.1", UpdatedDependencies = [new("Some.MSBuild.Sdk", "1.0.1", DependencyType.MSBuildSdk)] },
2298
+ _ => throw new NotImplementedException("unreachable")
2299
+ };
2300
+ return Task.FromResult(result);
2301
+ }),
2302
+ updaterWorker: new TestUpdaterWorker(async input =>
2303
+ {
2304
+ var (repoRoot, filePath, dependencyName, _previousVersion, _newVersion, _isTransitive) = input;
2305
+ var dependencyFilePath = Path.Join(repoRoot, filePath);
2306
+ var updatedContent = dependencyName switch
2307
+ {
2308
+ "some-tool" => "dotnet-tools.json content UPDATED",
2309
+ "Some.MSBuild.Sdk" => "global.json content UPDATED",
2310
+ _ => throw new NotImplementedException("unreachable")
2311
+ };
2312
+ await File.WriteAllTextAsync(dependencyFilePath, updatedContent);
2313
+ return new UpdateOperationResult();
2314
+ }),
2315
+ expectedResult: new()
2316
+ {
2317
+ Base64DependencyFiles = [
2318
+ new()
2319
+ {
2320
+ Directory = "/.config",
2321
+ Name = "dotnet-tools.json",
2322
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("dotnet-tools.json content old"))
2323
+ },
2324
+ new()
2325
+ {
2326
+ Directory = "/",
2327
+ Name = "global.json",
2328
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("global.json content old"))
2329
+ },
2330
+ ],
2331
+ BaseCommitSha = "TEST-COMMIT-SHA",
2332
+ },
2333
+ expectedApiMessages: [
2334
+ new UpdatedDependencyList()
2335
+ {
2336
+ Dependencies = [
2337
+ new()
2338
+ {
2339
+ Name = "some-tool",
2340
+ Version = "2.0.0",
2341
+ Requirements = [
2342
+ new()
2343
+ {
2344
+ Requirement = "2.0.0",
2345
+ File = "/.config/dotnet-tools.json",
2346
+ Groups = ["dependencies"],
2347
+ }
2348
+ ]
2349
+ },
2350
+ new()
2351
+ {
2352
+ Name = "Some.MSBuild.Sdk",
2353
+ Version = "1.0.0",
2354
+ Requirements = [
2355
+ new()
2356
+ {
2357
+ Requirement = "1.0.0",
2358
+ File = "/global.json",
2359
+ Groups = ["dependencies"],
2360
+ }
2361
+ ]
2362
+ },
2363
+ ],
2364
+ DependencyFiles = ["/.config/dotnet-tools.json", "/global.json"]
2365
+ },
2366
+ new IncrementMetric()
2367
+ {
2368
+ Metric = "updater.started",
2369
+ Tags = new()
2370
+ {
2371
+ ["operation"] = "group_update_all_versions"
2372
+ }
2373
+ },
2374
+ new CreatePullRequest()
2375
+ {
2376
+ Dependencies =
2377
+ [
2378
+ new ReportedDependency()
2379
+ {
2380
+ Name = "some-tool",
2381
+ Version = "2.0.1",
2382
+ Requirements =
2383
+ [
2384
+ new ReportedRequirement()
2385
+ {
2386
+ Requirement = "2.0.1",
2387
+ File = "/.config/dotnet-tools.json",
2388
+ Groups = ["dependencies"],
2389
+ Source = new()
2390
+ {
2391
+ SourceUrl = null,
2392
+ }
2393
+ }
2394
+ ],
2395
+ PreviousVersion = "2.0.0",
2396
+ PreviousRequirements =
2397
+ [
2398
+ new ReportedRequirement()
2399
+ {
2400
+ Requirement = "2.0.0",
2401
+ File = "/.config/dotnet-tools.json",
2402
+ Groups = ["dependencies"],
2403
+ }
2404
+ ],
2405
+ },
2406
+ new ReportedDependency()
2407
+ {
2408
+ Name = "Some.MSBuild.Sdk",
2409
+ Version = "1.0.1",
2410
+ Requirements =
2411
+ [
2412
+ new ReportedRequirement()
2413
+ {
2414
+ Requirement = "1.0.1",
2415
+ File = "/global.json",
2416
+ Groups = ["dependencies"],
2417
+ Source = new()
2418
+ {
2419
+ SourceUrl = null,
2420
+ }
2421
+ }
2422
+ ],
2423
+ PreviousVersion = "1.0.0",
2424
+ PreviousRequirements =
2425
+ [
2426
+ new ReportedRequirement()
2427
+ {
2428
+ Requirement = "1.0.0",
2429
+ File = "/global.json",
2430
+ Groups = ["dependencies"],
2431
+ }
2432
+ ],
2433
+ },
2434
+ ],
2435
+ UpdatedDependencyFiles =
2436
+ [
2437
+ new DependencyFile()
2438
+ {
2439
+ Name = "dotnet-tools.json",
2440
+ Directory = "/.config",
2441
+ Content = "dotnet-tools.json content UPDATED",
2442
+ },
2443
+ new DependencyFile()
2444
+ {
2445
+ Name = "global.json",
2446
+ Directory = "/",
2447
+ Content = "global.json content UPDATED",
2448
+ },
2449
+ ],
2450
+ BaseCommitSha = "TEST-COMMIT-SHA",
2451
+ CommitMessage = "TODO: message",
2452
+ PrTitle = "TODO: title",
2453
+ PrBody = "TODO: body",
2454
+ },
2455
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
2456
+ ]
2457
+ );
2458
+ }
2459
+
2052
2460
  private static async Task RunAsync(Job job, TestFile[] files, IDiscoveryWorker? discoveryWorker, IAnalyzeWorker? analyzeWorker, IUpdaterWorker? updaterWorker, RunResult expectedResult, object[] expectedApiMessages, MockNuGetPackage[]? packages = null, ExperimentsManager? experimentsManager = null, string? repoContentsPath = null)
2053
2461
  {
2054
2462
  // arrange