Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

51 řádky
1.5KB

  1. [CmdletBinding()]
  2. param(
  3. [Parameter(Mandatory = $true)]
  4. [string]$BaseUrl
  5. )
  6. $script:failures = 0
  7. function Report {
  8. param($ok, $label, $detail)
  9. if ($ok) {
  10. Write-Output "PASS: $label"
  11. } else {
  12. Write-Output "FAIL: $label ($detail)"
  13. $script:failures++
  14. }
  15. }
  16. try {
  17. $resp = Invoke-WebRequest -Uri "$BaseUrl/hello" -UseBasicParsing
  18. Report ($resp.StatusCode -eq 200) "GET /hello status 200" "got $($resp.StatusCode)"
  19. Report ($resp.Headers['Content-Type'] -eq 'text/html; charset=utf-8') "GET /hello content-type" "got $($resp.Headers['Content-Type'])"
  20. Report ($resp.Content -eq 'Hello from WSC-MVC!') "GET /hello body" "got '$($resp.Content)'"
  21. } catch {
  22. Report $false "GET /hello request" $_.Exception.Message
  23. }
  24. try {
  25. $wscResp = Invoke-WebRequest -Uri "$BaseUrl/Framework/Application.wsc" -UseBasicParsing
  26. Report $false "GET /Framework/Application.wsc denied" "got $($wscResp.StatusCode)"
  27. } catch [System.Net.WebException] {
  28. $webResp = $_.Exception.Response
  29. if ($webResp) {
  30. $code = [int]$webResp.StatusCode
  31. Report ($code -eq 404) "GET /Framework/Application.wsc denied" "got $code"
  32. } else {
  33. Report $false "GET /Framework/Application.wsc denied" $_.Exception.Message
  34. }
  35. } catch {
  36. Report $false "GET /Framework/Application.wsc denied" $_.Exception.Message
  37. }
  38. Write-Output "---"
  39. if ($script:failures -eq 0) {
  40. Write-Output "RESULT: ALL PASS"
  41. exit 0
  42. } else {
  43. Write-Output "RESULT: $($script:failures) FAILURE(S)"
  44. exit 1
  45. }

Powered by TurnKey Linux.