Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4d7e4b9
feat(server): Experimental support for OAuth2/OIDC authentication
cbcoutinho Oct 13, 2025
33b962a
test: Setup interactive browser test
cbcoutinho Oct 13, 2025
2b11718
test: continue working on oauth client
cbcoutinho Oct 13, 2025
7d8ba39
test: update app install scripts
cbcoutinho Oct 13, 2025
17979ac
test: Add patch for user_oidc app and update docs
cbcoutinho Oct 13, 2025
605c8af
test: Disable interactive tests for ci
cbcoutinho Oct 13, 2025
0c5d9a4
test: fix typo
cbcoutinho Oct 13, 2025
879cd58
test: rename interactive mark to oauth
cbcoutinho Oct 13, 2025
b7b8388
chore: comments
cbcoutinho Oct 13, 2025
4fae78a
test: disable oauth in ci
cbcoutinho Oct 13, 2025
e42cabb
chore: logging
cbcoutinho Oct 13, 2025
b26ff4f
test: Fix oauth interactive browser tests
cbcoutinho Oct 13, 2025
b3b7c90
chore: Move httpd server to separate fixture
cbcoutinho Oct 13, 2025
f58a988
test: Fix oauth2 token extract from starlette requests
cbcoutinho Oct 13, 2025
a4a7fb4
chore: Update --help
cbcoutinho Oct 13, 2025
2489a71
docs: Update README and docs
cbcoutinho Oct 13, 2025
9ef9fff
docs: Update Docs
cbcoutinho Oct 13, 2025
bcf8daa
docs: Update README
cbcoutinho Oct 13, 2025
ea46888
docs: Remove pip
cbcoutinho Oct 13, 2025
4b19964
docs: Update docs
cbcoutinho Oct 13, 2025
37b0577
test: Add asyncio tests using Playwright
cbcoutinho Oct 13, 2025
6ce4110
test: Enable tests via playwright, disable interactive in CI
cbcoutinho Oct 13, 2025
949d383
test: Install deps before wait, use firefox
cbcoutinho Oct 13, 2025
23cffc6
test: Add --build flag to docker compose up
cbcoutinho Oct 13, 2025
558f5ab
test: oauth
cbcoutinho Oct 13, 2025
f48d371
test: Add `restart` to mcp containers in docker-compose.yml
cbcoutinho Oct 13, 2025
13e4915
test: Remove unused pytest fixtures
cbcoutinho Oct 13, 2025
23688f3
chore: Remove comments
cbcoutinho Oct 13, 2025
e886eff
test: Fix typo in skipif condition
cbcoutinho Oct 13, 2025
2ae3c42
test: Skip interactive tests if GITHUB_ACTIONS is defined
cbcoutinho Oct 13, 2025
d879904
test: Skip for GITHUB_ACTIONS inside fixture
cbcoutinho Oct 13, 2025
a4ca3e0
Revert "test: Skip for GITHUB_ACTIONS inside fixture"
cbcoutinho Oct 13, 2025
3c4535d
test: Replace unittest class with simple tests
cbcoutinho Oct 13, 2025
057e25b
chore: Add support for overriding public issuer URL
cbcoutinho Oct 13, 2025
afc82ce
chore: Validate auth server support for PKCE on startup
cbcoutinho Oct 13, 2025
1023a7d
chore: Remove comments
cbcoutinho Oct 13, 2025
3ed24bd
docs: restructure documentation
cbcoutinho Oct 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ jobs:
uses: hoverkraft-tech/compose-action@3846bcd61da338e9eaaf83e7ed0234a12b099b72 # v2.4.1
with:
compose-file: "./docker-compose.yml"
up-flags: "--build"

- name: Install the latest version of uv
uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0

- name: Install Playwright dependencies
run: |
uv run playwright install firefox --with-deps

