Bangkok SP updates 65/26965/1
authorSteven Saunders <s.saunders-contractor@cablelabs.com>
Thu, 13 Sep 2018 21:12:59 +0000 (15:12 -0600)
committerSteven Saunders <s.saunders-contractor@cablelabs.com>
Thu, 13 Sep 2018 21:12:59 +0000 (15:12 -0600)
Change-Id: Ia14bf12669c385602886be9850ae719e85dd1980
Signed-off-by: Steven Saunders <s.saunders-contractor@cablelabs.com>
resource/csdk/security/include/experimental/securevirtualresourcetypes.h
resource/csdk/security/include/internal/spresource.h
resource/csdk/security/include/internal/srmresourcestrings.h
resource/csdk/security/provisioning/sample/oic_svr_db_server_mfg.json
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/src/spresource.c
resource/csdk/security/src/srmresourcestrings.c
resource/csdk/security/tool/json2cbor.c
resource/csdk/security/unittest/aclresourcetest.cpp
resource/csdk/security/unittest/spresource.cpp

index f612b09..b96a7d2 100644 (file)
@@ -638,7 +638,6 @@ struct OicSecSp
     size_t          supportedLen;       // the number of supported profiles
     char          **supportedProfiles;  // Array of supported security profiles
     char           *currentProfile;     // currently selected security profile
-    uint16_t        credid;             // Cred to accompany currentprofile
 };
 
 #if defined(__WITH_DTLS__) ||  defined(__WITH_TLS__)
