end2end_test_utils.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. *
  3. * Copyright 2015 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #include <string.h>
  19. #include <grpc/support/log.h>
  20. #include "test/core/end2end/end2end_tests.h"
  21. const char* get_host_override_string(const char* str,
  22. grpc_end2end_test_config config) {
  23. if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) {
  24. return str;
  25. } else {
  26. return nullptr;
  27. }
  28. }
  29. const grpc_slice* get_host_override_slice(const char* str,
  30. grpc_end2end_test_config config) {
  31. const char* r = get_host_override_string(str, config);
  32. if (r != nullptr) {
  33. static grpc_slice ret;
  34. ret = grpc_slice_from_static_string(r);
  35. return &ret;
  36. }
  37. return nullptr;
  38. }
  39. void validate_host_override_string(const char* pattern, grpc_slice str,
  40. grpc_end2end_test_config config) {
  41. if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) {
  42. GPR_ASSERT(0 == grpc_slice_str_cmp(str, pattern));
  43. }
  44. }