Files
WonderQ-Admin/tests/test_config.py
duanshuwen bac68842ef feat(auth): add wechat miniapp customer phone login
Implement Wechat Mini Program phone number login flow for end customers:
- add PhoneLoginIn Pydantic request schema
- create wechat.py module for Wechat API interactions and phone code exchange
- add customer JWT utilities and require_customer authentication dependency
- add new public API endpoints: /api/public/auth/phone-login and /api/public/auth/me
- add required environment config variables and update example .env
- add comprehensive test cases for the new auth flow and endpoints
2026-07-08 16:11:34 +08:00

28 lines
1.1 KiB
Python

from app.config import Settings
def test_oss_settings_are_loaded_from_prefixed_environment(monkeypatch):
monkeypatch.setenv("OSS_ACCESS_KEY_ID", "example-access-key-id")
monkeypatch.setenv("OSS_ACCESS_KEY_SECRET", "example-access-key-secret")
monkeypatch.setenv("OSS_ENDPOINT", "oss-cn-example.aliyuncs.com")
monkeypatch.setenv("OSS_BUCKET_NAME", "example-bucket")
settings = Settings(_env_file=None)
assert settings.oss_access_key_id == "example-access-key-id"
assert settings.oss_access_key_secret == "example-access-key-secret"
assert settings.oss_endpoint == "oss-cn-example.aliyuncs.com"
assert settings.oss_bucket_name == "example-bucket"
def test_wechat_miniapp_settings_are_loaded_from_environment(monkeypatch):
monkeypatch.setenv("WECHAT_MINIAPP_APPID", "wx-test-appid")
monkeypatch.setenv("WECHAT_MINIAPP_SECRET", "test-secret")
monkeypatch.setenv("CUSTOMER_JWT_EXPIRES_HOURS", "24")
settings = Settings(_env_file=None)
assert settings.wechat_miniapp_appid == "wx-test-appid"
assert settings.wechat_miniapp_secret == "test-secret"
assert settings.customer_jwt_expires_hours == 24