Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Paket.Core.preview3/Paket.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<Compile Include="$(PaketCoreSourcesDir)\Common\Utils.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Common\Xml.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Common\ProcessHelper.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Common\NetUtils.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Versioning\SemVer.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Versioning\VersionRange.fs" />
<Compile Include="$(PaketCoreSourcesDir)\Versioning\FrameworkHandling.fs" />
Expand Down
588 changes: 588 additions & 0 deletions src/Paket.Core/Common/NetUtils.fs

Large diffs are not rendered by default.

574 changes: 2 additions & 572 deletions src/Paket.Core/Common/Utils.fs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Paket.Core/Dependencies/NuGet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ let DownloadLicense(root,force,packageName:PackageName,version:SemVerInfo,licens
#endif

request.UseDefaultCredentials <- true
request.Proxy <- Utils.getDefaultProxyFor licenseUrl
request.Proxy <- NetUtils.getDefaultProxyFor licenseUrl
use _ = Profile.startCategory Profile.Category.NuGetRequest
use! httpResponse = request.AsyncGetResponse()

Expand Down Expand Up @@ -763,7 +763,7 @@ let private downloadAndExtractPackage(alternativeProjectRoot, root, isLocalOverr
else
request.UseDefaultCredentials <- true

request.Proxy <- Utils.getDefaultProxyFor source.Url
request.Proxy <- NetUtils.getDefaultProxyFor source.Url
use! httpResponse = request.AsyncGetResponse()

use httpResponseStream = httpResponse.GetResponseStream()
Expand Down
8 changes: 4 additions & 4 deletions src/Paket.Core/Dependencies/RemoteUpload.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ let Push maxTrials url apiKey clientVersion packageFileName =
| None ->
tracefnVerbose "No authorization found in config file."
let uploadWithHttpClient () =
let client = Utils.createHttpClient(url, authOpt)
Utils.addHeader client "X-NuGet-ApiKey" apiKey
Utils.addHeader client "X-NuGet-Client-Version" clientVersion // see https://github.com/NuGet/NuGetGallery/issues/4315
let client = NetUtils.createHttpClient(url, authOpt)
NetUtils.addHeader client "X-NuGet-ApiKey" apiKey
NetUtils.addHeader client "X-NuGet-Client-Version" clientVersion // see https://github.com/NuGet/NuGetGallery/issues/4315

client.UploadFileAsMultipart (new Uri(url)) packageFileName
|> ignore
Expand All @@ -63,7 +63,7 @@ let Push maxTrials url apiKey clientVersion packageFileName =
if useHttpClient then
uploadWithHttpClient()
else
let client = Utils.createWebClient(url, authOpt)
let client = NetUtils.createWebClient(url, authOpt)
client.Headers.Add ("X-NuGet-ApiKey", apiKey)
client.Headers.Add ("X-NuGet-Protocol-Version", Constants.NuGetProtocolVersion) // see https://github.com/NuGet/Announcements/issues/10

Expand Down
1 change: 1 addition & 0 deletions src/Paket.Core/Paket.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<Compile Include="Common\Utils.fs" />
<Compile Include="Common\Xml.fs" />
<Compile Include="Common\ProcessHelper.fs" />
<Compile Include="Common\NetUtils.fs" />
<Compile Include="Versioning\SemVer.fs" />
<Compile Include="Versioning\VersionRange.fs" />
<Compile Include="Versioning\FrameworkHandling.fs" />
Expand Down
4 changes: 2 additions & 2 deletions src/Paket.Core/Versioning/ConfigFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ let getAuthFromNode (node : XmlNode) =
let authType =
match node.Attributes.["authType"] with
| null -> AuthType.Basic
| n -> n.Value |> Utils.parseAuthTypeString
| n -> n.Value |> NetUtils.parseAuthTypeString

let salt = node.Attributes.["salt"].Value
Credentials ({Username = username; Password = Decrypt salt password; Type = authType})
Expand All @@ -132,7 +132,7 @@ let private setToken (token : string) (node : XmlElement) =

/// Check if the provided credentials for a specific source are correct
let checkCredentials(url, cred) =
let client = Utils.createHttpClient(url,cred)
let client = NetUtils.createHttpClient(url,cred)
try
client.DownloadData (Uri url) |> ignore
true
Expand Down
18 changes: 13 additions & 5 deletions src/Paket.Core/Versioning/FrameworkHandling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1321,22 +1321,30 @@ module SupportCalculation =
|> List.map (fun p -> p, getSupportedPortables p)
|> ofSeq

let mutable private supportMap = optimizeSupportMap (createInitialSupportMap())
let mutable private supportMap: SupportMap option = None

let private getSupportMap () =
match supportMap with
| Some supportMap ->
supportMap
| None ->
supportMap <- Some (optimizeSupportMap (createInitialSupportMap()))
supportMap.Value

let getSupportedPreCalculated (p:PortableProfileType) =
match supportMap.TryGetValue p with
match getSupportMap().TryGetValue p with
| true, v -> v
| _ ->
match p with
| UnsupportedProfile tfs ->
match supportMap.TryGetValue p with
match getSupportMap().TryGetValue p with
| true, v -> v
| _ ->
let clone = supportMap |> toSeq |> ofSeq
let clone = getSupportMap() |> toSeq |> ofSeq
clone.[p] <- getSupportedPortables p
let opt = optimizeSupportMap clone
let result = opt.[p]
supportMap <- opt
supportMap <- Some opt
result
| _ -> failwithf "Expected that default profiles are already created."

Expand Down
6 changes: 3 additions & 3 deletions src/Paket.Core/Versioning/PackageSources.fs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ let internal parseAuth(text:string, source) =

let authType =
if (authTypeRegex.IsMatch(text))
then authTypeRegex.Match(text).Groups.[1].Value |> Utils.parseAuthTypeString
else Utils.AuthType.Basic
then authTypeRegex.Match(text).Groups.[1].Value |> NetUtils.parseAuthTypeString
else NetUtils.AuthType.Basic

let auth =
match EnvironmentVariable.Create(username),
Expand Down Expand Up @@ -182,7 +182,7 @@ type PackageSource =

static member WarnIfNoConnection (source,_) =
let n url (auth:AuthProvider) =
use client = Utils.createHttpClient(url, auth.Retrieve true)
use client = NetUtils.createHttpClient(url, auth.Retrieve true)
try
client.DownloadData url |> ignore
with _ ->
Expand Down
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
<StartAction>Project</StartAction>
<StartArguments>install</StartArguments>
<StartWorkingDirectory>C:\temp\Gu.Reactive</StartWorkingDirectory>
<StartArguments>install -v</StartArguments>
<StartArguments>restore</StartArguments>
<StartWorkingDirectory>C:\proj\Paket</StartWorkingDirectory>
<StartWorkingDirectory>D:\temp\PaketTargetFrameworkRepro\</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\bookstore</StartWorkingDirectory>
<StartWorkingDirectory>C:\temp\paket-conflict\paket.conflict.app</StartWorkingDirectory>
<StartWorkingDirectory>D:\temp\i3032</StartWorkingDirectory>
<StartWorkingDirectory>E:\Projects\paket.test\</StartWorkingDirectory>
<StartWorkingDirectory>G:\Code\stidgen</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
Expand Down
8 changes: 4 additions & 4 deletions tests/Paket.Tests/DependenciesFile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ let ``should read config with encapsulated password source with no auth type spe
Url = "http://www.nuget.org/api/v2"
Authentication = AuthProvider.empty } ]
cfg.Groups.[Constants.MainDependencyGroup].Sources.Head.Auth.Retrieve true
|> shouldEqual (Some (Credentials{ Username = "tatü tata"; Password = "you got hacked!"; Type = Utils.AuthType.Basic}))
|> shouldEqual (Some (Credentials{ Username = "tatü tata"; Password = "you got hacked!"; Type = NetUtils.AuthType.Basic}))

