1 // Copyright (c) 2023 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #![cfg(all(
15     feature = "async",
16     feature = "http1_1",
17     feature = "ylong_base",
18     feature = "__tls"
19 ))]
20 
21 #[macro_use]
22 pub mod tcp_server;
23 
24 use ylong_http_client::async_impl::Client;
25 use ylong_http_client::{Certificate, TlsVersion};
26 
27 /// UT test cases for `Client::builder` function.
28 ///
29 /// # Brief
30 /// 1. Calls `Client::builder`.
31 /// 2. Checks if the results are correct.
32 #[test]
sdv_client_tls_builder()33 fn sdv_client_tls_builder() {
34     let client = Client::builder()
35         .max_tls_version(TlsVersion::TLS_1_3)
36         .min_tls_version(TlsVersion::TLS_1_0)
37         .add_root_certificate(Certificate::from_pem(b"cert").unwrap())
38         .tls_ca_file("ca.crt")
39         .tls_cipher_list("DEFAULT:!aNULL:!eNULL:!MD5:!3DES:!DES:!RC4:!IDEA:!SEED:!aDSS:!SRP:!PSK")
40         .tls_cipher_suites("DEFAULT:!aNULL:!eNULL:!MD5:!3DES:!DES:!RC4:!IDEA:!SEED:!aDSS:!SRP:!PSK")
41         .tls_built_in_root_certs(false)
42         .danger_accept_invalid_certs(false)
43         .danger_accept_invalid_hostnames(false)
44         .tls_sni(false)
45         .build();
46 
47     assert!(client.is_err());
48 }
49