forked from loafle/openapi-generator-original
[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:
@@ -75,5 +75,62 @@ module OpenapiClient
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# To test HTTP bearer authentication
|
||||
# To test HTTP bearer authentication
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [String]
|
||||
def test_auth_http_bearer(opts = {})
|
||||
data, _status_code, _headers = test_auth_http_bearer_with_http_info(opts)
|
||||
data
|
||||
end
|
||||
|
||||
# To test HTTP bearer authentication
|
||||
# To test HTTP bearer authentication
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
|
||||
def test_auth_http_bearer_with_http_info(opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: AuthApi.test_auth_http_bearer ...'
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/auth/http/bearer'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['text/plain'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:debug_body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:debug_return_type] || 'String'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:debug_auth_names] || ['http_bearer_auth']
|
||||
|
||||
new_options = opts.merge(
|
||||
:operation => :"AuthApi.test_auth_http_bearer",
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: AuthApi#test_auth_http_bearer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -209,6 +209,13 @@ module OpenapiClient
|
||||
key: 'Authorization',
|
||||
value: basic_auth_token
|
||||
},
|
||||
'http_bearer_auth' =>
|
||||
{
|
||||
type: 'bearer',
|
||||
in: 'header',
|
||||
key: 'Authorization',
|
||||
value: "Bearer #{access_token_with_refresh}"
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user