1 //******************************************************************
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include <gtest/gtest.h>
23 #include "cainterface.h"
24 #include "srmresourcestrings.h"
28 #define PE_UT_TAG "\tPE-UT-message: "
34 #include "policyengine.h"
35 #include "doxmresource.h"
38 // PEContext_t g_peContext;
44 OicUuid_t g_subjectIdA = {"SubjectA"};
45 OicUuid_t g_subjectIdB = {"SubjectB"};
47 char g_resource1[] = "Resource1";
48 char g_resource2[] = "Resource2";
50 extern OicSecDoxm_t *gDoxm;
52 // These tests need to be rewritten; they do not cover internal ACE/request
54 // See JIRA 1787 (https://jira.iotivity.org/browse/IOT-1787)
56 //Policy Engine Core Tests
57 // TEST(PolicyEngineCore, InitPolicyEngine)
59 // EXPECT_EQ(OC_STACK_OK, InitPolicyEngine(&g_peContext));
62 // TODO - in order to unittest this we need InitDoxmResource() to put doxm
63 // into Owned state with a known owner. This will have to be done post v1.1.
64 // TEST(PolicyEngineCore, CheckPermissionNoAcls)
66 // if(OC_STACK_OK == InitDoxmResource())
68 // EXPECT_EQ(ACCESS_DENIED_SUBJECT_NOT_FOUND,
69 // CheckPermission(&g_peContext,
76 // printf("%s WARNING: InitDoxmResource() returned ERROR!\n", PE_UT_TAG);
80 // // TODO - in order to unittest this we need InitDoxmResource() to put doxm
81 // // into Owned state with a known owner. This will have to be done post v1.1.
82 // TEST(PolicyEngineCore, CheckDevOwnerRequest)
84 // if(OC_STACK_OK == InitDoxmResource())
86 // if(OC_STACK_OK == GetDoxmDevOwnerId(&g_devOwner))
88 // printf("%s", PE_UT_TAG);
89 // for(int i = 0; i < UUID_LENGTH; i++)
91 // printf("%d", g_devOwner.id[i]);
94 // EXPECT_EQ(ACCESS_GRANTED,
95 // CheckPermission(&g_peContext,
98 // PERMISSION_FULL_CONTROL));
102 // printf("%s WARNING: GetDoxmDevOwnerId() returned ERROR!\n", PE_UT_TAG);
107 // printf("%s WARNING: InitDoxmResource() returned ERROR!\n", PE_UT_TAG);
111 // TEST(PolicyEngineCore, DeInitPolicyEngine)
113 // DeInitPolicyEngine(&g_peContext);
114 // EXPECT_EQ(STOPPED, g_peContext.state);
115 // EXPECT_EQ((uint16_t)0, g_peContext.permission);
116 // EXPECT_EQ(ACCESS_DENIED_POLICY_ENGINE_ERROR, g_peContext.retVal);