forked from loafle/openapi-generator-original
throw exception if username, password is not set in http auth in r client (#13035)
This commit is contained in:
@@ -308,6 +308,17 @@
|
||||
{{#isBasic}}
|
||||
{{#isBasicBasic}}
|
||||
# HTTP basic auth
|
||||
if (is.null(self$api_client$username) || is.null(self$api_client$password)) {
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop("username, password in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`.")
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = "username, password in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`.",
|
||||
.subclass = "ApiException",
|
||||
ApiException = ApiException$new(status = 0,
|
||||
reason = "username, password in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`."))
|
||||
{{/useRlangExceptionHandling}}
|
||||
}
|
||||
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
|
||||
@@ -586,6 +586,12 @@ PetApi <- R6::R6Class(
|
||||
|
||||
local_var_url_path <- "/pet"
|
||||
# HTTP basic auth
|
||||
if (is.null(self$api_client$username) || is.null(self$api_client$password)) {
|
||||
rlang::abort(message = "username, password in `api_client` must be set for authentication in the endpoint `AddPet`.",
|
||||
.subclass = "ApiException",
|
||||
ApiException = ApiException$new(status = 0,
|
||||
reason = "username, password in `api_client` must be set for authentication in the endpoint `AddPet`."))
|
||||
}
|
||||
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
||||
|
||||
# The Accept request HTTP header
|
||||
|
||||
@@ -11,8 +11,9 @@ pet <- Pet$new("name_test",
|
||||
),
|
||||
status = "available"
|
||||
)
|
||||
pet_api$api_client$username <- "username123"
|
||||
pet_api$api_client$password <- "password123"
|
||||
|
||||
pet_api$api_client$username <- ""
|
||||
pet_api$api_client$password <- ""
|
||||
result <- pet_api$AddPet(pet)
|
||||
|
||||
test_that("Test toJSONString", {
|
||||
|
||||
Reference in New Issue
Block a user