-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathTLSContextTest.cpp
54 lines (41 loc) · 1.69 KB
/
TLSContextTest.cpp
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
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/crt/Api.h>
#include <aws/testing/aws_test_harness.h>
#include <utility>
#if !BYO_CRYPTO
static int s_TestTLSContextResourceSafety(Aws::Crt::Allocator *allocator, void *ctx)
{
(void)ctx;
{
Aws::Crt::ApiHandle apiHandle(allocator);
Aws::Crt::Io::TlsContextOptions tlsCtxOptions = Aws::Crt::Io::TlsContextOptions::InitDefaultClient();
tlsCtxOptions.SetTlsCipherPreference(AWS_IO_TLS_CIPHER_PREF_SYSTEM_DEFAULT);
Aws::Crt::Io::TlsContext tlsContext(tlsCtxOptions, Aws::Crt::Io::TlsMode::CLIENT, allocator);
ASSERT_TRUE(tlsContext);
auto tlsContextPostMove = std::move(tlsContext);
ASSERT_TRUE(tlsContextPostMove);
// NOLINTNEXTLINE
ASSERT_FALSE(tlsContext);
auto tlsConnectionOptions = tlsContextPostMove.NewConnectionOptions();
}
return AWS_ERROR_SUCCESS;
}
AWS_TEST_CASE(TLSContextResourceSafety, s_TestTLSContextResourceSafety)
static int s_TestTLSContextUninitializedNewConnectionOptions(Aws::Crt::Allocator *allocator, void *ctx)
{
(void)ctx;
{
Aws::Crt::ApiHandle apiHandle(allocator);
// Intentionally create an uninitialized TlsContext
Aws::Crt::Io::TlsContext tlsContext;
Aws::Crt::Io::TlsConnectionOptions options = tlsContext.NewConnectionOptions();
// Options should be uninitialized, but creating them should not result in a crash.
ASSERT_TRUE(!options);
}
return AWS_ERROR_SUCCESS;
}
AWS_TEST_CASE(TLSContextUninitializedNewConnectionOptions, s_TestTLSContextUninitializedNewConnectionOptions)
#endif // !BYO_CRYPTO