index 2cc43c6..1053f7e 100644 (file)
@@ -27,13 +27,12 @@ extern "C" {
 typedef enum {
     SP_SUPPORTED_PROFILES = 0,
     SP_CURRENT_PROFILE,
-    SP_CRED_ID,
     SP_PROPERTY_COUNT
 } SpProperty_t;
 
 
 /**
- * Initialize credentiaspl resource by loading data from persistent storage.
+ * Initialize sp resource by loading data from persistent storage.
  *
  * @return ::OC_STACK_OK, if initialization is successful, else ::OC_STACK_ERROR if
  * initialization fails.
@@ -105,16 +104,6 @@ OCStackResult CBORPayloadToSp(const uint8_t *cborPayload,
                               OicSecSp_t **sp,
                               bool *decodedProperties);
 
-
-/**
- * Determine if a particular security profile requires a supporting credential
- *
- * @param [i] spName    securituy profile name
- *
- * @return          true if supporting cred required, otherwise false
- */
-bool SpRequiresCred(char* spName);
-
 /**
  * Return the index of a profile withing a list of supported profiles
  *
index 5fadf22..9728fb7 100644 (file)
@@ -152,7 +152,6 @@ extern const char * OIC_JSON_OM_NAME;
 extern const char * OIC_JSON_SM_NAME;
 extern const char * OIC_JSON_SUPPORTED_SP_NAME;
 extern const char * OIC_JSON_CURRENT_SP_NAME;
-extern const char * OIC_JSON_SP_CREDID_NAME;
 extern const char * OIC_JSON_SERVICE_DEVICE_ID;
 extern const char * OIC_JSON_SERVICE_TYPE;
 extern const char * OIC_JSON_SUPPORTED_CRED_TYPE_NAME;
index cbe6d84..a821fd8 100644 (file)
@@ -1,8 +1,7 @@
 {
     "sp": {
-        "supportedprofiles": [ "oic.sec.sp.baseline", "oic.sec.sp.black", "oic.sec.sp.blue", "oic.sec.sp.purple" ],
+        "supportedprofiles": [ "oic.sec.sp.baseline" ],
         "currentprofile": "oic.sec.sp.baseline",
-        "credid": 1,
         "rowneruuid": "00000000-0000-0000-0000-000000000000",
         "rt": ["oic.r.ps"],
         "if": ["oic.if.baseline"]
index bf4eab8..c5018b2 100644 (file)
@@ -161,16 +161,21 @@ OicSecSp_t gSpDefault =
     1,                          // supportedLen
     gSupportedProfilesDefault,  // supportedProfiles[0]
     "oic.sec.sp.baseline",      // activeProfile
-    0                           // credid
 };
 
 char * gSupportedProfilesAll[] = { "oic.sec.sp.black", "oic.sec.sp.blue", "oic.sec.sp.purple", "oic.sec.sp.baseline",  };
 OicSecSp_t gSpAll =
 {
-    3,                      // supportedLen
+    4,                      // supportedLen
     gSupportedProfilesAll,  // supportedProfiles[0]
     "oic.sec.sp.black",     // activeProfile
-    1                       // credid (arbitrary for testing)
+};
+char * gSupportedProfilesInvalid[] = { "oic.sec.sp.black", "oic.sec.sp.blue", "oic.sec.sp.purple", "oic.sec.sp.baseline",  };
+OicSecSp_t gSpInvalid =
+{
+    4,                         // supportedLen
+    gSupportedProfilesInvalid, // supportedProfiles
+    "oic.sec.sp.invalid",      // activeProfile
 };
 
 
@@ -1399,14 +1404,14 @@ static int provisionSecurityProfileInfo(void)
     int sp_selection = 0;
     for (; ; )
     {
-        printf("   > Enter (1) for SP defaults or (2) for SP containing all profiles: ");
+        printf("   > Enter (1) for SP defaults, (2) for SP containing all profiles, (3) for an invalid SP: ");
         for (int ret = 0; 1 != ret; )
         {
             ret = scanf("%d", &sp_selection);
             for (; 0x20 <= getchar(); );  // for removing overflow garbages
                                           // '0x20<=code' is character region
         }
-        if ((1 == sp_selection) || (2 >= sp_selection))
+        if ((1 <= sp_selection) && (3 >= sp_selection))
         {
             break;
         }
@@ -1416,7 +1421,13 @@ static int provisionSecurityProfileInfo(void)
     printf("   > Posting new security profile info to device ...\n");
     g_doneCB = false;
 
-    OicSecSp_t *sp = (sp_selection == 1) ? &gSpDefault : &gSpAll;
+    OicSecSp_t *sp = NULL;
+    switch (sp_selection) {
+        case 2 : sp = &gSpAll; break;
+        case 3 : sp = &gSpInvalid; break;
+        default: sp = &gSpDefault;
+    }
+
     OCStackResult rst = OCProvisionSecurityProfileInfo(
         (void*)g_ctx, sp, targetDevice, (OCProvisionResultCB)&provisionTrustChainCB);
     if (OC_STACK_OK != rst)
index b9623bf..3fafe0c 100644 (file)
@@ -32,6 +32,7 @@
 #include "psinterface.h"
 #include "resourcemanager.h"
 #include "spresource.h"
+#include "deviceonboardingstate.h"
 #include "srmutility.h"
 #include "srmresourcestrings.h"
 
@@ -43,20 +44,15 @@ static OCResourceHandle    gSpHandle  = NULL;
 static OicSecSp_t         *gSp        = NULL;
 
 // Default sp values
-char * gSupportedProfiles[] = { "oic.sec.sp.baseline",
-                                "oic.sec.sp.black",
-                                "oic.sec.sp.blue",
-                                "oic.sec.sp.purple"
-                                };
+char * gSupportedProfiles[] = { "oic.sec.sp.baseline" };
 OicSecSp_t gDefaultSp =
 {
     1,                     // supportedLen
     gSupportedProfiles,    // supportedProfiles[0]
     "oic.sec.sp.baseline", // currentProfile
-    0                      // credid
 };
 
-bool gAllProps[SP_PROPERTY_COUNT] = { true, true, true};
+bool gAllProps[SP_PROPERTY_COUNT] = { true, true };
 
 // Default cbor payload size. This value is increased in case of CborErrorOutOfMemory.
 // The value of payload size is increased until reaching below max cbor size.
@@ -73,11 +69,6 @@ OCStackResult SpToCBORPayload(const OicSecSp_t *sp, uint8_t **payload, size_t *s
     bool allProps[SP_PROPERTY_COUNT];
     SetAllSpProps(allProps, true);
 
-    if (false == SpRequiresCred(sp->currentProfile))
-    {
-        allProps[SP_CRED_ID] = false;
-    }
-
     return SpToCBORPayloadPartial(sp, payload, size, allProps);
 }
 
@@ -165,19 +156,6 @@ OCStackResult SpToCBORPayloadPartial(const OicSecSp_t *sp,
         OIC_LOG_V(DEBUG, TAG, "%s encoded sp currentprofile value %s.", __func__, sp->currentProfile);
     }
 
-    // cred id
-    if (propertiesToInclude[SP_CRED_ID])
-    {
-        cborEncoderResult = cbor_encode_text_string(
-            &spMap, OIC_JSON_SP_CREDID_NAME, strlen(OIC_JSON_SP_CREDID_NAME));
-        VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding credid Name Tag.");
-        OIC_LOG_V(DEBUG, TAG, "%s encoded sp %s tag.", __func__, OIC_JSON_SP_CREDID_NAME);
-
-        cborEncoderResult = cbor_encode_int(&spMap, sp->credid);
-        VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Adding sp credid Value.");
-        OIC_LOG_V(DEBUG, TAG, "%s encoded sp %d tag.", __func__, sp->credid);
-    }
-
     // rt (mandatory)
 
     CborEncoder rtArray;
@@ -351,34 +329,6 @@ exit:
     return ret;
 }
 
-/**
- * Static method to determine if a credid is required, and to extract it from spMap if so
- * corresponding index into the supportedProfiles array
- *
- * @param [i] spMap              sp map positioned at location where credit will be if present
- * @param [o] credid             credid extracted from spMap, if credid required
- *                               If credid not required, value of credid is undefined
- *
- * @return ::OC_STACK_OK for Success, otherwise error value.
- */
-static OCStackResult CredIdFromCBOR(CborValue *spMap,
-                                    uint16_t *credid)
-{
-    OCStackResult ret = OC_STACK_ERROR;
-    CborError cborResult = CborNoError;
-    *credid = 0;
-
-    uint64_t extractedCredid = 0;
-    cborResult = cbor_value_get_uint64(spMap, &extractedCredid);
-    VERIFY_CBOR_SUCCESS(TAG, cborResult, "Could not extract SP credid.");
-    *credid = (uint16_t)extractedCredid;
-
-    ret = OC_STACK_OK;
-
-exit:
-    return ret;
-}
-
 OCStackResult CBORPayloadToSp(const uint8_t *cborPayload,
                               const size_t size,
                               OicSecSp_t **secSp,
@@ -458,17 +408,6 @@ OCStackResult CBORPayloadToSp(const uint8_t *cborPayload,
                 }
             }
 
-            // credid
-            else if (strcmp(tagName, OIC_JSON_SP_CREDID_NAME) == 0)
-            {
-                ret = CredIdFromCBOR(&spMap, &sp->credid);
-                VERIFY_OR_LOG_AND_EXIT(TAG, (OC_STACK_OK == ret), "Failed to extract SP cred id", ERROR);
-                if (NULL != decodedProperties)
-                {
-                    decodedProperties[SP_CRED_ID] = true;
-                }
-            }
-
             // advance to the next tag
             if (cbor_value_is_valid(&spMap))
             {
@@ -529,25 +468,7 @@ void DeleteSpBinData(OicSecSp_t* sp)
             OICFree(sp->currentProfile);
         }
         sp->currentProfile = NULL;
-        sp->credid = 0;
-    }
-}
-
-bool SpRequiresCred(char* spName)
-{
-    if (NULL == spName)
-    {
-        OIC_LOG(WARNING, TAG, "NULL profile name supplied for cred check");
-        return false;
-    }
-
-    if ( (0 == strcmp(spName, "oic.sec.sp.black")) ||
-         (0 == strcmp(spName, "oic.sec.sp.blue")) ||
-         (0 == strcmp(spName, "oic.sec.sp.purple")))
-    {
-        return true;
     }
-    return false;
 }
 
 bool RequiredSpPropsPresentAndValid(OicSecSp_t* sp, bool *propertiesPresent)
