test_admin3.ps1 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Test his endpoints on fs-admin (8003) with proper token
  2. $loginBody = @{
  3. tenantCode = "T202605253515"
  4. username = "admin"
  5. password = "admin123"
  6. } | ConvertTo-Json
  7. $resp = Invoke-RestMethod -Uri "http://localhost:8006/login" -Method POST -ContentType "application/json" -Body $loginBody
  8. $token = $resp.token
  9. $headers = @{ Authorization = "Bearer $token" }
  10. Write-Output "=== Testing all his/health/course endpoints on fs-admin (8003) ==="
  11. $adminEndpoints = @(
  12. "/his/healthTongue/list",
  13. "/his/healthRecord/list",
  14. "/his/drugReport/list",
  15. "/his/drugReportCount/list",
  16. "/his/exportTask/list",
  17. "/his/inquiryOrderReport/list",
  18. "/his/tongue/list",
  19. "/his/user/list",
  20. "/his/userCoupon/list",
  21. "/his/storePayment/list",
  22. "/his/storeOrder/list",
  23. "/his/storeProduct/list",
  24. "/his/coupon/list",
  25. "/his/doctor/list",
  26. "/his/package/list",
  27. "/his/testReport/list",
  28. "/his/testTemp/list",
  29. "/his/testTempItem/list",
  30. "/his/inquiryOrder/list",
  31. "/his/inquiryTemp/list",
  32. "/his/inquiryDisease/list",
  33. "/his/physicalReportTemplate/list",
  34. "/his/physicalReportTemplateField/list",
  35. "/course/courseDomainName/list",
  36. "/course/courseQuestionBank/list",
  37. "/course/courseAnswerLog/list",
  38. "/course/courseRedPacketLog/list",
  39. "/course/courseWatchLog/list",
  40. "/billing/wallet/list",
  41. "/qw/qwGroupLiveCode/list",
  42. "/api/fee/wallet/1"
  43. )
  44. foreach ($path in $adminEndpoints) {
  45. try {
  46. $r = Invoke-WebRequest -Uri "http://localhost:8003$path" -Method GET -Headers $headers -UseBasicParsing -ErrorAction Stop
  47. $body = $r.Content | ConvertFrom-Json
  48. $code = $body.code
  49. $msg = if ($body.msg) { $body.msg.Substring(0, [Math]::Min(60, $body.msg.Length)) } else { "" }
  50. if ($code -eq 200) {
  51. Write-Output "OK 8003 $path"
  52. } else {
  53. Write-Output "ERR 8003 $path => code=$code msg=$msg"
  54. }
  55. } catch {
  56. $status = $_.Exception.Response.StatusCode.value__
  57. if ($status -eq 404) {
  58. Write-Output "404 8003 $path"
  59. } elseif ($status -eq 405) {
  60. Write-Output "405 8003 $path"
  61. } elseif ($status -eq 401) {
  62. Write-Output "401 8003 $path (auth issue)"
  63. } else {
  64. Write-Output "$status 8003 $path"
  65. }
  66. }
  67. }