diff --git a/src/Paket.Core/NuGetV2.fs b/src/Paket.Core/NuGetV2.fs index cf96e3cd12..7902b31cfa 100644 --- a/src/Paket.Core/NuGetV2.fs +++ b/src/Paket.Core/NuGetV2.fs @@ -34,9 +34,9 @@ type NugetPackageCache = Unlisted : bool DownloadUrl : string} -let rec private followODataLink auth url = +let rec private followODataLink getUrlContents url = async { - let! raw = getFromUrl (auth, url) + let! raw = getUrlContents url let doc = XmlDocument() doc.LoadXml raw let feed = @@ -44,41 +44,41 @@ let rec private followODataLink auth url = | Some node -> node | None -> failwithf "unable to parse data from %s" url - let readEntryVersion = optGetNode "properties" >> optGetNode "Version" + let readEntryVersion = Some + >> optGetNode "properties" + >> optGetNode "Version" + >> Option.map (fun node -> node.InnerText) - let entriesVersions = - feed - |> getNodes "entry" - |> List.choose (fun entry -> Some entry |> readEntryVersion |> Option.map (fun node -> node.InnerText)) + let entriesVersions = feed |> getNodes "entry" |> List.choose readEntryVersion - let linksVersions = + let! linksVersions = feed |> getNodes "link" |> List.filter (fun node -> node |> getAttribute "rel" = Some "next") |> List.choose (getAttribute "href") - |> List.map (followODataLink auth) + |> List.map (followODataLink getUrlContents) |> Async.Parallel - |> Async.RunSynchronously - |> Seq.concat return - entriesVersions - |> Seq.append linksVersions + linksVersions + |> Seq.collect id + |> Seq.append entriesVersions } /// Gets versions of the given package via OData via /Packages?$filter=Id eq 'packageId' -let getAllVersionsFromNugetODataWithFilter (auth, nugetURL, package) = +let getAllVersionsFromNugetODataWithFilter (getUrlContents, nugetURL, package) = // we cannot cache this - followODataLink auth (sprintf "%s/Packages?$filter=Id eq '%s'" nugetURL package) + let url = sprintf "%s/Packages?$filter=Id eq '%s'" nugetURL package + followODataLink getUrlContents url /// Gets versions of the given package via OData via /FindPackagesById()?id='packageId'. -let getAllVersionsFromNugetOData (auth, nugetURL, package) = +let getAllVersionsFromNugetOData (getUrlContents, nugetURL, package) = async { // we cannot cache this try let url = sprintf "%s/FindPackagesById()?id='%s'" nugetURL package - return! followODataLink auth url - with _ -> return! getAllVersionsFromNugetODataWithFilter (auth, nugetURL, package) + return! followODataLink getUrlContents url + with _ -> return! getAllVersionsFromNugetODataWithFilter (getUrlContents, nugetURL, package) } /// Gets all versions no. of the given package. @@ -86,15 +86,16 @@ let getAllVersionsFromNuGet2(auth,nugetURL,package) = // we cannot cache this async { let! raw = safeGetFromUrl(auth,sprintf "%s/package-versions/%s?includePrerelease=true" nugetURL package) + let getUrlContents url = getFromUrl(auth, url) match raw with - | None -> let! result = getAllVersionsFromNugetOData(auth,nugetURL, package) + | None -> let! result = getAllVersionsFromNugetOData(getUrlContents, nugetURL, package) return result | Some data -> try try let result = JsonConvert.DeserializeObject(data) |> Array.toSeq return result - with _ -> let! result = getAllVersionsFromNugetOData(auth,nugetURL, package) + with _ -> let! result = getAllVersionsFromNugetOData(getUrlContents, nugetURL, package) return result with exn -> return! failwithf "Could not get data from %s for package %s.%s Message: %s" nugetURL package diff --git a/tests/Paket.Tests/NuGetOData/NUnit.xml b/tests/Paket.Tests/NuGetOData/NUnit.xml new file mode 100644 index 0000000000..301f635803 --- /dev/null +++ b/tests/Paket.Tests/NuGetOData/NUnit.xml @@ -0,0 +1,533 @@ + + + https://www.nuget.org/api/v2/FindPackagesById + FindPackagesById + 2014-11-26T22:18:41Z + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='2.5.10.11092') + + + NUnit + NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.5, is the sixth major release of this xUnit based unit testing tool for Microsoft .NET. + 2014-11-26T22:09:15Z + + Charlie Poole + + + + + 2.5.10.11092 + 2.5.10.11092 + + 2011-04-25T20:20:32.973 + + NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.5, is the sixth major release of this xUnit based unit testing tool for Microsoft .NET. + 1577585 + https://www.nuget.org/packages/NUnit/2.5.10.11092 + + false + false + false + + 2011-04-25T20:20:34.397 + v2YKO25a8nnqunCr/XSV4LrCO3/86NV8QkA94Upkjgzg09kxTXzfSAFeEY1VIS+FfRvbw5cwVatoRvzFG6Px5A== + SHA512 + 824211 + + https://www.nuget.org/package/ReportAbuse/NUnit/2.5.10.11092 + + false + + NUnit + 179984 + + + + + + + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='2.5.7.10213') + + + NUnit + NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.5, is the sixth major release of this xUnit based unit testing tool for Microsoft .NET. + 2014-11-26T21:59:06Z + + Charlie Poole + + + + + 2.5.7.10213 + 2.5.7.10213 + + 2011-01-07T07:57:54.87 + + NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.5, is the sixth major release of this xUnit based unit testing tool for Microsoft .NET. + 1577585 + https://www.nuget.org/packages/NUnit/2.5.7.10213 + + false + false + false + + 2011-01-07T07:57:55.387 + 4aEVHJ3K6SRvmnUn630f6LMy6wfM5tZyMhSSAcMrOs2EspiwI0wsGtTQkFWizqjhNsO+fn0I/ravWZAAVfXpqg== + SHA512 + 763203 + + https://www.nuget.org/package/ReportAbuse/NUnit/2.5.7.10213 + + false + + NUnit + 12897 + + + + + + + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='2.5.9.10348') + + + NUnit + NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.5, is the sixth major release of this xUnit based unit testing tool for Microsoft .NET. + 2014-11-26T12:01:59Z + + Charlie Poole + + + + + 2.5.9.10348 + 2.5.9.10348 + + 2011-02-09T07:26:20.63 + + NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.5, is the sixth major release of this xUnit based unit testing tool for Microsoft .NET. + 1577585 + https://www.nuget.org/packages/NUnit/2.5.9.10348 + + false + false + false + + 2011-02-09T07:26:34.347 + J04Xy1Bj89NBmzhpKfZY714fy21p1Ehe6bC+YIZThR48VVw9/FCronTfCHCjSc4Nl5Ll19S2Z37buEMruv1rjQ== + SHA512 + 766139 + + https://www.nuget.org/package/ReportAbuse/NUnit/2.5.9.10348 + + false + + NUnit + 19500 + + + + + + + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='2.6.0.12051') + + + NUnit + NUnit is a unit-testing framework for all .Net languages with a strong TDD focus. + 2014-11-26T22:14:18Z + + Charlie Poole + + + + + 2.6.0.12051 + 2.6.0.12051 + + 2012-02-23T06:33:08.693 + + + NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. A number of runners, both from the NUnit project and by third parties, are able to execute NUnit tests. + + Version 2.6 is the seventh major release of this well-known and well-tested programming tool. + + This package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + 1577585 + https://www.nuget.org/packages/NUnit/2.6.0.12051 + http://nunit.org/nuget/nunit_32x32.png + false + false + false + + 1900-01-01T00:00:00 + 8poz2ckNXT8oGGBJeuEljiQj6wQllx6HTvsBY/XUHUfnYLscIqVidJpDIPgOTmuVEBQOpeXyejHxwReBD7M6gw== + SHA512 + 87290 + http://nunit.org/ + https://www.nuget.org/package/ReportAbuse/NUnit/2.6.0.12051 + + Version 2.6 is the seventh major release of NUnit. + + Unlike earlier versions, this package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + The nunit.mocks assembly is now provided by the NUnit.Mocks package. The pnunit.framework assembly is provided by the pNUnit package. + + false + test testing tdd framework fluent assert theory plugin addin + NUnit + 2063 + + + http://nunit.org/nuget/license.html + Zlib + + + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='2.6.0.12054') + + + NUnit + NUnit is a unit-testing framework for all .Net languages with a strong TDD focus. + 2014-11-26T22:14:18Z + + Charlie Poole + + + + + 2.6.0.12054 + 2.6.0.12054 + + 2012-02-24T04:03:05.29 + + + NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. A number of runners, both from the NUnit project and by third parties, are able to execute NUnit tests. + + Version 2.6 is the seventh major release of this well-known and well-tested programming tool. + + This package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + 1577585 + https://www.nuget.org/packages/NUnit/2.6.0.12054 + http://nunit.org/nuget/nunit_32x32.png + false + false + false + + 2012-02-24T04:03:05.29 + kGmOtt6nOjjrpEbN2D7fAI0HmpLNJsXt/zJaxFZguwCRkJirw5KViSZgj41N1F8lh46JVlphcaZgJFoihJlBbA== + SHA512 + 93979 + http://nunit.org/ + https://www.nuget.org/package/ReportAbuse/NUnit/2.6.0.12054 + + Version 2.6 is the seventh major release of NUnit. + + Unlike earlier versions, this package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + The nunit.mocks assembly is now provided by the NUnit.Mocks package. The pnunit.framework assembly is provided by the pNUnit package. + + false + test testing tdd framework fluent assert theory plugin addin + NUnit + 172379 + + + http://nunit.org/nuget/license.html + Zlib + + + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='2.6.1') + + + NUnit + NUnit is a unit-testing framework for all .Net languages with a strong TDD focus. + 2014-11-26T21:28:46Z + + Charlie Poole + + + + + 2.6.1 + 2.6.1 + + 2012-08-05T03:08:26.06 + + + NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. A number of runners, both from the NUnit project and by third parties, are able to execute NUnit tests. + + Version 2.6 is the seventh major release of this well-known and well-tested programming tool. + + This package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + 1577585 + https://www.nuget.org/packages/NUnit/2.6.1 + http://nunit.org/nuget/nunit_32x32.png + false + false + false + + 2012-08-05T03:08:28.403 + byiyAOxTyUpc9sTasSxdDsGGutZ+jMRclWJgwq9GURSmCFvPuqD2wDTUiJGdH+pTCIloqZBPDGl9EkxGr8Id/Q== + SHA512 + 94201 + http://nunit.org/ + https://www.nuget.org/package/ReportAbuse/NUnit/2.6.1 + + Version 2.6 is the seventh major release of NUnit. + + Unlike earlier versions, this package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + The nunit.mocks assembly is now provided by the NUnit.Mocks package. The pnunit.framework assembly is provided by the pNUnit package. + + false + test testing tdd framework fluent assert theory plugin addin + NUnit + 126150 + + + http://nunit.org/nuget/license.html + Zlib + + + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='2.6.2') + + + NUnit + NUnit is a unit-testing framework for all .Net languages with a strong TDD focus. + 2014-11-26T22:14:18Z + + Charlie Poole + + + + + 2.6.2 + 2.6.2 + + 2012-10-23T15:37:47.517 + + + NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. A number of runners, both from the NUnit project and by third parties, are able to execute NUnit tests. + + Version 2.6 is the seventh major release of this well-known and well-tested programming tool. + + This package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + 1577585 + https://www.nuget.org/packages/NUnit/2.6.2 + http://nunit.org/nuget/nunit_32x32.png + false + false + false + en-US + 2012-10-23T15:37:48 + bWEVvuPgy4ci3LL4x3nXmUeY4VTSFsXSbyAAalXCFFpQHXbEwfUtImcqA+4guoX1u2/52vnv9i7nbrgst0khSA== + SHA512 + 94702 + http://nunit.org/ + https://www.nuget.org/package/ReportAbuse/NUnit/2.6.2 + + Version 2.6 is the seventh major release of NUnit. + + Unlike earlier versions, this package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + The nunit.mocks assembly is now provided by the NUnit.Mocks package. The pnunit.framework assembly is provided by the pNUnit package. + + false + test testing tdd framework fluent assert theory plugin addin + NUnit + 505249 + + + http://nunit.org/nuget/license.html + Zlib + + + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='2.6.3') + + + NUnit + NUnit is a unit-testing framework for all .Net languages with a strong TDD focus. + 2014-11-26T22:14:18Z + + Charlie Poole + + + + + 2.6.3 + 2.6.3 + + 2013-10-11T01:52:53.4 + + + NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. A number of runners, both from the NUnit project and by third parties, are able to execute NUnit tests. + + Version 2.6 is the seventh major release of this well-known and well-tested programming tool. + + This package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + 1577585 + https://www.nuget.org/packages/NUnit/2.6.3 + http://nunit.org/nuget/nunit_32x32.png + true + false + false + en-US + 2013-10-11T01:52:53.417 + zGYW/N4U8H1Y6Xr6aGQZgaDtfpRJSlbx7A9Fg3WNUV3EKEUe1LwjnHw9NH81GVWYzKlOBLZmFp/q90YJwT2vzQ== + SHA512 + 98508 + http://nunit.org/ + https://www.nuget.org/package/ReportAbuse/NUnit/2.6.3 + + Version 2.6 is the seventh major release of NUnit. + + Unlike earlier versions, this package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. + + The nunit.mocks assembly is now provided by the NUnit.Mocks package. The pnunit.framework assembly is provided by the pNUnit package. + + false + nunit test testing tdd framework fluent assert theory plugin addin + NUnit + 555866 + + + http://nunit.org/nuget/license.html + Zlib + + + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='3.0.0-alpha') + + + NUnit + NUnit is a unit-testing framework for all .Net languages with a strong TDD focus. + 2014-11-26T17:10:39Z + + Charlie Poole + + + + + 3.0.0-alpha + 3.0.0-alpha + Copyright (c) 2014 Charlie Poole + 2014-09-23T03:11:33.413 + Microsoft.Bcl.Async:1.0.165:net40|::net45 + + NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. A number of runners, both from the NUnit project and by third parties, are able to execute NUnit tests. + + + This package includes the NUnit 3.0 framework assembly, which is referenced by your tests. You will need to install version 3.0 of the nunit-console program or a third-party runner that supports NUnit 3.0 in order to execute tests. Runners intended for use with NUnit 2.x will not run 3.0 tests correctly. + + + This is an alpha release and is not intended for production use. + + 1577585 + https://www.nuget.org/packages/NUnit/3.0.0-alpha + http://nunit.org/nuget/nunit_32x32.png + false + false + true + en-US + 2014-09-23T03:11:33.43 + 9/UBJEHOQoSTTw9u9/tnq35qiEefLpJBr5Jg9R8ljM5SufP6fLsacKGcQp3FGC6XYU18mKSQsdUZR7ZPjauwUA== + SHA512 + 740601 + http://nunit.org/ + https://www.nuget.org/package/ReportAbuse/NUnit/3.0.0-alpha + + This package includes the NUnit 3.0 framework assembly, which is referenced by your tests. You will need to install version 3.0 of the nunit-console program or a third-party runner that supports NUnit 3.0 in order to execute tests. Runners intended for use with NUnit 2.x will not run 3.0 tests correctly. + + + This is an alpha release and is not intended for production use. + + false + nunit test testing tdd framework fluent assert theory plugin addin + NUnit Version 3 + 2298 + + + http://nunit.org/nuget/nunit3-license.txt + + + + + + https://www.nuget.org/api/v2/Packages(Id='NUnit',Version='3.0.0-alpha-2') + + + NUnit + NUnit is a unit-testing framework for all .Net languages with a strong TDD focus. + 2014-11-26T21:18:38Z + + Charlie Poole + + + + + 3.0.0-alpha-2 + 3.0.0-alpha-2 + Copyright (c) 2014 Charlie Poole + 2014-11-03T06:24:59.183 + Microsoft.Bcl.Async:1.0.165:net40|::net45 + + NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. A number of runners, both from the NUnit project and by third parties, are able to execute NUnit tests. + + + This package includes the NUnit 3.0 framework assembly, which is referenced by your tests. You will need to install version 3.0 of the nunit-console program or a third-party runner that supports NUnit 3.0 in order to execute tests. Runners intended for use with NUnit 2.x will not run 3.0 tests correctly. + + + This is an alpha release and is not intended for production use. + + 1577585 + https://www.nuget.org/packages/NUnit/3.0.0-alpha-2 + http://nunit.org/nuget/nunit_32x32.png + false + true + true + en-US + 2014-11-03T06:24:59.217 + hfSLpLTZtzpT6+CSUs8T6ELKo4Qab5gWVtwPUNvE7Cet/LzgFjrj6sI0dBIyWq7eOtCH2V/cFrrVaMMMXCRnDg== + SHA512 + 738442 + http://nunit.org/ + https://www.nuget.org/package/ReportAbuse/NUnit/3.0.0-alpha-2 + + This package includes the NUnit 3.0 framework assembly, which is referenced by your tests. You will need to install version 3.0 of the nunit-console program or a third-party runner that supports NUnit 3.0 in order to execute tests. Runners intended for use with NUnit 2.x will not run 3.0 tests correctly. + + + This is an alpha release and is not intended for production use. + + false + nunit test testing tdd framework fluent assert theory plugin addin + NUnit Version 3 + 1199 + + + http://nunit.org/nuget/nunit3-license.txt + + + + + \ No newline at end of file diff --git a/tests/Paket.Tests/NuGetOData/ODataSpecs.fs b/tests/Paket.Tests/NuGetOData/ODataSpecs.fs index d813255576..0945ed9332 100644 --- a/tests/Paket.Tests/NuGetOData/ODataSpecs.fs +++ b/tests/Paket.Tests/NuGetOData/ODataSpecs.fs @@ -65,4 +65,21 @@ let ``can detect explicit dependencies for ReadOnlyCollectionExtensions``() = [] let ``can calculate v3 path``() = calculateNuGet3Path "https://nuget.org/api/v2" |> shouldEqual (Some "http://preview.nuget.org/ver3-preview/index.json") - calculateNuGet3Path "http://nuget.org/api/v2" |> shouldEqual (Some "http://preview.nuget.org/ver3-preview/index.json") \ No newline at end of file + calculateNuGet3Path "http://nuget.org/api/v2" |> shouldEqual (Some "http://preview.nuget.org/ver3-preview/index.json") + +[] +let ``can read all versions from single page with multiple entries``() = + let getUrlContentsStub _ = async { return File.ReadAllText "NuGetOData/NUnit.xml" } + + let versions = getAllVersionsFromNugetOData(getUrlContentsStub, fakeUrl, "NUnit") + |> Async.RunSynchronously + + versions |> shouldContain "3.0.0-alpha-2" + versions |> shouldContain "3.0.0-alpha" + versions |> shouldContain "2.6.3" + versions |> shouldContain "2.6.2" + versions |> shouldContain "2.6.1" + versions |> shouldContain "2.6.0.12054" + versions |> shouldContain "2.5.10.11092" + versions |> shouldContain "2.5.9.10348" + versions |> shouldContain "2.5.7.10213" diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index 7ebfd23a1e..da24d80bc9 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -64,13 +64,67 @@ --> + + + + + ..\..\packages\FSharp.Core.Microsoft.Signed\lib\net40\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core.Microsoft.Signed\lib\portable-net45+netcore45+MonoAndroid1+MonoTouch1\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core.Microsoft.Signed\lib\net45\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core.Microsoft.Signed\lib\portable-net45+sl5+netcore45+MonoAndroid1+MonoTouch1\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core.Microsoft.Signed\lib\portable-net45+netcore45+wp8+MonoAndroid1+MonoTouch1\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core.Microsoft.Signed\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\FSharp.Core.dll + True + True + + + + True FsUnit.fs - - @@ -127,6 +181,9 @@ Always + + Always + Always @@ -213,64 +270,6 @@ True - - - - - - ..\..\packages\FSharp.Core.Microsoft.Signed\lib\net40\FSharp.Core.dll - True - True - - - - - - - ..\..\packages\FSharp.Core.Microsoft.Signed\lib\portable-net45+netcore45+MonoAndroid1+MonoTouch1\FSharp.Core.dll - True - True - - - - - - - ..\..\packages\FSharp.Core.Microsoft.Signed\lib\net45\FSharp.Core.dll - True - True - - - - - - - ..\..\packages\FSharp.Core.Microsoft.Signed\lib\portable-net45+sl5+netcore45+MonoAndroid1+MonoTouch1\FSharp.Core.dll - True - True - - - - - - - ..\..\packages\FSharp.Core.Microsoft.Signed\lib\portable-net45+netcore45+wp8+MonoAndroid1+MonoTouch1\FSharp.Core.dll - True - True - - - - - - - ..\..\packages\FSharp.Core.Microsoft.Signed\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\FSharp.Core.dll - True - True - - - - - ..\..\packages\NUnit\lib\nunit.framework.dll True