@@ -569,10 +490,6 @@ bool RequiredSpPropsPresentAndValid(OicSecSp_t* sp, bool *propertiesPresent)
     VERIFY_OR_LOG_AND_EXIT(TAG, (0 <= ProfileIdx(sp->supportedLen, sp->supportedProfiles, sp->currentProfile)),
         "Currentprofile is not contained in supportedprofiles list", WARNING);
 
-    VERIFY_OR_LOG_AND_EXIT(TAG,
-        !((true == SpRequiresCred(sp->currentProfile)) &&  (false == propertiesPresent[SP_CRED_ID])),
-        "Current profile requires credential, but none is present", WARNING);
-
     requiredPropsPresentAndValid = true;
 
 exit:
@@ -651,7 +568,7 @@ static OCEntityHandlerResult HandleSpGetRequest (const OCEntityHandlerRequest *
     {
         if(OC_STACK_OK != SpToCBORPayload(gSp, &payload, &size))
         {
-            OIC_LOG_V(WARNING, TAG, "%s PstatToCBORPayload failed.", __func__);
+            OIC_LOG_V(WARNING, TAG, "%s SpToCBORPayload failed.", __func__);
         }
     }
 
@@ -738,7 +655,6 @@ static OicSecSp_t* SpDup(OicSecSp_t* spToDup)
     VERIFY_NOT_NULL(TAG, dupSp, ERROR);
 
     dupSp->supportedLen = spToDup->supportedLen;
-    dupSp->credid = spToDup->credid;
     dupSp->currentProfile = OICStrdup(spToDup->currentProfile);
     VERIFY_NOT_NULL(TAG, dupSp->currentProfile, ERROR);
 
@@ -800,10 +716,20 @@ static OCEntityHandlerResult HandleSpPostRequest(OCEntityHandlerRequest *ehReque
 
     bool newSupportedProfiles = false;
     bool newCurrentProfile = false;
-    bool newCredid = false;
 
     uint8_t *payload = NULL;
     size_t size = 0;
+    OicSecDostype_t dos;
+    ret = GetDos(&dos);
+    VERIFY_OR_LOG_AND_EXIT(TAG, (OC_STACK_OK == ret),
+        "Not able to get onboarding state (pstat.dos) for /sp POST request", ERROR);
+
+    OIC_LOG_V(DEBUG, TAG, "/sp POST request, pstat.dos state = %d", dos.state);
+    if ((DOS_RESET == dos.state) || (DOS_RFNOP == dos.state)) {
+        OIC_LOG(ERROR, TAG, "/sp resource is read-only in RESET and RFNOP");
+        ehRet = OC_EH_NOT_ACCEPTABLE;
+        goto exit;
+    }
 
     VERIFY_OR_LOG_AND_EXIT(TAG, (NULL != ehRequest->payload), "sp POST : no payload supplied ", ERROR);
     VERIFY_OR_LOG_AND_EXIT(TAG, (NULL != gSp), "sp POST : corrupt internal SP resource ", ERROR);
@@ -819,7 +745,6 @@ static OCEntityHandlerResult HandleSpPostRequest(OCEntityHandlerRequest *ehReque
 
     newSupportedProfiles = decodedProperties[SP_SUPPORTED_PROFILES];
     newCurrentProfile = decodedProperties[SP_CURRENT_PROFILE];
-    newCredid = decodedProperties[SP_CRED_ID];
 
     spUpdate = (OicSecSp_t *)OICCalloc(1, sizeof(OicSecSp_t));
     VERIFY_NOT_NULL(TAG, spUpdate, ERROR);
@@ -841,27 +766,17 @@ static OCEntityHandlerResult HandleSpPostRequest(OCEntityHandlerRequest *ehReque
         (0 <= ProfileIdx(spUpdate->supportedLen, spUpdate->supportedProfiles, spUpdate->currentProfile)),
         "sp POST : currentprofile is not contained in supportedprofiles list", ERROR);
 
-    // credid
-    if (true == SpRequiresCred(spUpdate->currentProfile))
-    {
-        spUpdate->credid = newCredid ? spIncoming->credid : gSp->credid;
-    }
-    else
-    {
-        spUpdate->credid = 0;
-    }
-
     // Before we update the sp, lets make sure everthing is valid
     VERIFY_OR_LOG_AND_EXIT(TAG,
         (true == RequiredSpPropsPresentAndValid(spUpdate, gAllProps)),
         "sp POST : update version of security profiles not valid, not updating", ERROR);
 
     // whew ...
-    ret = OC_STACK_OK;
+    ehRet = OC_EH_OK;
 
 exit:
 
-    if ((OC_STACK_OK == ret) && (NULL != spUpdate))
+    if ((OC_EH_OK == ehRet) && (NULL != spUpdate))
     {
         if( true != UpdatePersistentStorage(spUpdate))
         {
@@ -885,7 +800,7 @@ exit:
         ehRet = OC_EH_NOT_ACCEPTABLE;
     }
 
-    if ((OC_STACK_OK != ret) && (NULL != spUpdate))
+    if ((OC_EH_OK != ehRet) && (NULL != spUpdate))
     {
         DeleteSpBinData(spUpdate);
     }
@@ -944,7 +859,7 @@ OCEntityHandlerResult SpEntityHandler(OCEntityHandlerFlag flag,
     return ehRet;
 }
 
-//#define SP_RESOURCE_DISABLE
+#undef SP_RESOURCE_DISABLE
 OCStackResult CreateSpResource()
 {
     OCStackResult ret = OC_STACK_OK;
@@ -1077,14 +992,6 @@ bool IsSpSame(OicSecSp_t* sp1, OicSecSp_t* sp2, bool *propertiesToCheck)
         }
     }
 
-    if (true == propertiesToCheck[SP_CRED_ID] || (NULL == propertiesToCheck))
-    {
-        if (sp1->credid != sp2->credid)
-        {
-            return false;
-        }
-    }
-
     return true;
 }
 
@@ -1118,7 +1025,5 @@ void LogSp(OicSecSp_t* sp, int level, const char* tag, const char* msg)
         OIC_LOG_V(level, tag, "  %lu: %s", (unsigned long)i, sp->supportedProfiles[i]);
     }
     OIC_LOG_V(level, tag, "Current security profile: %s", sp->currentProfile);
-    OIC_LOG_V(level, tag, "Current profile requires cred: %s", (true == SpRequiresCred(sp->currentProfile) ? "yes" : "no"));
-    OIC_LOG_V(level, TAG, "credid: %hu", sp->credid);
     OIC_LOG(level, tag, "-------------------------------------------------");
 }
