1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <cstring> 17 #include "gtest/gtest.h" 18 #include "http_request_options.h" 19 #include "netstack_log.h" 20 21 using namespace OHOS::NetStack::Http; 22 23 class HttpRequestOptionsTest : public testing::Test { 24 public: SetUpTestCase()25 static void SetUpTestCase() {} 26 TearDownTestCase()27 static void TearDownTestCase() {} 28 SetUp()29 virtual void SetUp() {} 30 TearDown()31 virtual void TearDown() {} 32 }; 33 34 namespace { 35 using namespace std; 36 using namespace testing::ext; 37 constexpr char OTHER_CA_PATH[] = "/etc/ssl/certs/other.pem"; 38 39 HWTEST_F(HttpRequestOptionsTest, CaPathTest001, TestSize.Level1) 40 { 41 HttpRequestOptions requestOptions; 42 43 string path = requestOptions.GetCaPath(); 44 EXPECT_EQ(path, HttpConstant::HTTP_DEFAULT_CA_PATH); 45 } 46 47 HWTEST_F(HttpRequestOptionsTest, CaPathTest002, TestSize.Level1) 48 { 49 HttpRequestOptions requestOptions; 50 51 requestOptions.SetCaPath(""); 52 string path = requestOptions.GetCaPath(); 53 EXPECT_EQ(path, HttpConstant::HTTP_DEFAULT_CA_PATH); 54 } 55 56 HWTEST_F(HttpRequestOptionsTest, CaPathTest003, TestSize.Level1) 57 { 58 HttpRequestOptions requestOptions; 59 60 requestOptions.SetCaPath(OTHER_CA_PATH); 61 string path = requestOptions.GetCaPath(); 62 EXPECT_EQ(path, OTHER_CA_PATH); 63 } 64 } // namespace