let configWithPasswordWithAuthType = """
source http://www.nuget.org/api/v2 username: "tatü tata" password: "you got hacked!" authtype: "ntlm"
Expand All @@ -726,7 +726,7 @@ let ``should read config with encapsulated password source and auth type specifi
|> shouldEqual [
PackageSource.NuGetV2 {
Url = "http://www.nuget.org/api/v2"
Authentication = AuthProvider.ofUserPassword { Username = "tatü tata"; Password = "you got hacked!"; Type = Utils.AuthType.NTLM} } ]
Authentication = AuthProvider.ofUserPassword { Username = "tatü tata"; Password = "you got hacked!"; Type = NetUtils.AuthType.NTLM} } ]

let configWithPasswordInSingleQuotes = """
source http://www.nuget.org/api/v2 username: 'tatü tata' password: 'you got hacked!'
Expand Down Expand Up @@ -758,7 +758,7 @@ let ``should read config with password in env variable``() =
Url = "http://www.nuget.org/api/v2"
Authentication = AuthProvider.empty} ]
cfg.Groups.[Constants.MainDependencyGroup].Sources.Head.Auth.Retrieve true
|> shouldEqual (Some (Credentials{ Username = "user XYZ"; Password = "pw Love"; Type = Utils.AuthType.Basic}))
|> shouldEqual (Some (Credentials{ Username = "user XYZ"; Password = "pw Love"; Type = NetUtils.AuthType.Basic}))

