end2end_tests.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #ifndef GRPC_TEST_CORE_END2END_END2END_TESTS_H
  19. #define GRPC_TEST_CORE_END2END_END2END_TESTS_H
  20. #include <grpc/grpc.h>
  21. typedef struct grpc_end2end_test_fixture grpc_end2end_test_fixture;
  22. typedef struct grpc_end2end_test_config grpc_end2end_test_config;
  23. /* Test feature flags. */
  24. #define FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION 1
  25. #define FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION 2
  26. // Feature mask supports call credentials with a minimum security level of
  27. // GRPC_PRIVACY_AND_INTEGRITY.
  28. #define FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS 4
  29. // Feature mask supports call credentials with a minimum security level of
  30. // GRPC_SECURTITY_NONE.
  31. #define FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS_LEVEL_INSECURE 8
  32. #define FEATURE_MASK_SUPPORTS_REQUEST_PROXYING 16
  33. #define FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL 32
  34. #define FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER 64
  35. #define FEATURE_MASK_DOES_NOT_SUPPORT_RESOURCE_QUOTA_SERVER 128
  36. #define FEATURE_MASK_DOES_NOT_SUPPORT_NETWORK_STATUS_CHANGE 256
  37. #define FEATURE_MASK_SUPPORTS_WORKAROUNDS 512
  38. #define FEATURE_MASK_DOES_NOT_SUPPORT_CLIENT_HANDSHAKE_COMPLETE_FIRST 1024
  39. #define FAIL_AUTH_CHECK_SERVER_ARG_NAME "fail_auth_check"
  40. struct grpc_end2end_test_fixture {
  41. grpc_completion_queue* cq;
  42. grpc_completion_queue* shutdown_cq;
  43. grpc_server* server;
  44. grpc_channel* client;
  45. void* fixture_data;
  46. };
  47. struct grpc_end2end_test_config {
  48. /* A descriptive name for this test fixture. */
  49. const char* name;
  50. /* Which features are supported by this fixture. See feature flags above. */
  51. uint32_t feature_mask;
  52. /* If the call host is setup by the fixture (for example, via the
  53. * GRPC_SSL_TARGET_NAME_OVERRIDE_ARG channel arg), which value should the test
  54. * expect to find in call_details.host */
  55. const char* overridden_call_host;
  56. grpc_end2end_test_fixture (*create_fixture)(
  57. const grpc_channel_args* client_args,
  58. const grpc_channel_args* server_args);
  59. void (*init_client)(grpc_end2end_test_fixture* f,
  60. const grpc_channel_args* client_args);
  61. void (*init_server)(grpc_end2end_test_fixture* f,
  62. const grpc_channel_args* server_args);
  63. void (*tear_down_data)(grpc_end2end_test_fixture* f);
  64. };
  65. void grpc_end2end_tests_pre_init(void);
  66. void grpc_end2end_tests(int argc, char** argv, grpc_end2end_test_config config);
  67. const char* get_host_override_string(const char* str,
  68. grpc_end2end_test_config config);
  69. /* Returns a pointer to a statically allocated slice: future invocations
  70. overwrite past invocations, not threadsafe, etc... */
  71. const grpc_slice* get_host_override_slice(const char* str,
  72. grpc_end2end_test_config config);
  73. void validate_host_override_string(const char* pattern, grpc_slice str,
  74. grpc_end2end_test_config config);
  75. #endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */