Debian Codegraph @

crt/s2n/tests/unit/s2n_connection_context_test.c

raw symbols SCIP
1 /*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 #include <stdlib.h>
17
18 #include "api/s2n.h"
19 #include "s2n_test.h"
20
21 int main(int argc, char **argv)
22 {
23 struct s2n_connection *conn = NULL;
24 int ctx = 0;
25
26 struct s2n_connection *conn_null = NULL;
27
28 BEGIN_TEST();
29 EXPECT_SUCCESS(s2n_disable_tls13_in_test());
30
31 EXPECT_NOT_NULL(conn = s2n_connection_new(S2N_SERVER));
32
33 /* Verify that we can set and get ctx */
34 EXPECT_SUCCESS(s2n_connection_set_ctx(conn, &ctx));
35 EXPECT_EQUAL(s2n_connection_get_ctx(conn), &ctx);
36
37 /* Verify that conext is cleaned up after wipe */
38 EXPECT_SUCCESS(s2n_connection_wipe(conn));
39 EXPECT_EQUAL(s2n_connection_get_ctx(conn), NULL);
40
41 EXPECT_SUCCESS(s2n_connection_free(conn));
42
43 /* Verify that we don't assume nonnull input and seg fault */
44 EXPECT_NULL(s2n_connection_get_cipher(conn_null));
45
46 END_TEST();
47 }