Commit f242aced authored by Oleksandr Dmytrenko's avatar Oleksandr Dmytrenko

The provisioning unittest

deviceonboardingstate tests added

Change-Id: Idd2f65bfab3909ac139d5e24855cc0e57ddbfe4c
Signed-off-by: default avatarOleksandr Dmytrenko <o.dmytrenko@samsung.com>
parent 492772b0
......@@ -232,7 +232,8 @@ if target_os in ['linux']:
'oxmmanufacturercert.cpp',
'oxmrandompin.cpp',
'credentialgenerator.cpp',
'otmunittest.cpp'
'otmunittest.cpp',
'deviceonboardingstate.cpp'
]
if sptest_env.get('WITH_TCP') == True and sptest_env.get('WITH_CLOUD') == True:
unittest_src.append('cloudresource.cpp')
......
/* *****************************************************************
*
* Copyright 2019 Samsung Electronics All Rights Reserved.
*
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* *****************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <gtest/gtest.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "ocprovisioningmanager.h"
#include "../src/deviceonboardingstate.c"
#include "tools.h"
#undef TAG
#ifdef __cplusplus
}
#endif
#define TAG "DOBT_UNITTEST"
#define SVR_DB_FILE_NAME "oic_dobt.dat"
#define PM_DB_FILE_NAME "oic_dovt.db"
using namespace std;
class DOBT : public ::testing::Test
{
public:
static void SetUpTestCase()
{
IOT_Init(PM_DB_FILE_NAME);
}
static void TearDownTestCase()
{
IOT_DeInit(PM_DB_FILE_NAME);
}
};
TEST_F(DOBT, DoStateChange)
{
EXPECT_EQ(OC_STACK_OK, DoStateChange(DOS_RESET));
EXPECT_EQ(OC_STACK_OK, DoStateChange(DOS_RFOTM));
EXPECT_EQ(OC_STACK_FORBIDDEN_REQ, DoStateChange(DOS_RFPRO));
EXPECT_EQ(OC_STACK_FORBIDDEN_REQ, DoStateChange(DOS_RFNOP));
EXPECT_EQ(OC_STACK_FORBIDDEN_REQ, DoStateChange(DOS_SRESET));
OicUuid_t *owner = createUuid();
EXPECT_EQ(OC_STACK_OK, SetDoxmSelfOwnership(owner));
EXPECT_EQ(OC_STACK_OK, DoStateChange(DOS_RESET));
EXPECT_EQ(OC_STACK_OK, DoStateChange(DOS_RFOTM));
EXPECT_EQ(OC_STACK_FORBIDDEN_REQ, DoStateChange(DOS_RFPRO));
EXPECT_EQ(OC_STACK_FORBIDDEN_REQ, DoStateChange(DOS_RFNOP));
EXPECT_EQ(OC_STACK_FORBIDDEN_REQ, DoStateChange(DOS_SRESET));
freeUuid(owner);
}
......@@ -867,7 +867,6 @@ TEST_F(OTM, OCSaveTrustCertChainFull)
uint8_t *trustCertChain = (uint8_t *)getPemCert();
uint16_t credId = 0;
EXPECT_EQ(OC_STACK_OK, OCSaveTrustCertChain(trustCertChain, chainSize, OIC_ENCODING_PEM, &credId));
OICFree(trustCertChain);
}
TEST_F(OTM, OCSaveOwnRoleCertFull)
......@@ -875,7 +874,6 @@ TEST_F(OTM, OCSaveOwnRoleCertFull)
uint16_t credId = 0;
char *cert = (char *)getPemCert();
EXPECT_EQ(OC_STACK_OK, OCSaveOwnRoleCert(cert, &credId));
OICFree(cert);
}
static void trustCertChainChangeCB(void *ctx, uint16_t credId, uint8_t *trustCertChain,
......@@ -909,9 +907,6 @@ TEST_F(OTM, OCSaveOwnCertChainFull)
uint16_t credId = 0;
EXPECT_EQ(OC_STACK_OK, OCSaveOwnCertChain(cert, key, &credId));
OICFree(key);
OICFree(cert);
}
TEST_F(OTM, OCRemoveCredentialFull)
......
......@@ -55,29 +55,26 @@ const char ID_13[] = "4222222222222222";
#define F_OK 0
#endif
TEST(CallPDMAPIbeforeInit, BeforeInit)
{
if (0 == access(PM_DB_FILE_NAME, F_OK))
{
EXPECT_EQ(0, remove(PM_DB_FILE_NAME));
}
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMAddDevice(NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMIsDuplicateDevice(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMLinkDevices(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMUnlinkDevices(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMDeleteDevice(NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMGetOwnedDevices(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMGetLinkedDevices(NULL, NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMSetLinkStale(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMGetToBeUnlinkedDevices(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMIsLinkExists(NULL, NULL, NULL));
}
class PDB : public ::testing::Test
{
public:
static void SetUpTestCase()
{
if (0 == access(PM_DB_FILE_NAME, F_OK))
{
EXPECT_EQ(0, remove(PM_DB_FILE_NAME));
}
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMAddDevice(NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMIsDuplicateDevice(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMLinkDevices(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMUnlinkDevices(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMDeleteDevice(NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMGetOwnedDevices(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMGetLinkedDevices(NULL, NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMSetLinkStale(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMGetToBeUnlinkedDevices(NULL, NULL));
EXPECT_EQ(OC_STACK_PDM_IS_NOT_INITIALIZED, PDMIsLinkExists(NULL, NULL, NULL));
unlink("PDM.db");
IOT_Init(PM_DB_FILE_NAME);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment