49c5439686
Add cross-system interface test annotations to the 5 astrolabe test files, clarifying they test the MCP server's integration with the Astrolabe Nextcloud app (installed from the app store, source now in a separate repo). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
97 lines
3.5 KiB
Python
97 lines
3.5 KiB
Python
"""Integration tests for Astrolabe personal settings page buttons.
|
|
|
|
Cross-system interface test: Tests the MCP server's integration with the
|
|
Astrolabe Nextcloud app, which is installed from the Nextcloud app store via
|
|
app-hooks/post-installation/20-install-astrolabe-app.sh. Astrolabe source
|
|
lives in a separate repository (https://github.com/cbcoutinho/astrolabe).
|
|
|
|
Tests the button functionality on /settings/user/astrolabe:
|
|
1. Disable Indexing button (POST to /apps/astrolabe/api/revoke)
|
|
2. Disconnect button (POST to /apps/astrolabe/oauth/disconnect)
|
|
|
|
These tests verify that:
|
|
- The endpoints respond correctly to POST requests
|
|
- CSRF token validation works
|
|
- User actions are properly handled
|
|
- Appropriate redirects occur
|
|
"""
|
|
|
|
import httpx
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.integration
|
|
async def test_disable_indexing_button_endpoint_exists():
|
|
"""Test that the Disable Indexing endpoint is accessible."""
|
|
async with httpx.AsyncClient() as client:
|
|
# Try without authentication - should return 401 or redirect
|
|
response = await client.post(
|
|
"http://localhost:8080/apps/astrolabe/api/revoke",
|
|
follow_redirects=False,
|
|
)
|
|
|
|
# Should get 401 Unauthorized or 30x redirect
|
|
assert response.status_code in [401, 301, 302, 303, 307, 308], (
|
|
f"Expected 401 or redirect without auth, got {response.status_code}"
|
|
)
|
|
|
|
|
|
@pytest.mark.integration
|
|
async def test_disconnect_button_endpoint_exists():
|
|
"""Test that the Disconnect endpoint is accessible."""
|
|
async with httpx.AsyncClient() as client:
|
|
# Try without authentication - should return 401 or redirect
|
|
response = await client.post(
|
|
"http://localhost:8080/apps/astrolabe/oauth/disconnect",
|
|
follow_redirects=False,
|
|
)
|
|
|
|
# Should get 401 Unauthorized or 30x redirect
|
|
assert response.status_code in [401, 301, 302, 303, 307, 308], (
|
|
f"Expected 401 or redirect without auth, got {response.status_code}"
|
|
)
|
|
|
|
|
|
@pytest.mark.integration
|
|
async def test_settings_page_renders_buttons():
|
|
"""Test that the settings page template includes button forms.
|
|
|
|
This test verifies that the PHP template renders the form elements.
|
|
It doesn't require authentication since we're just checking the route exists.
|
|
"""
|
|
async with httpx.AsyncClient(follow_redirects=False) as client:
|
|
# Try to access settings page
|
|
response = await client.get("http://localhost:8080/settings/user/astrolabe")
|
|
|
|
# Should get 401/redirect if not authenticated (expected)
|
|
# or 200 if user session exists from browser testing
|
|
assert response.status_code in [200, 401, 302, 303, 307, 308], (
|
|
f"Unexpected status code: {response.status_code}"
|
|
)
|
|
|
|
|
|
@pytest.mark.integration
|
|
@pytest.mark.skip(
|
|
reason="Requires manual authentication - test with Playwright instead"
|
|
)
|
|
async def test_disconnect_button_functionality():
|
|
"""Test that clicking Disconnect button clears user OAuth tokens.
|
|
|
|
NOTE: This test is skipped because programmatic login to Nextcloud is complex.
|
|
Use Playwright-based tests or manual testing instead.
|
|
"""
|
|
pass
|
|
|
|
|
|
@pytest.mark.integration
|
|
@pytest.mark.skip(
|
|
reason="Requires manual authentication - test with Playwright instead"
|
|
)
|
|
async def test_disable_indexing_button_functionality():
|
|
"""Test that clicking Disable Indexing button revokes background access.
|
|
|
|
NOTE: This test is skipped because programmatic login to Nextcloud is complex.
|
|
Use Playwright-based tests or manual testing instead.
|
|
"""
|
|
pass
|