index 20968f5..435ed99 100644 (file)
@@ -129,7 +129,6 @@ const char * OIC_JSON_OM_NAME = "om";
 const char * OIC_JSON_SM_NAME = "sm";
 const char * OIC_JSON_SUPPORTED_SP_NAME = "supportedprofiles";
 const char * OIC_JSON_CURRENT_SP_NAME = "currentprofile";
-const char * OIC_JSON_SP_CREDID_NAME = "credid";
 const char * OIC_JSON_CREDID_NAME = "credid";
 const char * OIC_JSON_SUBJECT_NAME = "subject";
 const char * OIC_JSON_SUBJECTID_NAME = "subjectuuid";
index 2579755..6745d70 100644 (file)
@@ -1192,7 +1192,6 @@ static OicSecSp_t *JSONToSpBin(const char *jsonStr)
     cJSON *jsonCurrentProfileName = NULL;
     cJSON *jsonSupportedProfilesArray = NULL;
     cJSON *jsonProfileName = NULL;
-    cJSON *jsonCredid = NULL;
 
     OicSecSp_t *sp = NULL;
 
@@ -1236,27 +1235,6 @@ static OicSecSp_t *JSONToSpBin(const char *jsonStr)
         goto exit;
     }
 
-    // credid
-
-    jsonCredid = cJSON_GetObjectItem(jsonSp, OIC_JSON_SP_CREDID_NAME);
-    if (NULL == jsonCredid)
-    {
-        if (true == SpRequiresCred(sp->currentProfile))
-        {
-            OIC_LOG(ERROR, TAG, "sp current profile requires cred, but credid not present in json");
-            goto exit;
-        }
-        else
-        {
-            sp->credid = 0;
-        }
-    }
-    else
-    {
-        VERIFY_SUCCESS(TAG, (cJSON_Number == jsonCredid->type), ERROR);
-        sp->credid = (uint16_t)jsonCredid->valueint;
-    }
-
     ret = OC_STACK_OK;
 
 exit:
index 2ed6b35..51bbdae 100644 (file)
@@ -459,13 +459,14 @@ TEST(ACLResourceTest, ACLDeleteWithSingleResourceTest)
     EXPECT_EQ(OC_STACK_OK, SetDefaultACL(defaultAcl));
 
     //Populate ACL
-    OicSecAcl_t acl = OicSecAcl_t();
-    EXPECT_EQ(OC_STACK_OK, populateAcl(&acl, 1));
+    OicSecAcl_t *acl = (OicSecAcl_t *) OICCalloc(1, sizeof(OicSecAcl_t));
+    ASSERT_TRUE(NULL != acl);
+    EXPECT_EQ(OC_STACK_OK, populateAcl(acl, 1));
 
     //GET CBOR POST payload
     size_t size = 0;
     uint8_t  *payload = NULL;
-    EXPECT_EQ(OC_STACK_OK, AclToCBORPayload(&acl, OIC_SEC_ACL_V2, &payload, &size));
+    EXPECT_EQ(OC_STACK_OK, AclToCBORPayload(acl, OIC_SEC_ACL_V2, &payload, &size));
     ASSERT_TRUE(NULL != payload);
 
     // Security Payload
@@ -480,7 +481,7 @@ TEST(ACLResourceTest, ACLDeleteWithSingleResourceTest)
 
     // Verify if SRM contains ACE for the subject
     OicSecAce_t* savePtr = NULL;
