Skip to content

Commit

Permalink
Adds configuration option to skip certificate check. Fixes a typo. Fi…
Browse files Browse the repository at this point in the history
…xes an issue which was restricting from cookie to get consumed (#5657)
  • Loading branch information
vvb authored Mar 23, 2020
1 parent 5549c1d commit 4de97a4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
$Configuration = Get-{{{apiNamePrefix}}}Configuration
$RequestUri = $Configuration["BaseUrl"] + $Uri
$SkipCertificateCheck = $Configuration["SkipCertificateCheck"]

# cookie parameters
foreach ($Parameter in $CookieParameters) {
if ($CookieParameters[$Parameter]) {
$HeaderParameters["Cookie"] = $CookieParameters[$Parameter]
foreach ($Parameter in $CookieParameters.GetEnumerator()) {
if ($Parameter.Name -eq "cookieAuth") {
$HeaderParameters["Cookie"] = $Parameter.Value
} else {
$HeaderParameters[$Parameter.Name] = $Parameter.Value
}
}
if ($CookieParametters -and $CookieParameters.Count -gt 1) {
if ($CookieParameters -and $CookieParameters.Count -gt 1) {
Write-Warning "Multipe cookie parameters found. Curently only the first one is supported/used"
}

Expand Down Expand Up @@ -80,11 +83,21 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
$RequestBody = $Body
}

$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
if ($SkipCertificateCheck -eq $true) {
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-SkipCertificateCheck
} else {
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop
}

return @{
Response = DeserializeResponse -Response $Response -ReturnType $ReturnType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function Get-{{apiNamePrefix}}Configuration {
$Configuration["ApiKeyPrefix"] = @{}
}

if (!$Configuration.containsKey("SkipCertificateCheck")) {
$Configuration["SkipCertificateCheck"] = $false
}

Return $Configuration

}
Expand All @@ -48,6 +52,7 @@ function Set-{{{apiNamePrefix}}}Configuration {
[AllowEmptyString()]
[string]$AccessToken,
[switch]$PassThru,
[bool]$SkipCertificateCheck,
[switch]$Force
)
Expand Down Expand Up @@ -80,6 +85,10 @@ function Set-{{{apiNamePrefix}}}Configuration {
If ($AccessToken) {
$Script:Configuration['AccessToken'] = $AccessToken
}

If ($SkipCertificateCheck) {
$Script:Configuration['SkipCertificateCheck'] = $SkipCertificateCheck
}
}
}

Expand Down

0 comments on commit 4de97a4

Please sign in to comment.