- name: Wait for service to be ready
run: |
echo "Waiting for service at http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info to return 401..."
Expand All @@ -56,4 +62,4 @@ jobs:
NEXTCLOUD_USERNAME: "admin"
NEXTCLOUD_PASSWORD: "admin"
run: |
uv run --frozen python -m pytest
uv run pytest -v --browser firefox
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__/
*.env
.env.local
.env.*.local
.nextcloud_oauth_test_client.json
47 changes: 46 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Each Nextcloud app has a corresponding server module that:
- If tests require modifications to pass, ask for permission before proceeding
- Use `docker-compose up --build -d mcp` to rebuild MCP container after code changes
- **Use existing fixtures** from `tests/conftest.py` to avoid duplicate setup work:
- `nc_mcp_client` - MCP client session for tool/resource testing
- `nc_mcp_client` - MCP client session for tool/resource testing
- `nc_client` - Direct NextcloudClient for setup/cleanup operations
- `temporary_note` - Creates and cleans up test notes automatically
- `temporary_addressbook` - Creates and cleans up test address books
Expand All @@ -117,6 +117,51 @@ Each Nextcloud app has a corresponding server module that:
- For specific API changes: `uv run pytest tests/integration/test_notes_api.py -v`
- **Avoid creating standalone test scripts** - use pytest with proper fixtures instead

#### OAuth/OIDC Testing
OAuth integration tests support both **automated** (Playwright) and **interactive** authentication flows:

**Automated Testing (Default - Recommended for CI/CD):**
- **Default fixtures**: `nc_oauth_client`, `nc_mcp_oauth_client` now use Playwright automation by default
- Uses Playwright headless browser automation to complete OAuth flow programmatically
- All Playwright fixtures: `playwright_oauth_token`, `nc_oauth_client`, `nc_mcp_oauth_client`, `nc_oauth_client_playwright`, `nc_mcp_oauth_client_playwright`
- Requires: `NEXTCLOUD_HOST`, `NEXTCLOUD_USERNAME`, `NEXTCLOUD_PASSWORD` environment variables
- Uses `pytest-playwright-asyncio` for async Playwright fixtures
- Playwright configuration: Use pytest CLI args like `--browser firefox --headed` to customize
- Install browsers: `uv run playwright install firefox` (or `chromium`, `webkit`)
- Example:
```bash
# Run all OAuth tests with automated Playwright flow using Firefox
uv run pytest tests/integration/test_oauth*.py --browser firefox -v

# Run specific Playwright tests with visible browser for debugging
uv run pytest tests/integration/test_oauth_playwright.py --browser firefox --headed -v

# Run with Chromium (default)
uv run pytest tests/integration/test_oauth.py -v
```

**Interactive Testing (Manual browser login):**
- Opens system browser and waits for manual login/authorization
- Fixtures: `interactive_oauth_token`, `nc_oauth_client_interactive`, `nc_mcp_oauth_client_interactive`
- Requires: User to complete browser-based login when prompted
- Useful for: Debugging OAuth flows, testing with 2FA, local development
- **Automatically skipped in GitHub Actions CI** - Interactive fixtures check for `GITHUB_ACTIONS` environment variable
- Example:
```bash
# Run OAuth tests with interactive flow (will open browser and wait for manual login)
uv run pytest tests/integration/test_oauth_interactive.py -v
```

**Test Environment Setup:**
- Start OAuth MCP server: `docker-compose up --build -d mcp-oauth`
- OAuth server runs on port 8001 (regular MCP on 8000)
- Both flows register OAuth clients dynamically using Nextcloud's OIDC provider

**CI/CD Considerations:**
- Interactive OAuth tests are automatically skipped when `GITHUB_ACTIONS` environment variable is set
- Automated Playwright tests will run in CI/CD environments
- Use Firefox browser in CI: `--browser firefox` (Chromium may have issues with localhost redirects)

### Configuration Files

- **`pyproject.toml`** - Python project configuration using uv for dependency management
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ COPY . .

RUN uv sync --locked --no-dev

ENV PYTHONUNBUFFERED=1

ENTRYPOINT ["/app/.venv/bin/nextcloud-mcp-server", "--host", "0.0.0.0"]
Loading