let configWithPasswordInEnvVariableAndAuthType = """
source http://www.nuget.org/api/v2 username: "%FEED_USERNAME%" password: "%FEED_PASSWORD%" authtype: "nTlM"
Expand All @@ -777,7 +777,7 @@ let ``should read config with password in env variable and auth type specified``
Url = "http://www.nuget.org/api/v2"
Authentication = AuthProvider.empty } ]
cfg.Groups.[Constants.MainDependencyGroup].Sources.Head.Auth.Retrieve true
|> shouldEqual (Some (Credentials{ Username = "user XYZ"; Password = "pw Love"; Type = Utils.AuthType.NTLM}))
|> shouldEqual (Some (Credentials{ Username = "user XYZ"; Password = "pw Love"; Type = NetUtils.AuthType.NTLM}))

let configWithExplicitVersions = """
source "http://www.nuget.org/api/v2"
Expand Down
4 changes: 2 additions & 2 deletions tests/Paket.Tests/NuGetConfig/NuGetConfigSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let ``can detect encrypted passwords in nuget.config``() =
|> shouldEqual
{ PackageSources =
[ "https://www.nuget.org/api/v2/", ("https://www.nuget.org/api/v2/",None)
"tc", ("https://tc/httpAuth/app/nuget/v1/FeedService.svc/", Some(Credentials{Username = "notty"; Password = "secret"; Type = Utils.AuthType.Basic})) ]
"tc", ("https://tc/httpAuth/app/nuget/v1/FeedService.svc/", Some(Credentials{Username = "notty"; Password = "secret"; Type = NetUtils.AuthType.Basic})) ]
|> Map.ofList
PackageRestoreEnabled = false
PackageRestoreAutomatic = false }
Expand All @@ -67,7 +67,7 @@ let ``can detect cleartextpasswords in nuget.config``() =
|> shouldEqual
{ PackageSources =
[ "https://www.nuget.org/api/v2/", ("https://www.nuget.org/api/v2/",None)
"somewhere", ("https://nuget/somewhere/",Some (Credentials{Username ="myUser"; Password = "myPassword"; Type = Utils.AuthType.Basic})) ]
"somewhere", ("https://nuget/somewhere/",Some (Credentials{Username ="myUser"; Password = "myPassword"; Type = NetUtils.AuthType.Basic})) ]
|> Map.ofList
PackageRestoreEnabled = false
PackageRestoreAutomatic = false }
Expand Down
4 changes: 2 additions & 2 deletions tests/Paket.Tests/Versioning/ConfigFileSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let ``get username, password, and auth type from node``() =
node.SetAttribute("salt", salt)
node.SetAttribute("authType", "ntlm")
// Act
let (Credentials{Username = username; Password = password; Type = Utils.AuthType.NTLM}) = getAuthFromNode node
let (Credentials{Username = username; Password = password; Type = NetUtils.AuthType.NTLM}) = getAuthFromNode node

// Assert
username |> shouldEqual "demo-user"
Expand All @@ -57,7 +57,7 @@ let ``get username and password from node without auth type``() =
node.SetAttribute("password", password)
node.SetAttribute("salt", salt)
// Act
let (Credentials{Username = username; Password = password; Type = Utils.AuthType.Basic}) = getAuthFromNode node
let (Credentials{Username = username; Password = password; Type = NetUtils.AuthType.Basic}) = getAuthFromNode node

// Assert
username |> shouldEqual "demo-user"
Expand Down