fix: Apply black formatting to resolve CI formatting issues
Some checks failed
CI / test (3.10) (push) Failing after 1m21s
CI / test (3.11) (push) Failing after 1m19s
CI / test (3.9) (push) Failing after 1m22s
CI / lint (push) Failing after 43s

This commit is contained in:
CI Bot
2026-02-06 07:56:02 +00:00
parent 123a4f7d1d
commit d369d3b1f8
8 changed files with 75 additions and 39 deletions

View File

@@ -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 ""