mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-07 04:46:11 +00:00
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:
@@ -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