proxy.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. # Copyright 2018 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. run_kubectl_local_proxy_tests() {
  19. set -o nounset
  20. set -o errexit
  21. kube::log::status "Testing kubectl local proxy"
  22. start-proxy
  23. check-curl-proxy-code /api/kubernetes 404
  24. check-curl-proxy-code /api/v1/namespaces 200
  25. if kube::test::if_supports_resource "metrics" ; then
  26. check-curl-proxy-code /metrics 200
  27. fi
  28. if kube::test::if_supports_resource "static" ; then
  29. check-curl-proxy-code /static/ 200
  30. fi
  31. stop-proxy
  32. # Make sure the in-development api is accessible by default
  33. start-proxy
  34. check-curl-proxy-code /apis 200
  35. check-curl-proxy-code /apis/extensions/ 200
  36. stop-proxy
  37. # Custom paths let you see everything.
  38. start-proxy /custom
  39. check-curl-proxy-code /custom/api/kubernetes 404
  40. check-curl-proxy-code /custom/api/v1/namespaces 200
  41. if kube::test::if_supports_resource "metrics" ; then
  42. check-curl-proxy-code /custom/metrics 200
  43. fi
  44. check-curl-proxy-code /custom/api/v1/namespaces 200
  45. stop-proxy
  46. set +o nounset
  47. set +o errexit
  48. }