forked from loafle/openapi-generator-original
Add tests for http basic authentication in python client (#16488)
* add tests for http basic auth in python client * add new files
This commit is contained in:
@@ -19,6 +19,7 @@ src/main/java/org/openapitools/client/EncodingUtils.java
|
||||
src/main/java/org/openapitools/client/ServerConfiguration.java
|
||||
src/main/java/org/openapitools/client/ServerVariable.java
|
||||
src/main/java/org/openapitools/client/StringUtil.java
|
||||
src/main/java/org/openapitools/client/api/AuthApi.java
|
||||
src/main/java/org/openapitools/client/api/BodyApi.java
|
||||
src/main/java/org/openapitools/client/api/FormApi.java
|
||||
src/main/java/org/openapitools/client/api/HeaderApi.java
|
||||
|
||||
@@ -469,6 +469,23 @@ paths:
|
||||
- body
|
||||
x-content-type: multipart/form-data
|
||||
x-accepts: text/plain
|
||||
/auth/http/basic:
|
||||
post:
|
||||
description: To test HTTP basic authentication
|
||||
operationId: test/auth/http/basic
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
description: Successful operation
|
||||
security:
|
||||
- http_auth: []
|
||||
summary: To test HTTP basic authentication
|
||||
tags:
|
||||
- auth
|
||||
x-accepts: text/plain
|
||||
components:
|
||||
requestBodies:
|
||||
Pet:
|
||||
@@ -729,4 +746,8 @@ components:
|
||||
required:
|
||||
- files
|
||||
type: object
|
||||
securitySchemes:
|
||||
http_auth:
|
||||
scheme: basic
|
||||
type: http
|
||||
|
||||
|
||||
@@ -39,7 +39,15 @@ public class ApiClient {
|
||||
this();
|
||||
for(String authName : authNames) {
|
||||
log.log(Level.FINE, "Creating authentication {0}", authName);
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||
RequestInterceptor auth = null;
|
||||
if ("http_auth".equals(authName)) {
|
||||
auth = new HttpBasicAuth();
|
||||
} else {
|
||||
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
|
||||
}
|
||||
if (auth != null) {
|
||||
addAuthorization(authName, auth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.EncodingUtils;
|
||||
import org.openapitools.client.model.ApiResponse;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import feign.*;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public interface AuthApi extends ApiClient.Api {
|
||||
|
||||
|
||||
/**
|
||||
* To test HTTP basic authentication
|
||||
* To test HTTP basic authentication
|
||||
* @return String
|
||||
*/
|
||||
@RequestLine("POST /auth/http/basic")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
})
|
||||
String testAuthHttpBasic();
|
||||
|
||||
/**
|
||||
* To test HTTP basic authentication
|
||||
* Similar to <code>testAuthHttpBasic</code> but it also returns the http response headers .
|
||||
* To test HTTP basic authentication
|
||||
* @return A ApiResponse that wraps the response boyd and the http headers.
|
||||
*/
|
||||
@RequestLine("POST /auth/http/basic")
|
||||
@Headers({
|
||||
"Accept: text/plain",
|
||||
})
|
||||
ApiResponse<String> testAuthHttpBasicWithHttpInfo();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for AuthApi
|
||||
*/
|
||||
class AuthApiTest {
|
||||
|
||||
private AuthApi api;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
api = new ApiClient().buildClient(AuthApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To test HTTP basic authentication
|
||||
*
|
||||
* To test HTTP basic authentication
|
||||
*/
|
||||
@Test
|
||||
void testAuthHttpBasicTest() {
|
||||
// String response = api.testAuthHttpBasic();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user