test_admin.ps1 2.4 KB

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