aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/tsi/alts/handshaker/alts_handshaker_service_api_test_lib.h
blob: 2fcbb4ea99a04b70dc0b2b52233129c6d867f8f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 *
 * Copyright 2018 gRPC authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#ifndef GRPC_TEST_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_TEST_LIB_H
#define GRPC_TEST_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_TEST_LIB_H

#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api.h"
#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h"
#include "src/core/tsi/alts/handshaker/transport_security_common_api.h"

/**
 * The first part of this file contains function signatures for de-serializing
 * ALTS handshake requests and setting/serializing ALTS handshake responses,
 * which simulate the behaviour of grpc server that runs ALTS handshaker
 * service.
 */

/**
 * This method creates a ALTS handshaker request that is used to hold
 * de-serialized result.
 */
grpc_gcp_handshaker_req* grpc_gcp_handshaker_decoded_req_create(
    grpc_gcp_handshaker_req_type type);

/* This method de-serializes a ALTS handshaker request. */
bool grpc_gcp_handshaker_req_decode(grpc_slice slice,
                                    grpc_gcp_handshaker_req* req);

/* This method serializes a ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_encode(grpc_gcp_handshaker_resp* resp,
                                     grpc_slice* slice);

/* This method sets application protocol of ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_application_protocol(
    grpc_gcp_handshaker_resp* resp, const char* application_protocol);

/* This method sets record protocol of ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_record_protocol(
    grpc_gcp_handshaker_resp* resp, const char* record_protocol);

/* This method sets key_data of ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_key_data(grpc_gcp_handshaker_resp* resp,
                                           const char* key_data, size_t size);

/* This method sets local identity's hostname for ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_local_identity_hostname(
    grpc_gcp_handshaker_resp* resp, const char* hostname);

/**
 * This method sets local identity's service account for ALTS handshaker
 * response.
 */
bool grpc_gcp_handshaker_resp_set_local_identity_service_account(
    grpc_gcp_handshaker_resp* resp, const char* service_account);

/* This method sets peer identity's hostname for ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_peer_identity_hostname(
    grpc_gcp_handshaker_resp* resp, const char* hostname);

/**
 * This method sets peer identity's service account for ALTS handshaker
 * response.
 */
bool grpc_gcp_handshaker_resp_set_peer_identity_service_account(
    grpc_gcp_handshaker_resp* resp, const char* service_account);

/* This method sets keep_channel_open for ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_channel_open(grpc_gcp_handshaker_resp* resp,
                                               bool keep_channel_open);

/* This method sets code for ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_code(grpc_gcp_handshaker_resp* resp,
                                       uint32_t code);

/* This method sets details for ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_details(grpc_gcp_handshaker_resp* resp,
                                          const char* details);

/* This method sets out_frames for ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_out_frames(grpc_gcp_handshaker_resp* resp,
                                             const char* out_frames,
                                             size_t size);

/* This method sets peer_rpc_versions for ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_peer_rpc_versions(
    grpc_gcp_handshaker_resp* resp, uint32_t max_major, uint32_t max_minor,
    uint32_t min_major, uint32_t min_minor);

/* This method sets bytes_consumed for ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_set_bytes_consumed(grpc_gcp_handshaker_resp* resp,
                                                 int32_t bytes_consumed);

/* This method serializes ALTS handshaker response. */
bool grpc_gcp_handshaker_resp_encode(grpc_gcp_handshaker_resp* resp,
                                     grpc_slice* slice);

/* This method de-serializes ALTS handshaker request. */
bool grpc_gcp_handshaker_req_decode(grpc_slice slice,
                                    grpc_gcp_handshaker_req* req);

/**
 * The second part contains function signatures for checking equality of a pair
 * of ALTS handshake requests/responses.
 */

/* This method checks equality of two client_start handshaker requests. */
bool grpc_gcp_handshaker_client_start_req_equals(
    grpc_gcp_start_client_handshake_req* l_req,
    grpc_gcp_start_client_handshake_req* r_req);

/* This method checks equality of two server_start handshaker requests. */
bool grpc_gcp_handshaker_server_start_req_equals(
    grpc_gcp_start_server_handshake_req* l_req,
    grpc_gcp_start_server_handshake_req* r_req);

/* This method checks equality of two ALTS handshaker requests. */
bool grpc_gcp_handshaker_req_equals(grpc_gcp_handshaker_req* l_req,
                                    grpc_gcp_handshaker_req* r_req);

/* This method checks equality of two handshaker response results. */
bool grpc_gcp_handshaker_resp_result_equals(
    grpc_gcp_handshaker_result* l_result, grpc_gcp_handshaker_result* r_result);

/* This method checks equality of two ALTS handshaker responses. */
bool grpc_gcp_handshaker_resp_equals(grpc_gcp_handshaker_resp* l_resp,
                                     grpc_gcp_handshaker_resp* r_resp);

#endif  // GRPC_TEST_CORE_TSI_ALTS_HANDSHAKER_ALTS_HANDSHAKER_SERVICE_API_TEST_LIB_H