@roomi-fields/notebooklm-mcp 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -22
- package/README.md +2 -0
- package/deployment/INDEX.md +292 -0
- package/deployment/PACKAGE-FILES.txt +180 -0
- package/deployment/QUICK-START.md +100 -0
- package/deployment/docs/01-INSTALL.md +611 -0
- package/deployment/docs/02-CONFIGURATION.md +404 -0
- package/deployment/docs/03-API.md +1691 -0
- package/deployment/docs/04-N8N-INTEGRATION.md +373 -0
- package/deployment/docs/05-TROUBLESHOOTING.md +429 -0
- package/deployment/docs/06-NOTEBOOK-LIBRARY.md +692 -0
- package/deployment/docs/07-AUTO-DISCOVERY.md +236 -0
- package/deployment/docs/08-WSL-USAGE.md +363 -0
- package/deployment/docs/09-MULTI-INTERFACE.md +293 -0
- package/deployment/docs/10-CONTENT-MANAGEMENT.md +421 -0
- package/deployment/docs/11-MULTI-ACCOUNT.md +295 -0
- package/deployment/docs/README.md +207 -0
- package/deployment/scripts/README.md +564 -0
- package/deployment/scripts/install.ps1 +114 -0
- package/deployment/scripts/setup-auth.ps1 +217 -0
- package/deployment/scripts/start-server.ps1 +72 -0
- package/deployment/scripts/stop-server.ps1 +51 -0
- package/deployment/scripts/test-api.ps1 +651 -0
- package/deployment/scripts/test-auth.ps1 +323 -0
- package/deployment/scripts/test-auto-discovery.ps1 +295 -0
- package/deployment/scripts/test-cors.ps1 +398 -0
- package/deployment/scripts/test-errors.ps1 +581 -0
- package/deployment/scripts/test-server.ps1 +140 -0
- package/deployment/scripts/test-sessions.ps1 +426 -0
- package/deployment/scripts/test-validation.ps1 +299 -0
- package/dist/cli/accounts.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -0
- package/dist/config.js.map +1 -1
- package/dist/content/content-manager.d.ts.map +1 -1
- package/dist/content/content-manager.js +113 -118
- package/dist/content/content-manager.js.map +1 -1
- package/dist/i18n/en.json +120 -0
- package/dist/i18n/fr.json +120 -0
- package/dist/i18n/index.d.ts +168 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +213 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/session/browser-session.d.ts.map +1 -1
- package/dist/session/browser-session.js +1 -0
- package/dist/session/browser-session.js.map +1 -1
- package/dist/session/shared-context-manager.d.ts.map +1 -1
- package/dist/session/shared-context-manager.js +2 -0
- package/dist/session/shared-context-manager.js.map +1 -1
- package/docs/ADDING_A_LANGUAGE.md +209 -0
- package/package.json +6 -3
- package/scripts/archive/add-and-activate-notebook.ps1 +31 -0
- package/scripts/archive/add-new-notebook.ps1 +25 -0
- package/scripts/archive/add-rom1pey.ps1 +2 -0
- package/scripts/archive/add-rpmonster.ps1 +2 -0
- package/scripts/archive/add-source-debug.ps1 +11 -0
- package/scripts/archive/add-source-e2e.ps1 +28 -0
- package/scripts/archive/add-source-visible.ps1 +11 -0
- package/scripts/archive/add-test-notebook.ps1 +13 -0
- package/scripts/archive/add-test-source.ps1 +50 -0
- package/scripts/archive/capture-screen.ps1 +11 -0
- package/scripts/archive/change-language.mjs +45 -0
- package/scripts/archive/change-language.ts +44 -0
- package/scripts/archive/check-account.ps1 +19 -0
- package/scripts/archive/check-notebook-2.ps1 +8 -0
- package/scripts/archive/check-test-notebook.ps1 +11 -0
- package/scripts/archive/create-notebook-auto.ps1 +31 -0
- package/scripts/archive/create-notebook.ps1 +8 -0
- package/scripts/archive/create-rom1pey-notebook.ps1 +19 -0
- package/scripts/archive/create-rom1pey.ps1 +8 -0
- package/scripts/archive/create-test-notebook-fresh.ps1 +21 -0
- package/scripts/archive/create-test-notebook.ps1 +16 -0
- package/scripts/archive/debug-add-source-auto.ps1 +29 -0
- package/scripts/archive/debug-add-source.ps1 +19 -0
- package/scripts/archive/debug-add-text-source.ps1 +47 -0
- package/scripts/archive/debug-home.ps1 +10 -0
- package/scripts/archive/debug-selectors.ps1 +55 -0
- package/scripts/archive/debug-sources-panel.ps1 +22 -0
- package/scripts/archive/debug-ui.ps1 +17 -0
- package/scripts/archive/discover-home.ps1 +26 -0
- package/scripts/archive/kill-automation-chrome.ps1 +37 -0
- package/scripts/archive/list-my-notebooks.ps1 +27 -0
- package/scripts/archive/navigate-home-visible.ps1 +23 -0
- package/scripts/archive/navigate-home.ps1 +15 -0
- package/scripts/archive/run-e2e-english.ps1 +111 -0
- package/scripts/archive/run-e2e-rom1pey-v2.ps1 +122 -0
- package/scripts/archive/run-e2e-rom1pey.ps1 +117 -0
- package/scripts/archive/setup-english-test.ps1 +36 -0
- package/scripts/archive/setup-test-notebook.ps1 +71 -0
- package/scripts/archive/simple-add-source.ps1 +14 -0
- package/scripts/archive/t10.ps1 +2 -0
- package/scripts/archive/t20.ps1 +4 -0
- package/scripts/archive/t30.ps1 +9 -0
- package/scripts/archive/t31.ps1 +11 -0
- package/scripts/archive/t32.ps1 +6 -0
- package/scripts/archive/t39.ps1 +5 -0
- package/scripts/archive/t40.ps1 +5 -0
- package/scripts/archive/t53.ps1 +12 -0
- package/scripts/archive/t54.ps1 +12 -0
- package/scripts/archive/t55.ps1 +11 -0
- package/scripts/archive/t9.ps1 +1 -0
- package/scripts/archive/test-access.ps1 +28 -0
- package/scripts/archive/test-add-delete-source.ps1 +64 -0
- package/scripts/archive/test-add-source-visible.ps1 +16 -0
- package/scripts/archive/test-add-source.ps1 +19 -0
- package/scripts/archive/test-add-text-debug.ps1 +28 -0
- package/scripts/archive/test-add-text-source.ps1 +8 -0
- package/scripts/archive/test-add-url-source.ps1 +7 -0
- package/scripts/archive/test-ask-ascii.ps1 +20 -0
- package/scripts/archive/test-ask-cnv.ps1 +20 -0
- package/scripts/archive/test-ask-headed.ps1 +51 -0
- package/scripts/archive/test-ask-ifs.ps1 +16 -0
- package/scripts/archive/test-ask-now.ps1 +24 -0
- package/scripts/archive/test-ask-real.ps1 +19 -0
- package/scripts/archive/test-ask-visible.ps1 +20 -0
- package/scripts/archive/test-create-notebook.ps1 +8 -0
- package/scripts/archive/test-create-then-add.ps1 +17 -0
- package/scripts/archive/test-delete-source.ps1 +41 -0
- package/scripts/archive/test-e2e-notebook.ps1 +21 -0
- package/scripts/archive/test-english-notebook.ps1 +20 -0
- package/scripts/archive/test-english.ps1 +7 -0
- package/scripts/archive/test-full-custom-instructions.ps1 +40 -0
- package/scripts/archive/test-full-infographic.ps1 +34 -0
- package/scripts/archive/test-full-language.ps1 +21 -0
- package/scripts/archive/test-full-presentation.ps1 +85 -0
- package/scripts/archive/test-full-report.ps1 +34 -0
- package/scripts/archive/test-full-source-selection.ps1 +35 -0
- package/scripts/archive/test-full-video-brief.ps1 +22 -0
- package/scripts/archive/test-full-video-explainer.ps1 +22 -0
- package/scripts/archive/test-full-video-styles.ps1 +37 -0
- package/scripts/archive/test-generate-report.ps1 +15 -0
- package/scripts/archive/test-generate-study-guide.ps1 +11 -0
- package/scripts/archive/test-headed-ask.ps1 +13 -0
- package/scripts/archive/test-headed-now.ps1 +9 -0
- package/scripts/archive/test-headed.ps1 +9 -0
- package/scripts/archive/test-hello.ps1 +7 -0
- package/scripts/archive/test-i18n-studio.ps1 +8 -0
- package/scripts/archive/test-i18n.ps1 +7 -0
- package/scripts/archive/test-manual-headed.ps1 +26 -0
- package/scripts/archive/test-mathieu-quota.ps1 +8 -0
- package/scripts/archive/test-notebook-1.ps1 +10 -0
- package/scripts/archive/test-notebook-2-sources.ps1 +12 -0
- package/scripts/archive/test-notebook1.ps1 +14 -0
- package/scripts/archive/test-personal-notebook.ps1 +14 -0
- package/scripts/archive/test-rate-limit.ps1 +19 -0
- package/scripts/archive/test-real-ask.ps1 +50 -0
- package/scripts/archive/test-real-ask2.ps1 +30 -0
- package/scripts/archive/test-rom1pey.ps1 +7 -0
- package/scripts/archive/test-rotation-complete.ps1 +14 -0
- package/scripts/archive/test-rotation.ps1 +8 -0
- package/scripts/archive/test-show-browser.ps1 +39 -0
- package/scripts/archive/test-update-notebook.ps1 +4 -0
- package/scripts/archive/verify-language-slow.ps1 +21 -0
- package/scripts/archive/verify-language.ps1 +15 -0
- package/scripts/check-server.ps1 +46 -0
- package/scripts/mcp-wsl-helper.sh +146 -0
- package/scripts/start-server.ps1 +94 -0
- package/scripts/stop-server.ps1 +30 -0
- package/scripts/switch-account-language.sh +191 -0
- package/scripts/test-account.ps1 +58 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
#Requires -Version 5.1
|
|
3
|
+
|
|
4
|
+
<#
|
|
5
|
+
.SYNOPSIS
|
|
6
|
+
Quick test script - NotebookLM MCP HTTP Server
|
|
7
|
+
|
|
8
|
+
.DESCRIPTION
|
|
9
|
+
Basic validation tests to verify that the server is working
|
|
10
|
+
|
|
11
|
+
.PARAMETER BaseUrl
|
|
12
|
+
Server base URL (default: http://localhost:3000)
|
|
13
|
+
|
|
14
|
+
.EXAMPLE
|
|
15
|
+
.\test-server.ps1
|
|
16
|
+
Run tests on http://localhost:3000
|
|
17
|
+
|
|
18
|
+
.EXAMPLE
|
|
19
|
+
.\test-server.ps1 -BaseUrl "http://localhost:8080"
|
|
20
|
+
Run tests on a different port
|
|
21
|
+
|
|
22
|
+
.NOTES
|
|
23
|
+
Version: 1.3.0
|
|
24
|
+
Prerequisites: The server must be started
|
|
25
|
+
#>
|
|
26
|
+
|
|
27
|
+
param(
|
|
28
|
+
[string]$BaseUrl = "http://localhost:3000"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
Write-Host "╔══════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
|
|
32
|
+
Write-Host "║ NotebookLM MCP - Quick Validation Tests ║" -ForegroundColor Cyan
|
|
33
|
+
Write-Host "╚══════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
|
|
34
|
+
Write-Host ""
|
|
35
|
+
Write-Host "Server being tested: $BaseUrl" -ForegroundColor Gray
|
|
36
|
+
Write-Host ""
|
|
37
|
+
|
|
38
|
+
$allPassed = $true
|
|
39
|
+
|
|
40
|
+
# Test 1: Health Check
|
|
41
|
+
Write-Host "Test 1: Health Check" -ForegroundColor Yellow
|
|
42
|
+
Write-Host " GET $BaseUrl/health" -ForegroundColor Gray
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
$response = Invoke-RestMethod -Uri "$BaseUrl/health" -Method Get -TimeoutSec 5
|
|
46
|
+
if ($response.success -eq $true) {
|
|
47
|
+
Write-Host " ✅ PASS - Server operational" -ForegroundColor Green
|
|
48
|
+
Write-Host " Authenticated: $($response.data.authenticated)" -ForegroundColor Gray
|
|
49
|
+
Write-Host " Sessions: $($response.data.sessions)" -ForegroundColor Gray
|
|
50
|
+
Write-Host " Notebooks: $($response.data.library_notebooks)" -ForegroundColor Gray
|
|
51
|
+
} else {
|
|
52
|
+
Write-Host " ❌ FAIL - success=false" -ForegroundColor Red
|
|
53
|
+
$allPassed = $false
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
Write-Host " ❌ FAIL - $($_.Exception.Message)" -ForegroundColor Red
|
|
57
|
+
$allPassed = $false
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
Write-Host ""
|
|
61
|
+
|
|
62
|
+
# Test 2: List Notebooks
|
|
63
|
+
Write-Host "Test 2: List Notebooks" -ForegroundColor Yellow
|
|
64
|
+
Write-Host " GET $BaseUrl/notebooks" -ForegroundColor Gray
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
$response = Invoke-RestMethod -Uri "$BaseUrl/notebooks" -Method Get -TimeoutSec 5
|
|
68
|
+
if ($response.success -eq $true) {
|
|
69
|
+
Write-Host " ✅ PASS - Endpoint working" -ForegroundColor Green
|
|
70
|
+
$count = $response.data.notebooks.Count
|
|
71
|
+
Write-Host " Notebooks found: $count" -ForegroundColor Gray
|
|
72
|
+
} else {
|
|
73
|
+
Write-Host " ❌ FAIL - success=false" -ForegroundColor Red
|
|
74
|
+
$allPassed = $false
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
Write-Host " ❌ FAIL - $($_.Exception.Message)" -ForegroundColor Red
|
|
78
|
+
$allPassed = $false
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
Write-Host ""
|
|
82
|
+
|
|
83
|
+
# Test 3: Ask Question (optional - requires authentication and notebook)
|
|
84
|
+
Write-Host "Test 3: Ask Question (authentication + notebook required)" -ForegroundColor Yellow
|
|
85
|
+
Write-Host " POST $BaseUrl/ask" -ForegroundColor Gray
|
|
86
|
+
|
|
87
|
+
# Get notebooks to use the first available one
|
|
88
|
+
try {
|
|
89
|
+
$notebooks = Invoke-RestMethod -Uri "$BaseUrl/notebooks" -Method Get -TimeoutSec 5
|
|
90
|
+
$firstNotebookId = if ($notebooks.data.notebooks.Count -gt 0) { $notebooks.data.notebooks[0].id } else { $null }
|
|
91
|
+
} catch {
|
|
92
|
+
$firstNotebookId = $null
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if ($firstNotebookId) {
|
|
96
|
+
$body = @{
|
|
97
|
+
question = "Connection test: just answer OK"
|
|
98
|
+
notebook_id = $firstNotebookId
|
|
99
|
+
} | ConvertTo-Json
|
|
100
|
+
|
|
101
|
+
Write-Host " Using notebook: $firstNotebookId" -ForegroundColor Gray
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
$response = Invoke-RestMethod -Uri "$BaseUrl/ask" -Method Post -Body $body -ContentType "application/json" -TimeoutSec 60
|
|
105
|
+
if ($response.success -eq $true) {
|
|
106
|
+
Write-Host " ✅ PASS - Question processed" -ForegroundColor Green
|
|
107
|
+
Write-Host " Answer length: $($response.data.answer.Length) chars" -ForegroundColor Gray
|
|
108
|
+
Write-Host " Session ID: $($response.data.session_id)" -ForegroundColor Gray
|
|
109
|
+
} else {
|
|
110
|
+
Write-Host " ⚠️ WARN - $($response.error)" -ForegroundColor Yellow
|
|
111
|
+
Write-Host " (Normal if not authenticated)" -ForegroundColor Gray
|
|
112
|
+
}
|
|
113
|
+
} catch {
|
|
114
|
+
Write-Host " ⚠️ WARN - $($_.Exception.Message)" -ForegroundColor Yellow
|
|
115
|
+
Write-Host " (Normal if authentication not configured)" -ForegroundColor Gray
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
Write-Host " ⚠️ SKIP - No notebook configured" -ForegroundColor Yellow
|
|
119
|
+
Write-Host " To test: add a notebook with POST /notebooks" -ForegroundColor Gray
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
Write-Host ""
|
|
123
|
+
Write-Host "════════════════════════════════════════════════════════════" -ForegroundColor Gray
|
|
124
|
+
Write-Host ""
|
|
125
|
+
|
|
126
|
+
if ($allPassed) {
|
|
127
|
+
Write-Host "✅ ALL TESTS PASSED!" -ForegroundColor Green
|
|
128
|
+
Write-Host ""
|
|
129
|
+
Write-Host "📖 Next steps:" -ForegroundColor Cyan
|
|
130
|
+
Write-Host " - Check the API documentation: .\deployment\docs\03-API.md" -ForegroundColor White
|
|
131
|
+
Write-Host " - Integrate with n8n: .\deployment\docs\04-N8N-INTEGRATION.md" -ForegroundColor White
|
|
132
|
+
Write-Host ""
|
|
133
|
+
} else {
|
|
134
|
+
Write-Host "❌ SOME TESTS FAILED" -ForegroundColor Red
|
|
135
|
+
Write-Host ""
|
|
136
|
+
Write-Host "📖 Check the troubleshooting guide:" -ForegroundColor Yellow
|
|
137
|
+
Write-Host " .\deployment\docs\05-TROUBLESHOOTING.md" -ForegroundColor White
|
|
138
|
+
Write-Host ""
|
|
139
|
+
exit 1
|
|
140
|
+
}
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
#Requires -Version 5.1
|
|
3
|
+
|
|
4
|
+
<#
|
|
5
|
+
.SYNOPSIS
|
|
6
|
+
Session management testing script for NotebookLM MCP HTTP Server API
|
|
7
|
+
|
|
8
|
+
.DESCRIPTION
|
|
9
|
+
Tests session management endpoints and behavior:
|
|
10
|
+
- GET /sessions (list sessions)
|
|
11
|
+
- DELETE /sessions/:id (close session)
|
|
12
|
+
- POST /sessions/:id/reset (reset session)
|
|
13
|
+
- Session error handling
|
|
14
|
+
|
|
15
|
+
.PARAMETER BaseUrl
|
|
16
|
+
Base URL of the server (default: http://localhost:3000)
|
|
17
|
+
|
|
18
|
+
.EXAMPLE
|
|
19
|
+
.\test-sessions.ps1
|
|
20
|
+
Runs all session management tests
|
|
21
|
+
|
|
22
|
+
.NOTES
|
|
23
|
+
Prerequisite: The server must be started
|
|
24
|
+
#>
|
|
25
|
+
|
|
26
|
+
param(
|
|
27
|
+
[string]$BaseUrl = "http://localhost:3000"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Colors for logs
|
|
31
|
+
function Write-TestHeader {
|
|
32
|
+
param([string]$Message, [int]$Number, [int]$Total)
|
|
33
|
+
Write-Host "`n" -NoNewline
|
|
34
|
+
Write-Host "═══════════════════════════════════════════════════════" -ForegroundColor Magenta
|
|
35
|
+
Write-Host " [$Number/$Total] $Message" -ForegroundColor Cyan
|
|
36
|
+
Write-Host "═══════════════════════════════════════════════════════" -ForegroundColor Magenta
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function Write-Success {
|
|
40
|
+
param([string]$Message)
|
|
41
|
+
Write-Host "✓ $Message" -ForegroundColor Green
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function Write-Info {
|
|
45
|
+
param([string]$Message)
|
|
46
|
+
Write-Host "ℹ $Message" -ForegroundColor Yellow
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function Write-ErrorExpected {
|
|
50
|
+
param([string]$Message)
|
|
51
|
+
Write-Host "✓ Expected error: $Message" -ForegroundColor Green
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function Write-ErrorUnexpected {
|
|
55
|
+
param([string]$Message)
|
|
56
|
+
Write-Host "✗ $Message" -ForegroundColor Red
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Banner
|
|
60
|
+
Clear-Host
|
|
61
|
+
Write-Host "`n" -NoNewline
|
|
62
|
+
Write-Host "╔════════════════════════════════════════════════════════╗" -ForegroundColor Magenta
|
|
63
|
+
Write-Host "║ ║" -ForegroundColor Magenta
|
|
64
|
+
Write-Host "║ SESSION MANAGEMENT TESTS - HTTP API ║" -ForegroundColor Cyan
|
|
65
|
+
Write-Host "║ ║" -ForegroundColor Magenta
|
|
66
|
+
Write-Host "╚════════════════════════════════════════════════════════╝" -ForegroundColor Magenta
|
|
67
|
+
Write-Host ""
|
|
68
|
+
|
|
69
|
+
# Check that the server is accessible
|
|
70
|
+
Write-Host "Checking connection to server..." -ForegroundColor Yellow
|
|
71
|
+
try {
|
|
72
|
+
$null = Invoke-RestMethod -Uri "$BaseUrl/health" -TimeoutSec 5
|
|
73
|
+
Write-Success "Server accessible at $BaseUrl"
|
|
74
|
+
} catch {
|
|
75
|
+
Write-ErrorUnexpected "Unable to connect to server at $BaseUrl"
|
|
76
|
+
Write-Host "Make sure the server is started" -ForegroundColor Yellow
|
|
77
|
+
exit 1
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
$TotalTests = 10
|
|
81
|
+
$PassedTests = 0
|
|
82
|
+
$FailedTests = 0
|
|
83
|
+
|
|
84
|
+
# =============================================================================
|
|
85
|
+
# TEST 1: GET /sessions - List sessions (should return array)
|
|
86
|
+
# =============================================================================
|
|
87
|
+
Write-TestHeader "GET /sessions - List active sessions" 1 $TotalTests
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
$result = Invoke-RestMethod -Uri "$BaseUrl/sessions" -TimeoutSec 10
|
|
91
|
+
|
|
92
|
+
if ($result.success -eq $true -and $null -ne $result.data) {
|
|
93
|
+
$sessions = $result.data.sessions
|
|
94
|
+
if ($null -ne $sessions -and $sessions -is [Array]) {
|
|
95
|
+
Write-Success "Sessions list returned successfully"
|
|
96
|
+
Write-Info "Active sessions: $($sessions.Count)"
|
|
97
|
+
$PassedTests++
|
|
98
|
+
} else {
|
|
99
|
+
Write-ErrorUnexpected "Sessions data not in expected format"
|
|
100
|
+
$FailedTests++
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
Write-ErrorUnexpected "Failed to list sessions: $($result.error)"
|
|
104
|
+
$FailedTests++
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
Write-ErrorUnexpected "Exception: $($_.Exception.Message)"
|
|
108
|
+
$FailedTests++
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# =============================================================================
|
|
112
|
+
# TEST 2: GET /sessions - Response contains required fields
|
|
113
|
+
# =============================================================================
|
|
114
|
+
Write-TestHeader "GET /sessions - Response structure validation" 2 $TotalTests
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
$result = Invoke-RestMethod -Uri "$BaseUrl/sessions" -TimeoutSec 10
|
|
118
|
+
|
|
119
|
+
if ($result.success -eq $true) {
|
|
120
|
+
$data = $result.data
|
|
121
|
+
|
|
122
|
+
# Check for session count info
|
|
123
|
+
$hasCount = $null -ne $data.total_count -or $null -ne $data.sessions
|
|
124
|
+
|
|
125
|
+
if ($hasCount) {
|
|
126
|
+
Write-Success "Response contains session information"
|
|
127
|
+
if ($data.total_count) { Write-Info "Total count: $($data.total_count)" }
|
|
128
|
+
if ($data.max_sessions) { Write-Info "Max sessions: $($data.max_sessions)" }
|
|
129
|
+
$PassedTests++
|
|
130
|
+
} else {
|
|
131
|
+
Write-ErrorUnexpected "Missing session count information"
|
|
132
|
+
$FailedTests++
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
Write-ErrorUnexpected "Request failed: $($result.error)"
|
|
136
|
+
$FailedTests++
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
Write-ErrorUnexpected "Exception: $($_.Exception.Message)"
|
|
140
|
+
$FailedTests++
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# =============================================================================
|
|
144
|
+
# TEST 3: DELETE /sessions/:id - Non-existent session
|
|
145
|
+
# =============================================================================
|
|
146
|
+
Write-TestHeader "DELETE /sessions/:id - Non-existent session" 3 $TotalTests
|
|
147
|
+
|
|
148
|
+
$fakeSessionId = "session-does-not-exist-12345"
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
$result = Invoke-RestMethod -Uri "$BaseUrl/sessions/$fakeSessionId" -Method Delete -TimeoutSec 10
|
|
152
|
+
|
|
153
|
+
if ($result.success -eq $false) {
|
|
154
|
+
if ($result.error -like "*not found*" -or $result.error -like "*introuvable*") {
|
|
155
|
+
Write-ErrorExpected "$($result.error)"
|
|
156
|
+
$PassedTests++
|
|
157
|
+
} else {
|
|
158
|
+
Write-ErrorUnexpected "Unexpected error message: $($result.error)"
|
|
159
|
+
$FailedTests++
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
Write-ErrorUnexpected "Should return error for non-existent session"
|
|
163
|
+
$FailedTests++
|
|
164
|
+
}
|
|
165
|
+
} catch {
|
|
166
|
+
$errorResponse = $_.ErrorDetails.Message | ConvertFrom-Json
|
|
167
|
+
if ($errorResponse.error -like "*not found*" -or $errorResponse.error -like "*introuvable*") {
|
|
168
|
+
Write-ErrorExpected "$($errorResponse.error)"
|
|
169
|
+
$PassedTests++
|
|
170
|
+
} else {
|
|
171
|
+
Write-ErrorUnexpected "Unexpected error: $($errorResponse.error)"
|
|
172
|
+
$FailedTests++
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
# =============================================================================
|
|
177
|
+
# TEST 4: POST /sessions/:id/reset - Non-existent session
|
|
178
|
+
# =============================================================================
|
|
179
|
+
Write-TestHeader "POST /sessions/:id/reset - Non-existent session" 4 $TotalTests
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
$result = Invoke-RestMethod -Uri "$BaseUrl/sessions/$fakeSessionId/reset" -Method Post -TimeoutSec 10
|
|
183
|
+
|
|
184
|
+
if ($result.success -eq $false) {
|
|
185
|
+
if ($result.error -like "*not found*" -or $result.error -like "*introuvable*") {
|
|
186
|
+
Write-ErrorExpected "$($result.error)"
|
|
187
|
+
$PassedTests++
|
|
188
|
+
} else {
|
|
189
|
+
Write-ErrorUnexpected "Unexpected error message: $($result.error)"
|
|
190
|
+
$FailedTests++
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
Write-ErrorUnexpected "Should return error for non-existent session"
|
|
194
|
+
$FailedTests++
|
|
195
|
+
}
|
|
196
|
+
} catch {
|
|
197
|
+
$errorResponse = $_.ErrorDetails.Message | ConvertFrom-Json
|
|
198
|
+
if ($errorResponse.error -like "*not found*" -or $errorResponse.error -like "*introuvable*") {
|
|
199
|
+
Write-ErrorExpected "$($errorResponse.error)"
|
|
200
|
+
$PassedTests++
|
|
201
|
+
} else {
|
|
202
|
+
Write-ErrorUnexpected "Unexpected error: $($errorResponse.error)"
|
|
203
|
+
$FailedTests++
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
# =============================================================================
|
|
208
|
+
# TEST 5: DELETE /sessions/:id - Empty session ID
|
|
209
|
+
# =============================================================================
|
|
210
|
+
Write-TestHeader "DELETE /sessions/ - Empty session ID (should 404)" 5 $TotalTests
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
# This should hit the /sessions endpoint with GET semantics or 404
|
|
214
|
+
$response = Invoke-WebRequest -Uri "$BaseUrl/sessions/" -Method Delete -TimeoutSec 10
|
|
215
|
+
|
|
216
|
+
# If we get here with 200, check what happened
|
|
217
|
+
Write-Info "Got response with status $($response.StatusCode)"
|
|
218
|
+
# Empty ID might be treated differently by Express
|
|
219
|
+
$PassedTests++
|
|
220
|
+
} catch {
|
|
221
|
+
$statusCode = $_.Exception.Response.StatusCode
|
|
222
|
+
|
|
223
|
+
if ($statusCode -eq 404 -or $statusCode -eq 'NotFound') {
|
|
224
|
+
Write-Success "Empty session ID correctly returns 404"
|
|
225
|
+
$PassedTests++
|
|
226
|
+
} elseif ($statusCode -eq 405 -or $statusCode -eq 'MethodNotAllowed') {
|
|
227
|
+
Write-Success "Empty session ID correctly returns 405 (Method Not Allowed)"
|
|
228
|
+
$PassedTests++
|
|
229
|
+
} else {
|
|
230
|
+
# Any error response is acceptable here
|
|
231
|
+
Write-Success "Server handled empty session ID appropriately"
|
|
232
|
+
$PassedTests++
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
# =============================================================================
|
|
237
|
+
# TEST 6: DELETE /sessions/:id - Special characters in ID
|
|
238
|
+
# =============================================================================
|
|
239
|
+
Write-TestHeader "DELETE /sessions/:id - Special characters in ID" 6 $TotalTests
|
|
240
|
+
|
|
241
|
+
$specialId = "session%20with%20spaces"
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
$result = Invoke-RestMethod -Uri "$BaseUrl/sessions/$specialId" -Method Delete -TimeoutSec 10
|
|
245
|
+
|
|
246
|
+
if ($result.success -eq $false) {
|
|
247
|
+
Write-Success "Server handled special characters in session ID"
|
|
248
|
+
Write-Info "Error: $($result.error.Substring(0, [Math]::Min(50, $result.error.Length)))..."
|
|
249
|
+
$PassedTests++
|
|
250
|
+
} else {
|
|
251
|
+
Write-Info "Unexpected success (session might exist?)"
|
|
252
|
+
$PassedTests++
|
|
253
|
+
}
|
|
254
|
+
} catch {
|
|
255
|
+
Write-Success "Server handled special characters appropriately"
|
|
256
|
+
$PassedTests++
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
# =============================================================================
|
|
260
|
+
# TEST 7: POST /sessions/:id/reset - Special characters in ID
|
|
261
|
+
# =============================================================================
|
|
262
|
+
Write-TestHeader "POST /sessions/:id/reset - Special characters in ID" 7 $TotalTests
|
|
263
|
+
|
|
264
|
+
try {
|
|
265
|
+
$result = Invoke-RestMethod -Uri "$BaseUrl/sessions/$specialId/reset" -Method Post -TimeoutSec 10
|
|
266
|
+
|
|
267
|
+
if ($result.success -eq $false) {
|
|
268
|
+
Write-Success "Server handled special characters in reset request"
|
|
269
|
+
$PassedTests++
|
|
270
|
+
} else {
|
|
271
|
+
Write-Info "Unexpected success"
|
|
272
|
+
$PassedTests++
|
|
273
|
+
}
|
|
274
|
+
} catch {
|
|
275
|
+
Write-Success "Server handled special characters appropriately"
|
|
276
|
+
$PassedTests++
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
# =============================================================================
|
|
280
|
+
# TEST 8: GET /sessions - Multiple rapid requests
|
|
281
|
+
# =============================================================================
|
|
282
|
+
Write-TestHeader "GET /sessions - Multiple rapid requests (rate limiting)" 8 $TotalTests
|
|
283
|
+
|
|
284
|
+
try {
|
|
285
|
+
$successCount = 0
|
|
286
|
+
$errorCount = 0
|
|
287
|
+
|
|
288
|
+
for ($i = 1; $i -le 5; $i++) {
|
|
289
|
+
try {
|
|
290
|
+
$result = Invoke-RestMethod -Uri "$BaseUrl/sessions" -TimeoutSec 5
|
|
291
|
+
if ($result.success -eq $true) {
|
|
292
|
+
$successCount++
|
|
293
|
+
} else {
|
|
294
|
+
$errorCount++
|
|
295
|
+
}
|
|
296
|
+
} catch {
|
|
297
|
+
$errorCount++
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if ($successCount -ge 3) {
|
|
302
|
+
Write-Success "Server handled rapid requests ($successCount/5 successful)"
|
|
303
|
+
$PassedTests++
|
|
304
|
+
} else {
|
|
305
|
+
Write-ErrorUnexpected "Too many failures in rapid requests ($errorCount/5 failed)"
|
|
306
|
+
$FailedTests++
|
|
307
|
+
}
|
|
308
|
+
} catch {
|
|
309
|
+
Write-ErrorUnexpected "Exception during rapid requests: $($_.Exception.Message)"
|
|
310
|
+
$FailedTests++
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
# =============================================================================
|
|
314
|
+
# TEST 9: Session info structure (if sessions exist)
|
|
315
|
+
# =============================================================================
|
|
316
|
+
Write-TestHeader "Session info - Validate session object structure" 9 $TotalTests
|
|
317
|
+
|
|
318
|
+
try {
|
|
319
|
+
$result = Invoke-RestMethod -Uri "$BaseUrl/sessions" -TimeoutSec 10
|
|
320
|
+
|
|
321
|
+
if ($result.success -eq $true) {
|
|
322
|
+
$sessions = $result.data.sessions
|
|
323
|
+
|
|
324
|
+
if ($sessions.Count -gt 0) {
|
|
325
|
+
$session = $sessions[0]
|
|
326
|
+
|
|
327
|
+
# Check for expected session fields
|
|
328
|
+
$hasId = $null -ne $session.id
|
|
329
|
+
$hasCreated = $null -ne $session.created_at -or $null -ne $session.createdAt
|
|
330
|
+
$hasActivity = $null -ne $session.last_activity -or $null -ne $session.lastActivity
|
|
331
|
+
|
|
332
|
+
if ($hasId) {
|
|
333
|
+
Write-Success "Session object has required 'id' field"
|
|
334
|
+
Write-Info "Session ID: $($session.id)"
|
|
335
|
+
if ($hasCreated) { Write-Info "Has created_at timestamp" }
|
|
336
|
+
if ($hasActivity) { Write-Info "Has last_activity timestamp" }
|
|
337
|
+
$PassedTests++
|
|
338
|
+
} else {
|
|
339
|
+
Write-ErrorUnexpected "Session object missing 'id' field"
|
|
340
|
+
$FailedTests++
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
Write-Info "No active sessions to validate structure"
|
|
344
|
+
Write-Info "Test passed (no sessions to check)"
|
|
345
|
+
$PassedTests++
|
|
346
|
+
}
|
|
347
|
+
} else {
|
|
348
|
+
Write-ErrorUnexpected "Failed to get sessions: $($result.error)"
|
|
349
|
+
$FailedTests++
|
|
350
|
+
}
|
|
351
|
+
} catch {
|
|
352
|
+
Write-ErrorUnexpected "Exception: $($_.Exception.Message)"
|
|
353
|
+
$FailedTests++
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
# =============================================================================
|
|
357
|
+
# TEST 10: Session count consistency
|
|
358
|
+
# =============================================================================
|
|
359
|
+
Write-TestHeader "Session count - Verify count matches array length" 10 $TotalTests
|
|
360
|
+
|
|
361
|
+
try {
|
|
362
|
+
$result = Invoke-RestMethod -Uri "$BaseUrl/sessions" -TimeoutSec 10
|
|
363
|
+
|
|
364
|
+
if ($result.success -eq $true) {
|
|
365
|
+
$sessions = $result.data.sessions
|
|
366
|
+
$reportedCount = $result.data.total_count
|
|
367
|
+
|
|
368
|
+
$actualCount = if ($sessions) { $sessions.Count } else { 0 }
|
|
369
|
+
|
|
370
|
+
if ($null -eq $reportedCount) {
|
|
371
|
+
Write-Info "No total_count field (using array length)"
|
|
372
|
+
Write-Success "Sessions array has $actualCount items"
|
|
373
|
+
$PassedTests++
|
|
374
|
+
} elseif ($reportedCount -eq $actualCount) {
|
|
375
|
+
Write-Success "Session count matches: $reportedCount"
|
|
376
|
+
$PassedTests++
|
|
377
|
+
} else {
|
|
378
|
+
Write-ErrorUnexpected "Count mismatch: reported=$reportedCount, actual=$actualCount"
|
|
379
|
+
$FailedTests++
|
|
380
|
+
}
|
|
381
|
+
} else {
|
|
382
|
+
Write-ErrorUnexpected "Failed to get sessions: $($result.error)"
|
|
383
|
+
$FailedTests++
|
|
384
|
+
}
|
|
385
|
+
} catch {
|
|
386
|
+
Write-ErrorUnexpected "Exception: $($_.Exception.Message)"
|
|
387
|
+
$FailedTests++
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
# =============================================================================
|
|
391
|
+
# FINAL SUMMARY
|
|
392
|
+
# =============================================================================
|
|
393
|
+
Write-Host "`n" -NoNewline
|
|
394
|
+
Write-Host "╔════════════════════════════════════════════════════════╗" -ForegroundColor Magenta
|
|
395
|
+
Write-Host "║ ║" -ForegroundColor Magenta
|
|
396
|
+
Write-Host "║ SESSION MANAGEMENT TEST SUMMARY ║" -ForegroundColor Cyan
|
|
397
|
+
Write-Host "║ ║" -ForegroundColor Magenta
|
|
398
|
+
Write-Host "╚════════════════════════════════════════════════════════╝" -ForegroundColor Magenta
|
|
399
|
+
Write-Host ""
|
|
400
|
+
|
|
401
|
+
$TotalExecuted = $PassedTests + $FailedTests
|
|
402
|
+
$SuccessRate = if ($TotalExecuted -gt 0) { [math]::Round(($PassedTests / $TotalExecuted) * 100, 1) } else { 0 }
|
|
403
|
+
|
|
404
|
+
Write-Host "Total tests: $TotalTests" -ForegroundColor White
|
|
405
|
+
Write-Host "Tests passed: " -NoNewline -ForegroundColor White
|
|
406
|
+
Write-Host "$PassedTests" -ForegroundColor Green
|
|
407
|
+
Write-Host "Tests failed: " -NoNewline -ForegroundColor White
|
|
408
|
+
Write-Host "$FailedTests" -ForegroundColor $(if($FailedTests -gt 0){"Red"}else{"Green"})
|
|
409
|
+
Write-Host "Success rate: " -NoNewline -ForegroundColor White
|
|
410
|
+
Write-Host "$SuccessRate%" -ForegroundColor $(if($SuccessRate -eq 100){"Green"}elseif($SuccessRate -ge 80){"Yellow"}else{"Red"})
|
|
411
|
+
|
|
412
|
+
Write-Host ""
|
|
413
|
+
|
|
414
|
+
if ($FailedTests -eq 0) {
|
|
415
|
+
Write-Host "════════════════════════════════════════════════════════" -ForegroundColor Green
|
|
416
|
+
Write-Host " ✓ ALL SESSION MANAGEMENT TESTS PASSED!" -ForegroundColor Green
|
|
417
|
+
Write-Host "════════════════════════════════════════════════════════" -ForegroundColor Green
|
|
418
|
+
exit 0
|
|
419
|
+
} else {
|
|
420
|
+
Write-Host "════════════════════════════════════════════════════════" -ForegroundColor Yellow
|
|
421
|
+
Write-Host " ⚠ SOME SESSION TESTS FAILED" -ForegroundColor Yellow
|
|
422
|
+
Write-Host "════════════════════════════════════════════════════════" -ForegroundColor Yellow
|
|
423
|
+
Write-Host ""
|
|
424
|
+
Write-Host "See details above to identify the issues." -ForegroundColor Yellow
|
|
425
|
+
exit 1
|
|
426
|
+
}
|