• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
19 #include "test/core/end2end/end2end_tests.h"
20 
21 #include <string.h>
22 
23 #include <grpc/support/log.h>
24 
get_host_override_string(const char * str,grpc_end2end_test_config config)25 const char* get_host_override_string(const char* str,
26                                      grpc_end2end_test_config config) {
27   if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) {
28     return str;
29   } else {
30     return nullptr;
31   }
32 }
33 
get_host_override_slice(const char * str,grpc_end2end_test_config config)34 const grpc_slice* get_host_override_slice(const char* str,
35                                           grpc_end2end_test_config config) {
36   const char* r = get_host_override_string(str, config);
37   if (r != nullptr) {
38     static grpc_slice ret;
39     ret = grpc_slice_from_static_string(r);
40     return &ret;
41   }
42   return nullptr;
43 }
44 
validate_host_override_string(const char * pattern,grpc_slice str,grpc_end2end_test_config config)45 void validate_host_override_string(const char* pattern, grpc_slice str,
46                                    grpc_end2end_test_config config) {
47   if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) {
48     GPR_ASSERT(0 == grpc_slice_str_cmp(str, pattern));
49   }
50 }
51