mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-20 01:07:04 +00:00
[Java][resttemplate] Add test for bearer auth (#17081)
* add bearer auth API to echo-api * run generate-samples.sh * add resttemplate echo-api sample * add bearer auth test * remove @Ignore
This commit is contained in:
@@ -76,3 +76,71 @@ function Test-AuthHttpBasic {
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
To test HTTP bearer authentication
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
No description available.
|
||||
|
||||
.PARAMETER WithHttpInfo
|
||||
|
||||
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
|
||||
|
||||
.OUTPUTS
|
||||
|
||||
String
|
||||
#>
|
||||
function Test-AuthHttpBearer {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Switch]
|
||||
$WithHttpInfo
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: Test-AuthHttpBearer' | Write-Debug
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$LocalVarAccepts = @()
|
||||
$LocalVarContentTypes = @()
|
||||
$LocalVarQueryParameters = @{}
|
||||
$LocalVarHeaderParameters = @{}
|
||||
$LocalVarFormParameters = @{}
|
||||
$LocalVarPathParameters = @{}
|
||||
$LocalVarCookieParameters = @{}
|
||||
$LocalVarBodyParameter = $null
|
||||
|
||||
$Configuration = Get-Configuration
|
||||
# HTTP header 'Accept' (if needed)
|
||||
$LocalVarAccepts = @('text/plain')
|
||||
|
||||
$LocalVarUri = '/auth/http/bearer'
|
||||
|
||||
if ($Configuration["AccessToken"]) {
|
||||
$LocalVarHeaderParameters['Authorization'] = "Bearer " + $Configuration["AccessToken"]
|
||||
Write-Verbose ("Using Bearer authentication in {0}" -f $MyInvocation.MyCommand)
|
||||
}
|
||||
|
||||
$LocalVarResult = Invoke-ApiClient -Method 'POST' `
|
||||
-Uri $LocalVarUri `
|
||||
-Accepts $LocalVarAccepts `
|
||||
-ContentTypes $LocalVarContentTypes `
|
||||
-Body $LocalVarBodyParameter `
|
||||
-HeaderParameters $LocalVarHeaderParameters `
|
||||
-QueryParameters $LocalVarQueryParameters `
|
||||
-FormParameters $LocalVarFormParameters `
|
||||
-CookieParameters $LocalVarCookieParameters `
|
||||
-ReturnType "String" `
|
||||
-IsBodyNullable $false
|
||||
|
||||
if ($WithHttpInfo.IsPresent) {
|
||||
return $LocalVarResult
|
||||
} else {
|
||||
return $LocalVarResult["Response"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user