Merge test folder of test branch
[iotivity.git] / test / src / tc / pm / gtest / csdk / include / PMCsdkUtilityHelper.h
1 /******************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *
20  ******************************************************************/
21
22 #ifndef PMCsdkUtilityHelper_H_
23 #define PMCsdkUtilityHelper_H_
24
25 #ifdef __GNUC__
26 #pragma GCC system_header
27 #endif
28
29 #include <stddef.h>
30 #include <string>
31 #include "casecurityinterface.h"
32 #include "cathreadpool.h"
33 #include "occloudprovisioning.h"
34 #include "ocpayload.h"
35 #include "ocprovisioningmanager.h"
36 #include "ocstack.h"
37 #include "oic_malloc.h"
38 #include "oic_string.h"
39 #include "crlresource.h"
40 #include "oxmjustworks.h"
41 #include "oxmrandompin.h"
42 #include "oxmverifycommon.h"
43 #ifdef MULTIPLE_OWNER
44 #include "experimental/securevirtualresourcetypes.h"
45 #endif //MULTIPLE_OWNER
46 #include "OCAccountManager.h"
47 #include "OCApi.h"
48 #include "OCPlatform.h"
49 #include "OCPlatform_impl.h"
50 #include "payload_logging.h"
51 #include "pmtypes.h"
52 #include "rd_client.h"
53 #include "srmutility.h"
54 #include "ssl_ciphersuites.h"
55 #include "utils.h"
56 #include "utlist.h"
57 #include "mbedtls/config.h"
58 #include "mbedtls/pem.h"
59 #include "mbedtls/x509_csr.h"
60 #include "occertutility.h"
61
62 #include "CommonUtil.h"
63 #include "CommonTestUtil.h"
64 #include "SecurityCommonUtil.h"
65 #include "CommonProperties.h"
66 #include "IotivityTest_Logger.h"
67
68 using namespace std;
69 using namespace OC;
70
71 #define TAG "PM CPP"
72 /**
73  *  Server and Client Resources
74  */
75 #define KILL_SERVERS "iotivity_pm_ser"
76
77 #define SVR_DB_FILE_NAME "oic_svr_db_client.dat"
78 #define AUTO_PROVISION_SVR_DB_FILE_NAME "oic_autoprvn_mng.db"
79 #define PRVN_DB_FILE_NAME "oic_prvn_mng.db"
80 #define JUSTWORKS_SERVER1 "./iotivity_pm_server oic_svr_db_server.dat 1"
81 #define JUSTWORKS_SERVER2 "./iotivity_pm_server oic_svr_db_server_justworks.dat 1"
82 #define RANDOMPIN_SERVER "./iotivity_pm_server oic_svr_db_server_randompin.dat 2"
83 #define MV_JUSTWORKS_SERVER "./iotivity_pm_server oic_svr_db_server_mvjustworks.dat 4"
84
85 #define JUSTWORKS_SERVER1_CBOR "./oic_svr_db_server.dat"
86 #define JUSTWORKS_SERVER1_CBOR_BACKUP "../oic_svr_db_server.dat"
87 #define JUSTWORKS_SERVER2_CBOR "./oic_svr_db_server_justworks.dat"
88 #define JUSTWORKS_SERVER2_CBOR_BACKUP "../oic_svr_db_server_justworks.dat"
89 #define RANDOMPIN_SERVER_CBOR "./oic_svr_db_server_randompin.dat"
90 #define RANDOMPIN_SERVER_CBOR_BACKUP "../oic_svr_db_server_randompin.dat"
91 #define CLIENT_CBOR "./oic_svr_db_client.dat"
92 #define CLIENT_CBOR_BACKUP "../oic_svr_db_client.dat"
93 #define CLIENT_DATABASE "./oic_prvn_mng.db"
94 #define AUTO_PROVISION_CLIENT_DATABASE "./oic_autoprvn_mng.db"
95 #define DATABASE_PDM "./PDM.db"
96
97 #define MV_JUSTWORKS_SERVER_CBOR "./oic_svr_db_server_mvjustworks.dat"
98 #define MV_JUSTWORKS_SERVER_CBOR_BACKUP "../oic_svr_db_server_mvjustworks.dat"
99
100 #define DEVICE_PROPERTIES "./device_properties.dat"
101
102 /**
103  * MOT Resources
104  */
105 #define JUSTWORKS_SERVER "./sampleserver_justworks"
106 #define JUSTWORKS_SERVER7 "./iotivity_pm_server mot_preconfig_pin_server.dat 1"
107 #define JUSTWORKS_SERVER7_CBOR "./mot_preconfig_pin_server.dat"
108 #define JUSTWORKS_SERVER7_CBOR_BACKUP "../mot_preconfig_pin_server.dat"
109 #define JUSTWORKS_SERVER2_CBOR "./oic_svr_db_server_justworks.dat"
110 #define JUSTWORKS_SERVER2_CBOR_BACKUP "../oic_svr_db_server_justworks.dat"
111
112 #define PRECONFIG_SERVER1 "./iotivity_pm_server preconfig_server_1.dat 3"
113 #define PRECONFIG_SERVER2 "./iotivity_pm_server preconfig_server_2.dat 3"
114 #define PRECONFIG_SERVER1_CBOR "./preconfig_server_1.dat"
115 #define PRECONFIG_SERVER1_CBOR_BACKUP "../preconfig_server_1.dat"
116 #define PRECONFIG_SERVER2_CBOR "./preconfig_server_2.dat"
117 #define PRECONFIG_SERVER2_CBOR_BACKUP "../preconfig_server_2.dat"
118
119 #define MOT_CTX "MOT Context"
120 #define MOT_CBOR_FILE "oic_svr_db_subowner_client.dat"
121 #define MOT_PRVN_DB_FILE_NAME "oic_pdm_subowner.db"
122 #define MOT_CLIENT_CBOR "./oic_svr_db_subowner_client.dat"
123 #define MOT_CLIENT_CBOR_BACKUP "../oic_svr_db_subowner_client.dat"
124 #define MOT_CLIENT_DATABASE "./oic_pdm_subowner.db"
125 #define MOT_DEFAULT_PRE_CONFIG_PIN "12341234"
126 #define MOT_PRECONFIG_PIN_ZERO_SIZE 0
127 #define OIC_MULTIPLE_OWNER_UOBV 10
128
129 #define CTX_CERT_REQ_ISSUE "Cert Request Context"
130 #define CTX_PROV_TRUST_CERT "Trust Cert Context"
131 #define ROOT_CERT_FILE "rootca.crt"
132 #define ROOT_CERT_FILE_TMP "./rootca.crt"
133 #define ROOT_CERT_FILE_BACKUP "../rootca.crt"
134 #define TEST_CERT_ROLE1 "IoTivity-test-role1"
135
136 class PMCsdkUtilityHelper
137 {
138
139 public:
140
141     static OCProvisionDev_t* getDevInst(OCProvisionDev_t* dev_lst, const int dev_num);
142
143     static int printDevList(OCProvisionDev_t*);
144
145     static bool checkResultList(const OCProvisionResult_t* rslt_lst, const size_t rslt_cnt, int expectedResult);
146
147     static int printResultList(const OCProvisionResult_t*, const size_t);
148
149     static size_t printUuidList(const OCUuidList_t*);
150
151     static void printUuid(const OicUuid_t*);
152
153     static char* getOxmType(OicSecOxm_t oxmType);
154
155     static void removeAllResFile();
156
157     static std::string setFailureMessage(OCStackResult actualResult, OCStackResult expectedResult);
158
159     static std::string setFailureMessage(OicSecOxm_t actualResult, OicSecOxm_t expectedResult);
160
161     static std::string setFailureMessage(std::string errorMessage);
162 };
163
164 #endif /* PMCsdkUtilityHelper_H_ */