| 1 |
#ifndef AWS_AUTH_CREDENTIALS_PROVIDER_MOCK_H |
| 2 |
#define AWS_AUTH_CREDENTIALS_PROVIDER_MOCK_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/auth/private/aws_profile.h> |
| 10 |
#include <aws/auth/private/credentials_utils.h> |
| 11 |
|
| 12 |
#include <aws/common/condition_variable.h> |
| 13 |
#include <aws/common/mutex.h> |
| 14 |
#include <aws/http/connection_manager.h> |
| 15 |
#include <aws/http/request_response.h> |
| 16 |
|
| 17 |
struct aws_credentials; |
| 18 |
struct aws_credentials_provider; |
| 19 |
struct aws_credentials_provider_shutdown_options; |
| 20 |
struct aws_event_loop_group; |
| 21 |
struct aws_string; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
struct aws_get_credentials_test_callback_result { |
| 39 |
struct aws_mutex sync; |
| 40 |
struct aws_condition_variable signal; |
| 41 |
struct aws_credentials *credentials; |
| 42 |
int count; |
| 43 |
int required_count; |
| 44 |
int last_error; |
| 45 |
}; |
| 46 |
|
| 47 |
void aws_get_credentials_test_callback_result_init( |
| 48 |
struct aws_get_credentials_test_callback_result *result, |
| 49 |
int required_count); |
| 50 |
void aws_get_credentials_test_callback_result_clean_up(struct aws_get_credentials_test_callback_result *result); |
| 51 |
|
| 52 |
void aws_wait_on_credentials_callback(struct aws_get_credentials_test_callback_result *result); |
| 53 |
|
| 54 |
void aws_test_get_credentials_async_callback(struct aws_credentials *credentials, int error_code, void *user_data); |
| 55 |
|
| 56 |
struct get_credentials_mock_result { |
| 57 |
int error_code; |
| 58 |
struct aws_credentials *credentials; |
| 59 |
}; |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
struct aws_credentials_provider *aws_credentials_provider_new_mock( |
| 65 |
struct aws_allocator *allocator, |
| 66 |
struct get_credentials_mock_result *results, |
| 67 |
size_t result_count, |
| 68 |
struct aws_credentials_provider_shutdown_options *shutdown_options); |
| 69 |
|
| 70 |
struct aws_credentials_provider *aws_credentials_provider_new_mock_async( |
| 71 |
struct aws_allocator *allocator, |
| 72 |
struct get_credentials_mock_result *results, |
| 73 |
size_t result_count, |
| 74 |
struct aws_event_loop_group *elg, |
| 75 |
struct aws_credentials_provider_shutdown_options *shutdown_options); |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
void aws_credentials_provider_mock_async_fire_callbacks(struct aws_credentials_provider *provider); |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
int mock_aws_get_system_time(uint64_t *current_time); |
| 85 |
void mock_aws_set_system_time(uint64_t current_time); |
| 86 |
|
| 87 |
int mock_aws_get_high_res_time(uint64_t *current_time); |
| 88 |
void mock_aws_set_high_res_time(uint64_t current_time); |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
struct aws_credentials_provider *aws_credentials_provider_new_null( |
| 94 |
struct aws_allocator *allocator, |
| 95 |
struct aws_credentials_provider_shutdown_options *shutdown_options); |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
int aws_create_directory_components(struct aws_allocator *allocator, const struct aws_string *path); |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
int aws_create_random_home_directory(struct aws_allocator *allocator, struct aws_string **out_path); |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
struct aws_credentials_provider_http_mock_tester { |
| 113 |
struct aws_tls_ctx *tls_ctx; |
| 114 |
struct aws_event_loop_group *el_group; |
| 115 |
struct aws_host_resolver *resolver; |
| 116 |
struct aws_client_bootstrap *bootstrap; |
| 117 |
|
| 118 |
struct aws_byte_buf request_path; |
| 119 |
struct aws_byte_buf request_body; |
| 120 |
struct aws_http_make_request_options request_options; |
| 121 |
|
| 122 |
struct aws_array_list response_data_callbacks; |
| 123 |
bool is_connection_acquire_successful; |
| 124 |
bool is_request_successful; |
| 125 |
|
| 126 |
struct aws_mutex lock; |
| 127 |
struct aws_condition_variable signal; |
| 128 |
|
| 129 |
struct aws_credentials *credentials; |
| 130 |
bool has_received_credentials_callback; |
| 131 |
bool has_received_shutdown_callback; |
| 132 |
|
| 133 |
int attempts; |
| 134 |
int response_code; |
| 135 |
int error_code; |
| 136 |
int failure_response_code; |
| 137 |
int failure_count; |
| 138 |
}; |
| 139 |
|
| 140 |
extern struct aws_credentials_provider_http_mock_tester credentials_provider_http_mock_tester; |
| 141 |
int aws_credentials_provider_http_mock_tester_init(struct aws_allocator *allocator); |
| 142 |
void aws_credentials_provider_http_mock_tester_cleanup(void); |
| 143 |
void aws_credentials_provider_http_mock_on_shutdown_complete(void *user_data); |
| 144 |
bool aws_credentials_provider_http_mock_has_received_shutdown_callback(void *user_data); |
| 145 |
void aws_credentials_provider_http_mock_wait_for_shutdown_callback(void); |
| 146 |
struct aws_http_connection_manager *aws_credentials_provider_http_mock_connection_manager_new( |
| 147 |
struct aws_allocator *allocator, |
| 148 |
const struct aws_http_connection_manager_options *options); |
| 149 |
void aws_credentials_provider_http_mock_connection_manager_release(struct aws_http_connection_manager *manager); |
| 150 |
void aws_credentials_provider_http_mock_connection_manager_acquire_connection( |
| 151 |
struct aws_http_connection_manager *manager, |
| 152 |
aws_http_connection_manager_on_connection_setup_fn *callback, |
| 153 |
void *user_data); |
| 154 |
int aws_credentials_provider_http_mock_connection_manager_release_connection( |
| 155 |
struct aws_http_connection_manager *manager, |
| 156 |
struct aws_http_connection *connection); |
| 157 |
void aws_credentials_provider_http_mock_invoke_request_callbacks( |
| 158 |
const struct aws_http_make_request_options *options, |
| 159 |
struct aws_array_list *data_callbacks, |
| 160 |
bool is_request_successful); |
| 161 |
struct aws_http_stream *aws_credentials_provider_http_mock_make_request( |
| 162 |
struct aws_http_connection *client_connection, |
| 163 |
const struct aws_http_make_request_options *options); |
| 164 |
int aws_credentials_provider_http_mock_stream_activate(struct aws_http_stream *stream); |
| 165 |
int aws_credentials_provider_http_mock_stream_get_incoming_response_status( |
| 166 |
const struct aws_http_stream *stream, |
| 167 |
int *out_status_code); |
| 168 |
void aws_credentials_provider_http_mock_stream_release(struct aws_http_stream *stream); |
| 169 |
void aws_credentials_provider_http_mock_connection_close(struct aws_http_connection *connection); |
| 170 |
struct aws_http_connection *aws_credentials_provider_http_mock_stream_get_connection( |
| 171 |
const struct aws_http_stream *stream); |
| 172 |
bool aws_credentials_provider_http_mock_has_received_credentials_callback(void *user_data); |
| 173 |
void aws_credentials_provider_http_mock_wait_for_credentials_result(void); |
| 174 |
void aws_credentials_provider_http_mock_get_credentials_callback( |
| 175 |
struct aws_credentials *credentials, |
| 176 |
int error_code, |
| 177 |
void *user_data); |
| 178 |
extern struct aws_auth_http_system_vtable aws_credentials_provider_http_mock_function_table; |
| 179 |
|
| 180 |
#endif |