AutoGPT/autogpt_platform/backend/test/sdk
Swifty 83f96b75c7
fix(backend): Ensure we only present working auth options on blocks (#10454)
To allow for a simpler dev experience, the new SDK now auto discovers
providers and registers them. However, the OAuth system was still
requiring these credentials to be hardcoded in the settings object.

This PR changes that to verify the env var is present during
registration and then allows the OAuth system to load them from the env.

### Changes 🏗️

- **OAuth Registration**: Modified `ProviderBuilder.with_oauth(..)` to
check OAuth env vars exist during registration
- **OAuth Loading**: Updated OAuth system to load credentials from env
vars if not using secrets
- **Block Filtering**: Added `is_block_auth_configured()` function to
check if a block has valid authorization options configured at runtime
- **Test Updates**: Fixed failing SDK registry tests to properly mock
environment variables for OAuth registration

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
- [x] Verified OAuth system checks that env vars exist during provider
registration
- [x] Confirmed OAuth system can use env vars directly without requiring
hardcoded secrets
- [x] Tested that blocks with unconfigured OAuth providers are filtered
out
  - [x] All SDK registry tests pass with proper env var mocking

#### For configuration changes:
- [x] `.env.example` is updated or already compatible with my changes
- [x] `docker-compose.yml` is updated or already compatible with my
changes
- [x] I have included a list of my configuration changes in the PR
description (under **Changes**)
- OAuth providers now require their client ID and secret env vars to be
set for registration
  - No changes required to `.env.example` or `docker-compose.yml`

---------

Co-authored-by: Reinier van der Leer <pwuts@agpt.co>
2025-07-29 17:26:54 +00:00
..
__init__.py
_config.py
conftest.py
test_sdk_block_creation.py
test_sdk_patching.py
test_sdk_registry.py fix(backend): Ensure we only present working auth options on blocks (#10454) 2025-07-29 17:26:54 +00:00
test_sdk_webhooks.py