fix: Apply black formatting to resolve CI formatting issues
This commit is contained in:
@@ -8,6 +8,7 @@ from .exceptions import AuthConfigError, MissingSecuritySchemeError
|
||||
|
||||
class AuthType(str, Enum):
|
||||
"""Types of authentication."""
|
||||
|
||||
API_KEY = "apiKey"
|
||||
BEARER = "bearer"
|
||||
BASIC = "basic"
|
||||
@@ -131,6 +132,7 @@ class AuthConfig:
|
||||
return {"Authorization": f"{method['token_prefix']} {method['token']}"}
|
||||
elif method["type"] == AuthType.BASIC:
|
||||
import base64
|
||||
|
||||
credentials = f"{method['username']}:{method['password']}"
|
||||
encoded = base64.b64encode(credentials.encode()).decode()
|
||||
return {"Authorization": f"Basic {encoded}"}
|
||||
@@ -222,19 +224,19 @@ class AuthConfig:
|
||||
String containing pytest auth code.
|
||||
"""
|
||||
if method["type"] == AuthType.API_KEY:
|
||||
return f'''
|
||||
return f"""
|
||||
@pytest.fixture
|
||||
def api_key_headers():
|
||||
return {{"{method['header_name']}": "{method['api_key']}"}}
|
||||
'''
|
||||
"""
|
||||
elif method["type"] == AuthType.BEARER:
|
||||
return f'''
|
||||
return f"""
|
||||
@pytest.fixture
|
||||
def bearer_headers():
|
||||
return {{"Authorization": "{method['token_prefix']} {method['token']}"}}
|
||||
'''
|
||||
"""
|
||||
elif method["type"] == AuthType.BASIC:
|
||||
return f'''
|
||||
return f"""
|
||||
import base64
|
||||
|
||||
@pytest.fixture
|
||||
@@ -242,7 +244,7 @@ def basic_headers():
|
||||
credentials = f"{{"{method['username']}"}}:{{"{method['password']}"}}"
|
||||
encoded = base64.b64encode(credentials.encode()).decode()
|
||||
return {{"Authorization": f"Basic {{encoded}}"}}
|
||||
'''
|
||||
"""
|
||||
return ""
|
||||
|
||||
def _generate_jest_auth(self, method: Dict[str, Any]) -> str:
|
||||
@@ -255,24 +257,24 @@ def basic_headers():
|
||||
String containing Jest auth code.
|
||||
"""
|
||||
if method["type"] == AuthType.API_KEY:
|
||||
return f'''
|
||||
return f"""
|
||||
const getApiKeyHeaders = () => ({{
|
||||
"{method['header_name']}": process.env.API_KEY || "{method['api_key']}",
|
||||
}});
|
||||
'''
|
||||
"""
|
||||
elif method["type"] == AuthType.BEARER:
|
||||
return f'''
|
||||
return f"""
|
||||
const getBearerHeaders = () => ({{
|
||||
Authorization: `${{process.env.TOKEN_PREFIX || "{method['token_prefix']}"}} ${{process.env.TOKEN || "{method['token']}"}}`,
|
||||
}});
|
||||
'''
|
||||
"""
|
||||
elif method["type"] == AuthType.BASIC:
|
||||
return f'''
|
||||
return f"""
|
||||
const getBasicHeaders = () => {{
|
||||
const credentials = Buffer.from(`${{process.env.USERNAME || "{method['username']}"}}:${{process.env.PASSWORD || "{method['password']}"}}`).toString('base64');
|
||||
return {{ Authorization: `Basic ${{credentials}}` }};
|
||||
}};
|
||||
'''
|
||||
"""
|
||||
return ""
|
||||
|
||||
def _generate_go_auth(self, method: Dict[str, Any]) -> str:
|
||||
@@ -285,23 +287,23 @@ const getBasicHeaders = () => {{
|
||||
String containing Go auth code.
|
||||
"""
|
||||
if method["type"] == AuthType.API_KEY:
|
||||
return f'''
|
||||
return f"""
|
||||
func getAPIKeyHeaders() map[string]string {{
|
||||
return map[string]string{{
|
||||
"{method['header_name']}": os.Getenv("API_KEY"),
|
||||
}}
|
||||
}}
|
||||
'''
|
||||
"""
|
||||
elif method["type"] == AuthType.BEARER:
|
||||
return '''
|
||||
return """
|
||||
func getBearerHeaders() map[string]string {
|
||||
return map[string]string{
|
||||
"Authorization": fmt.Sprintf("%s %s", os.Getenv("TOKEN_PREFIX"), os.Getenv("TOKEN")),
|
||||
}
|
||||
}
|
||||
'''
|
||||
"""
|
||||
elif method["type"] == AuthType.BASIC:
|
||||
return '''
|
||||
return """
|
||||
func getBasicHeaders(username, password string) map[string]string {
|
||||
auth := username + ":" + password
|
||||
encoded := base64.StdEncoding.EncodeToString([]byte(auth))
|
||||
@@ -309,5 +311,5 @@ func getBasicHeaders(username, password string) map[string]string {
|
||||
"Authorization": "Basic " + encoded,
|
||||
}
|
||||
}
|
||||
'''
|
||||
"""
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user