-    const OicSecAce_t* subjectAce1 = GetACLResourceData(&acl.aces->subjectuuid, &savePtr);
+    const OicSecAce_t* subjectAce1 = GetACLResourceData(&(acl->aces->subjectuuid), &savePtr);
     ASSERT_TRUE(NULL != subjectAce1);
 
     // Create Entity Handler DELETE request
@@ -493,12 +494,12 @@ TEST(ACLResourceTest, ACLDeleteWithSingleResourceTest)
 
     // Verify if SRM has deleted ACE for the subject
     savePtr = NULL;
-    const OicSecAce_t* subjectAce2 = GetACLResourceData(&acl.aces->subjectuuid, &savePtr);
+    const OicSecAce_t* subjectAce2 = GetACLResourceData(&(acl->aces->subjectuuid), &savePtr);
     ASSERT_TRUE(NULL == subjectAce2);
 
     // Perform cleanup
     DeInitACLResource();
-    DeleteACLList(&acl);
+    DeleteACLList(acl);
     OICFree(ehReq.query);
     OCPayloadDestroy((OCPayload *)securityPayload);
     OICFree(payload);
@@ -520,13 +521,14 @@ TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
     EXPECT_EQ(OC_STACK_OK, SetDefaultACL(defaultAcl));
 
     //Populate ACL
-    OicSecAcl_t acl = OicSecAcl_t();
-    EXPECT_EQ(OC_STACK_OK, populateAcl(&acl, 2));
+    OicSecAcl_t *acl = (OicSecAcl_t *) OICCalloc(1, sizeof(OicSecAcl_t));
+    ASSERT_TRUE(NULL != acl);
+    EXPECT_EQ(OC_STACK_OK, populateAcl(acl, 2));
 
     //GET CBOR POST payload
     size_t size = 0;
     uint8_t *payload = NULL;
-    EXPECT_EQ(OC_STACK_OK, AclToCBORPayload(&acl, OIC_SEC_ACL_V2, &payload, &size));
+    EXPECT_EQ(OC_STACK_OK, AclToCBORPayload(acl, OIC_SEC_ACL_V2, &payload, &size));
     ASSERT_TRUE(NULL != payload);
 
     // Security Payload
@@ -541,7 +543,7 @@ TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
 
     // Verify if SRM contains ACE for the subject with two resources
     OicSecAce_t* savePtr = NULL;
-    const OicSecAce_t* subjectAce1 = GetACLResourceData(&acl.aces->subjectuuid, &savePtr);
+    const OicSecAce_t* subjectAce1 = GetACLResourceData(&(acl->aces->subjectuuid), &savePtr);
     ASSERT_TRUE(NULL != subjectAce1);
     EXPECT_EQ(2u, GetNumberOfResource(subjectAce1));
 
@@ -564,14 +566,14 @@ TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
 
     // Verify if SRM contains ACL for the subject but only with one resource
     savePtr = NULL;
-    const OicSecAce_t* subjectAce2 = GetACLResourceData(&acl.aces->subjectuuid, &savePtr);
+    const OicSecAce_t* subjectAce2 = GetACLResourceData(&(acl->aces->subjectuuid), &savePtr);
     ASSERT_TRUE(NULL != subjectAce2);
     EXPECT_EQ(1u, GetNumberOfResource(subjectAce2));
 
     // Perform cleanup
     OCPayloadDestroy((OCPayload *)securityPayload);
     DeInitACLResource();
-    DeleteACLList(&acl);
+    DeleteACLList(acl);
     OICFree(ehReq.query);
     OICFree(payload);
 }
@@ -588,13 +590,14 @@ TEST(ACLResourceTest, ACLGetWithQueryTest)
     EXPECT_EQ(OC_STACK_OK, SetDefaultACL(defaultAcl));
 
     //Populate ACL
