• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #include <gtest/gtest.h>
16 
17 #include "net_proxy_userinfo.h"
18 #include "rdb_errno.h"
19 #include "rdb_helper.h"
20 #include "rdb_open_callback.h"
21 #include "rdb_store.h"
22 #include "rdb_store_config.h"
23 #include "rdb_types.h"
24 
25 namespace OHOS {
26 namespace NetManagerStandard {
27 namespace {
28 constexpr const char *TEST_IPV4_ADDR = "127.0.0.1";
29 constexpr const char *PROXY_NAME = "123456789";
30 constexpr const int32_t PROXY_NAME_SIZE = 9;
31 }
32 using namespace testing::ext;
33 
34 class NetProxyUserinfoTest : public testing::Test {
35 public:
36     static void SetUpTestCase();
37     static void TearDownTestCase();
38     void SetUp();
39     void TearDown();
40 };
41 
SetUpTestCase()42 void NetProxyUserinfoTest::SetUpTestCase() {}
43 
TearDownTestCase()44 void NetProxyUserinfoTest::TearDownTestCase() {}
45 
SetUp()46 void NetProxyUserinfoTest::SetUp() {}
47 
TearDown()48 void NetProxyUserinfoTest::TearDown() {}
49 
50 HWTEST_F(NetProxyUserinfoTest, SaveHttpProxyUserAndPassTest001, TestSize.Level1)
51 {
52     HttpProxy httpProxy = {TEST_IPV4_ADDR, 8080, {}};
53     HttpProxy httpProxyForGet = {TEST_IPV4_ADDR, 8080, {}};
54     SecureData name;
55     name.append(PROXY_NAME, PROXY_NAME_SIZE);
56     SecureData pwd;
57     pwd.append(PROXY_NAME, PROXY_NAME_SIZE);
58     httpProxy.SetUserName(name);
59     httpProxy.SetPassword(pwd);
60     NetProxyUserinfo::GetInstance().SaveHttpProxyHostPass(httpProxy);
61     NetProxyUserinfo::GetInstance().GetHttpProxyHostPass(httpProxyForGet);
62     EXPECT_EQ(httpProxyForGet.GetUsername().empty(), false);
63 }
64 } // namespace NetManagerStandard
65 } // namespace OHOS