test_all.ps1 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Test login with correct path
  2. $loginBody = @{
  3. tenantCode = "T202605253515"
  4. username = "admin"
  5. password = "FFuxUo5bC^ui"
  6. } | ConvertTo-Json
  7. Write-Output "=== Testing Login with /login ==="
  8. try {
  9. $resp = Invoke-RestMethod -Uri "http://localhost:8006/login" -Method POST -ContentType "application/json" -Body $loginBody
  10. Write-Output "Login code: $($resp.code)"
  11. Write-Output "Login msg: $($resp.msg)"
  12. if ($resp.token) {
  13. Write-Output "Token: $($resp.token.Substring(0,30))..."
  14. $script:token = $resp.token
  15. }
  16. } catch {
  17. Write-Output "Login error: $($_.Exception.Message)"
  18. if ($_.Exception.Response) {
  19. $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
  20. $reader.BaseStream.Position = 0
  21. Write-Output "Response body: $($reader.ReadToEnd())"
  22. }
  23. }
  24. if ($script:token) {
  25. Write-Output ""
  26. Write-Output "=== Testing key endpoints with token ==="
  27. $headers = @{ Authorization = "Bearer $script:token" }
  28. $endpoints = @(
  29. "/chat/chatMsg/list",
  30. "/chat/chatMsgLogs/list",
  31. "/chat/chatSession/list",
  32. "/his/redPacket/info",
  33. "/store/storeStatistics/list",
  34. "/store/store/storeOrderOffline/list",
  35. "/store/store/storeOrderAudit/list",
  36. "/store/store/statistics/list",
  37. "/his/integralGoods/list",
  38. "/his/integralOrder/list",
  39. "/billing/wallet/list",
  40. "/course/courseDomainName/list",
  41. "/course/courseQuestionBank/list",
  42. "/qwSop/sopUserLogsWx/list",
  43. "/index/statistics/rechargeComsumption",
  44. "/crm/statistics/customer",
  45. "/qw/qwGroupLiveCode/list",
  46. "/store/collection/list",
  47. "/course/courseAnswerLog/list",
  48. "/transfer/transfer/list",
  49. "/transfer/voiceLog/list",
  50. "/his/tongue/list",
  51. "/his/healthRecord/list",
  52. "/his/medicineReport/list",
  53. "/his/inquiryReport/list"
  54. )
  55. foreach ($ep in $endpoints) {
  56. try {
  57. $r = Invoke-WebRequest -Uri "http://localhost:8006$ep" -Method GET -Headers $headers -ErrorAction Stop
  58. $body = $r.Content | ConvertFrom-Json
  59. Write-Output "$ep => HTTP $($r.StatusCode) code=$($body.code) msg=$($body.msg)"
  60. } catch {
  61. $status = $_.Exception.Response.StatusCode.value__
  62. if ($status -eq 404) {
  63. Write-Output "$ep => HTTP 404 NOT FOUND"
  64. } elseif ($status -eq 405) {
  65. Write-Output "$ep => HTTP 405 Method Not Allowed"
  66. } else {
  67. Write-Output "$ep => HTTP $status ERROR: $($_.Exception.Message)"
  68. }
  69. }
  70. }
  71. }