-    OicSecAcl_t acl = OicSecAcl_t();
-    EXPECT_EQ(OC_STACK_OK, populateAcl(&acl, 1));
+    OicSecAcl_t *acl = (OicSecAcl_t *) OICCalloc(1, sizeof(OicSecAcl_t));
+    ASSERT_TRUE(NULL != acl);
+    EXPECT_EQ(OC_STACK_OK, populateAcl(acl, 1));
 
     //GET CBOR POST payload
     size_t size = 0;
     uint8_t *payload = NULL;
-    EXPECT_EQ(OC_STACK_OK, AclToCBORPayload(&acl, OIC_SEC_ACL_V2, &payload, &size));
+    EXPECT_EQ(OC_STACK_OK, AclToCBORPayload(acl, OIC_SEC_ACL_V2, &payload, &size));
     ASSERT_TRUE(NULL != payload);
 
     // Security Payload
@@ -619,7 +622,7 @@ TEST(ACLResourceTest, ACLGetWithQueryTest)
     // Perform cleanup
     OCPayloadDestroy((OCPayload *)securityPayload);
     DeInitACLResource();
-    DeleteACLList(&acl);
+    DeleteACLList(acl);
     OICFree(ehReq.query);
     OICFree(payload);
 }
index c5cb9f0..93eb9eb 100644 (file)
@@ -51,7 +51,6 @@ static OicSecSp_t s_testSp =
     0,                      // supportedLen
     s_profileArray,         // supportedProfiles[0]
     NULL,                   // currentProfile
-    0                       // credid
 };
 
 
@@ -72,7 +71,6 @@ TEST(SPResourceTest, CBORFullEncodingPositive)
     s_testSp.supportedProfiles[2] = s_spBlackName;
     s_testSp.supportedProfiles[3] = s_spPurpleName;
     s_testSp.currentProfile = s_spBlackName;
-    s_testSp.credid = 1;
     TestEncodeDecode(&s_testSp, propsToTest, true);
 
     // default configuration
@@ -90,7 +88,6 @@ TEST(SPResourceTest, CBORFullEncodingPositive)
     s_testSp.supportedProfiles[0] = s_spBaselineName;
     s_testSp.supportedProfiles[1] = s_spBlackName;
     s_testSp.currentProfile = s_spBlackName;
-    s_testSp.credid = 22;
     TestEncodeDecode(&s_testSp, propsToTest, true);
 }
 
@@ -111,12 +108,6 @@ TEST(SPResourceTest, CBORPartialEncodingPositive)
     s_testSp.currentProfile = s_spBlueName;
     TestEncodeDecode(&s_testSp, propsToTest, false);
 
-    // cred profile only
-    TestInit(&s_testSp, propsToTest);
-    propsToTest[SP_CRED_ID] = true;
-    s_testSp.credid = 11;
-    TestEncodeDecode(&s_testSp, propsToTest, false);
-
     // supported profiles and current profile
     TestInit(&s_testSp, propsToTest);
     propsToTest[SP_SUPPORTED_PROFILES] = true;
@@ -126,24 +117,6 @@ TEST(SPResourceTest, CBORPartialEncodingPositive)
     s_testSp.supportedProfiles[1] = s_spBlueName;
     s_testSp.currentProfile = s_spBlueName;
     TestEncodeDecode(&s_testSp, propsToTest, false);
-
-    // supported profiles and credid
-    TestInit(&s_testSp, propsToTest);
-    propsToTest[SP_SUPPORTED_PROFILES] = true;
-    propsToTest[SP_CRED_ID] = true;
-    s_testSp.supportedLen = 2;
-    s_testSp.supportedProfiles[0] = s_spBaselineName;
-    s_testSp.supportedProfiles[1] = s_spBlackName;
-    s_testSp.credid = 88;
-    TestEncodeDecode(&s_testSp, propsToTest, false);
-
-    // current profiles and credid
-    TestInit(&s_testSp, propsToTest);
-    propsToTest[SP_CURRENT_PROFILE] = true;
-    propsToTest[SP_CRED_ID] = true;
-    s_testSp.currentProfile = s_spBaselineName;
-    s_testSp.credid = 22;
-    TestEncodeDecode(&s_testSp, propsToTest, false);
 }
 
 // TODO: in order of priority
@@ -197,7 +170,6 @@ static void TestInit(OicSecSp_t* testSp, bool* spProps)
 {
     testSp->supportedLen = 0;
     testSp->currentProfile = NULL;
-    testSp->credid = 0;
 
     for (size_t i = 0; i < sizeof(s_profileArray)/sizeof(s_profileArray[0]); i++)
     {