Updated ACL and Cred EntityHandler to process Delete Request
authorShilpa Sodani <shilpa.a.sodani@intel.com>
Fri, 31 Jul 2015 23:14:32 +0000 (16:14 -0700)
committerSachin Agrawal <sachin.agrawal@intel.com>
Sun, 9 Aug 2015 18:33:40 +0000 (18:33 +0000)
Added HandleACLDeleteRequest function to ACL resource to process
delete request.

Added HandelDeleteRequest function to Cred resource to process
delete request.

Changed Rest query separator to ";" from "&"

Change-Id: I5f7a0e446051f63e6aad9e49e4cbce1e34dc5f57
Signed-off-by: Shilpa Sodani <shilpa.a.sodani@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2035
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sachin Agrawal <sachin.agrawal@intel.com>
resource/csdk/security/src/aclresource.c
resource/csdk/security/src/credresource.c
resource/csdk/security/src/psinterface.c
resource/csdk/security/src/srmresourcestrings.c
resource/csdk/security/unittest/aclresourcetest.cpp
resource/csdk/security/unittest/credentialresource.cpp
resource/csdk/security/unittest/doxmresource.cpp
resource/csdk/security/unittest/srmtestcommon.cpp
resource/csdk/security/unittest/srmtestcommon.h
resource/csdk/security/unittest/srmutility.cpp
resource/csdk/stack/samples/linux/secure/oic_svr_db_server.json

index 7da0f85b52b3c72cb9d5409aba6c73939a090668..a6fe97067045460ddcd17bc79e27df0c8c84808b 100644 (file)
 #include "srmresourcestrings.h"
 #include "doxmresource.h"
 #include "srmutility.h"
+#include "ocserverrequest.h"
 #include <stdlib.h>
+#ifdef WITH_ARDUINO
 #include <string.h>
+#else
+#include <strings.h>
+#endif
 
 #define TAG  PCF("SRM-ACL")
 
 OicSecAcl_t        *gAcl = NULL;
 static OCResourceHandle    gAclHandle = NULL;
 
+/**
+ * This function frees OicSecAcl_t object's fields and object itself.
+ */
+static void FreeACE(OicSecAcl_t *ace)
+{
+    size_t i;
+    if(NULL == ace)
+    {
+        OC_LOG (INFO, TAG, PCF("Invalid Parameter"));
+        return;
+    }
+
+    // Clean Resources
+    for (i = 0; i < ace->resourcesLen; i++)
+    {
+        OICFree(ace->resources[i]);
+    }
+    OICFree(ace->resources);
+
+    //Clean Period & Recurrence
+    for(i = 0; i < ace->prdRecrLen; i++)
+    {
+        OICFree(ace->periods[i]);
+        OICFree(ace->recurrences[i]);
+    }
+    OICFree(ace->periods);
+    OICFree(ace->recurrences);
+
+    // Clean Owners
+    OICFree(ace->owners);
+
+    // Clean ACL node itself
+    OICFree(ace);
+}
+
 void DeleteACLList(OicSecAcl_t* acl)
 {
     if (acl)
@@ -48,31 +88,8 @@ void DeleteACLList(OicSecAcl_t* acl)
         OicSecAcl_t *aclTmp1 = NULL, *aclTmp2 = NULL;
         LL_FOREACH_SAFE(acl, aclTmp1, aclTmp2)
         {
-            int i = 0;
-
             LL_DELETE(acl, aclTmp1);
-
-            // Clean Resources
-            for (i = 0; i < aclTmp1->resourcesLen; i++)
-            {
-                OICFree(aclTmp1->resources[i]);
-            }
-            OICFree(aclTmp1->resources);
-
-            //Clean Period & Recurrence
-            for(i = 0; i < aclTmp1->prdRecrLen; i++)
-            {
-                OICFree(aclTmp1->periods[i]);
-                OICFree(aclTmp1->recurrences[i]);
-            }
-            OICFree(aclTmp1->periods);
-            OICFree(aclTmp1->recurrences);
-
-            // Clean Owners
-            OICFree(aclTmp1->owners);
-
-            // Clean ACL node itself
-            OICFree(aclTmp1);
+            FreeACE(aclTmp1);
         }
     }
 }
@@ -125,7 +142,7 @@ char * BinToAclJSON(const OicSecAcl_t * acl)
             cJSON *jsonRsrcArray = NULL;
             cJSON_AddItemToObject (jsonAcl, OIC_JSON_RESOURCES_NAME, jsonRsrcArray = cJSON_CreateArray());
             VERIFY_NON_NULL(TAG, jsonRsrcArray, ERROR);
-            for (int i = 0; i < acl->resourcesLen; i++)
+            for (size_t i = 0; i < acl->resourcesLen; i++)
             {
                 cJSON_AddItemToArray (jsonRsrcArray, cJSON_CreateString(acl->resources[i]));
             }
@@ -165,7 +182,7 @@ char * BinToAclJSON(const OicSecAcl_t * acl)
             cJSON *jsonOwnrArray = NULL;
             cJSON_AddItemToObject (jsonAcl, OIC_JSON_OWNERS_NAME, jsonOwnrArray = cJSON_CreateArray());
             VERIFY_NON_NULL(TAG, jsonOwnrArray, ERROR);
-            for (int i = 0; i < acl->ownersLen; i++)
+            for (size_t i = 0; i < acl->ownersLen; i++)
             {
                 outLen = 0;
 
@@ -258,7 +275,7 @@ OicSecAcl_t * JSONToAclBin(const char * jsonStr)
             acl->resources = (char**)OICCalloc(acl->resourcesLen, sizeof(char*));
             VERIFY_NON_NULL(TAG, (acl->resources), ERROR);
 
-            int idxx = 0;
+            size_t idxx = 0;
             do
             {
                 cJSON *jsonRsrc = cJSON_GetArrayItem(jsonObj, idxx);
@@ -374,6 +391,119 @@ exit:
     return headAcl;
 }
 
+static bool UpdatePersistentStorage(const OicSecAcl_t *acl)
+{
+    // Convert ACL data into JSON for update to persistent storage
+    char *jsonStr = BinToAclJSON(acl);
+    if (jsonStr)
+    {
+        cJSON *jsonAcl = cJSON_Parse(jsonStr);
+        OICFree(jsonStr);
+
+        if ((jsonAcl) && (OC_STACK_OK == UpdateSVRDatabase(OIC_JSON_ACL_NAME, jsonAcl)))
+        {
+            return true;
+        }
+        cJSON_Delete(jsonAcl);
+    }
+    return false;
+}
+/*
+ * This method removes ACE for the subject and resource from the ACL
+ *
+ * @param subject  - subject of the ACE
+ * @param resource - resource of the ACE
+ *
+ * @return
+ *     OC_STACK_RESOURCE_DELETED on success
+ *     OC_STACK_NO_RESOURC on failure to find the appropriate ACE
+ *     OC_STACK_INVALID_PARAM on invalid parameter
+ */
+static OCStackResult RemoveACE(const OicUuid_t * subject,
+                               const char * resource)
+{
+    OC_LOG(INFO, TAG, PCF("IN RemoveACE"));
+
+    OicSecAcl_t *acl = NULL;
+    OicSecAcl_t *tempAcl = NULL;
+    bool deleteFlag = false;
+    OCStackResult ret = OC_STACK_NO_RESOURCE;
+
+    if(memcmp(subject->id, &WILDCARD_SUBJECT_ID, sizeof(subject->id)) == 0)
+    {
+        OC_LOG_V (INFO, TAG, PCF("%s received invalid parameter"), __func__ );
+        return  OC_STACK_INVALID_PARAM;
+    }
+
+    //If resource is NULL then delete all the ACE for the subject.
+    if(NULL == resource)
+    {
+        LL_FOREACH_SAFE(gAcl, acl, tempAcl)
+        {
+            if(memcmp(acl->subject.id, subject->id, sizeof(subject->id)) == 0)
+            {
+                LL_DELETE(gAcl, acl);
+                FreeACE(acl);
+                deleteFlag = true;
+            }
+        }
+    }
+    else
+    {
+        //Looping through ACL to find the right ACE to delete. If the required resource is the only
+        //resource in the ACE for the subject then delete the whole ACE. If there are more resources
+        //than the required resource in the ACE, for the subject then just delete the resource from
+        //the resource array
+        LL_FOREACH_SAFE(gAcl, acl, tempAcl)
+        {
+            if(memcmp(acl->subject.id, subject->id, sizeof(subject->id)) == 0)
+            {
+                if(1 == acl->resourcesLen && strcmp(acl->resources[0],  resource) == 0)
+                {
+                    LL_DELETE(gAcl, acl);
+                    FreeACE(acl);
+                    deleteFlag = true;
+                    break;
+                }
+                else
+                {
+                    int resPos = -1;
+                    size_t i;
+                    for(i = 0; i < acl->resourcesLen; i++)
+                    {
+                        if(strcmp(acl->resources[i],  resource) == 0)
+                        {
+                            resPos = i;
+                            break;
+                        }
+                    }
+                    if((0 <= resPos))
+                    {
+                        OICFree(acl->resources[resPos]);
+                        acl->resources[resPos] = NULL;
+                        acl->resourcesLen -= 1;
+                        for(i = resPos; i < acl->resourcesLen; i++)
+                        {
+                            acl->resources[i] = acl->resources[i+1];
+                        }
+                        deleteFlag = true;
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    if(deleteFlag)
+    {
+        if(UpdatePersistentStorage(gAcl))
+        {
+            ret = OC_STACK_RESOURCE_DELETED;
+        }
+    }
+    return ret;
+}
+
 static OCEntityHandlerResult HandleACLGetRequest (const OCEntityHandlerRequest * ehRequest)
 {
     // Convert ACL data into JSON for transmission
@@ -406,19 +536,9 @@ static OCEntityHandlerResult HandleACLPostRequest (const OCEntityHandlerRequest
         // Append the new ACL to existing ACL
         LL_APPEND(gAcl, newAcl);
 
-        // Convert ACL data into JSON for update to persistent storage
-        char *jsonStr = BinToAclJSON(gAcl);
-        if (jsonStr)
+        if(UpdatePersistentStorage(gAcl))
         {
-            cJSON *jsonAcl = cJSON_Parse(jsonStr);
-            OICFree(jsonStr);
-
-            if ((jsonAcl) &&
-                (OC_STACK_OK == UpdateSVRDatabase(OIC_JSON_ACL_NAME, jsonAcl)))
-            {
-                ehRet = OC_EH_RESOURCE_CREATED;
-            }
-            cJSON_Delete(jsonAcl);
+            ehRet = OC_EH_RESOURCE_CREATED;
         }
     }
 
@@ -429,6 +549,57 @@ static OCEntityHandlerResult HandleACLPostRequest (const OCEntityHandlerRequest
     return ehRet;
 }
 
+static OCEntityHandlerResult HandleACLDeleteRequest(const OCEntityHandlerRequest *ehRequest)
+{
+    OC_LOG (INFO, TAG, PCF("Processing ACLDeleteRequest"));
+    OCEntityHandlerResult ehRet = OC_EH_ERROR;
+
+    if(NULL == ehRequest->query)
+    {
+        return ehRet;
+    }
+    OicParseQueryIter_t parseIter = {.attrPos=NULL};
+    OicUuid_t subject = {.id={0}};
+    char * resource = NULL;
+
+    //Parsing REST query to get subject & resource
+    ParseQueryIterInit((unsigned char *)ehRequest->query, &parseIter);
+
+    while(GetNextQuery(&parseIter))
+    {
+        if(strncasecmp((char *)parseIter.attrPos, OIC_JSON_SUBJECT_NAME, parseIter.attrLen) == 0)
+        {
+            unsigned char base64Buff[sizeof(((OicUuid_t*)0)->id)] = {};
+            uint32_t outLen = 0;
+            B64Result b64Ret = B64_OK;
+
+           b64Ret = b64Decode((char *)parseIter.valPos, parseIter.valLen, base64Buff,
+                               sizeof(base64Buff), &outLen);
+
+           VERIFY_SUCCESS(TAG, (b64Ret == B64_OK && outLen <= sizeof(subject.id)), ERROR);
+           memcpy(subject.id, base64Buff, outLen);
+        }
+        if(strncasecmp((char *)parseIter.attrPos, OIC_JSON_RESOURCES_NAME, parseIter.attrLen) == 0)
+        {
+            resource = (char *)OICMalloc(parseIter.valLen);
+            VERIFY_NON_NULL(TAG, resource, ERROR);
+            OICStrcpy(resource, sizeof(resource), (char *)parseIter.valPos);
+        }
+    }
+
+    if(OC_STACK_RESOURCE_DELETED == RemoveACE(&subject, resource))
+    {
+        ehRet = OC_EH_RESOURCE_DELETED;
+    }
+    OICFree(resource);
+
+    // Send payload to request originator
+    SendSRMResponse(ehRequest, ehRet, NULL);
+
+exit:
+    return ehRet;
+}
+
 /*
  * This internal method is the entity handler for ACL resources and
  * will handle REST request (GET/PUT/POST/DEL) for them.
@@ -437,6 +608,7 @@ OCEntityHandlerResult ACLEntityHandler (OCEntityHandlerFlag flag,
                                         OCEntityHandlerRequest * ehRequest,
                                         void* callbackParameter)
 {
+    OC_LOG(INFO, TAG, PCF("Received request ACLEntityHandler\n"));
     OCEntityHandlerResult ehRet = OC_EH_ERROR;
 
     if (!ehRequest)
@@ -458,6 +630,10 @@ OCEntityHandlerResult ACLEntityHandler (OCEntityHandlerFlag flag,
                 ehRet = HandleACLPostRequest(ehRequest);
                 break;
 
+            case OC_REST_DELETE:
+                ehRet = HandleACLDeleteRequest(ehRequest);
+                break;
+
             default:
                 ehRet = OC_EH_ERROR;
                 SendSRMResponse(ehRequest, ehRet, NULL);
@@ -500,7 +676,7 @@ OCStackResult  GetDefaultACL(OicSecAcl_t** defaultAcl)
 {
     OCStackResult ret = OC_STACK_ERROR;
 
-    OicUuid_t ownerId = {};
+    OicUuid_t ownerId = {.id={}};
 
     /*
      * TODO In future, when new virtual resources will be added in OIC
@@ -539,7 +715,7 @@ OCStackResult  GetDefaultACL(OicSecAcl_t** defaultAcl)
     acl->resources = (char**)OICCalloc(acl->resourcesLen, sizeof(char*));
     VERIFY_NON_NULL(TAG, (acl->resources), ERROR);
 
-    for (int i = 0; i <  acl->resourcesLen; i++)
+    for (size_t i = 0; i <  acl->resourcesLen; i++)
     {
         size_t len = strlen(rsrcs[i]) + 1;
         acl->resources[i] = (char*)OICMalloc(len * sizeof(char));
index af21b26156ce6da4d96c01d30335de7a8bb5afba..d9955d295b43c65b5e9d55a26c773fed072ecf51 100644 (file)
 #include "srmutility.h"
 #include "cainterface.h"
 #include <stdlib.h>
+#ifdef WITH_ARDUINO
 #include <string.h>
+#else
+#include <strings.h>
+#endif
 #include <stdint.h>
 
 
 static OicSecCred_t        *gCred = NULL;
 static OCResourceHandle    gCredHandle = NULL;
 
-void DeleteCredList(OicSecCred_t* cred)
+/**
+ * This function frees OicSecCred_t object's fields and object itself.
+ */
+static void FreeCred(OicSecCred_t *cred)
 {
-    if (cred)
+    if(NULL == cred)
     {
-        OicSecCred_t *credTmp1 = NULL, *credTmp2 = NULL;
-        LL_FOREACH_SAFE(cred, credTmp1, credTmp2)
-        {
-            LL_DELETE(cred, credTmp1);
-
-            //Note: Need further clarification on roleID data type
+        OC_LOG (INFO, TAG, PCF("Invalid Parameter"));
+        return;
+    }
+    //Note: Need further clarification on roleID data type
 #if 0
-            //Clean roleIds
-            OICFree(credTmp1->roleIds);
+    //Clean roleIds
+    OICFree(cred->roleIds);
 #endif
 
-            //Clean PublicData
-            OICFree(credTmp1->publicData.data);
+    //Clean PublicData
+    OICFree(cred->publicData.data);
 
-            //Clean PrivateData
-            OICFree(credTmp1->privateData.data);
+    //Clean PrivateData
+    OICFree(cred->privateData.data);
 
-            //Clean Period
-            OICFree(credTmp1->period);
+    //Clean Period
+    OICFree(cred->period);
 
-            //Clean Owners
-            OICFree(credTmp1->owners);
+    //Clean Owners
+    OICFree(cred->owners);
 
-            //Clean Cred node itself
-            OICFree(credTmp1);
+    //Clean Cred node itself
+    OICFree(cred);
+}
+
+void DeleteCredList(OicSecCred_t* cred)
+{
+    if (cred)
+    {
+        OicSecCred_t *credTmp1 = NULL, *credTmp2 = NULL;
+        LL_FOREACH_SAFE(cred, credTmp1, credTmp2)
+        {
+            LL_DELETE(cred, credTmp1);
+            FreeCred(credTmp1);
         }
     }
 }
@@ -395,7 +411,35 @@ exit:
     return cred;
 }
 
-/*
+static bool UpdatePersistentStorage(const OicSecCred_t *cred)
+{
+    bool ret = false;
+
+    // Convert Cred data into JSON for update to persistent storage
+    char *jsonStr = BinToCredJSON(cred);
+    if (jsonStr)
+    {
+        cJSON *jsonCred = cJSON_Parse(jsonStr);
+        OICFree(jsonStr);
+
+        if ((jsonCred) &&
+          (OC_STACK_OK == UpdateSVRDatabase(OIC_JSON_CRED_NAME, jsonCred)))
+        {
+            ret = true;
+        }
+        cJSON_Delete(jsonCred );
+    }
+    else //Empty cred list
+    {
+        if (OC_STACK_OK == UpdateSVRDatabase(OIC_JSON_CRED_NAME, NULL))
+        {
+            ret = true;
+        }
+    }
+    return ret;
+}
+
+/**
  * Compare function used LL_SORT for sorting credentials
  *
  * @param first   pointer to OicSecCred_t struct
@@ -458,6 +502,8 @@ static uint16_t GetCredId()
 exit:
     return 0;
 }
+
+
 /**
  * This function adds the new cred to the credential list.
  *
@@ -482,23 +528,41 @@ OCStackResult AddCredential(OicSecCred_t * newCred)
     //Append the new Cred to existing list
     LL_APPEND(gCred, newCred);
 
-    //Convert CredList to JSON and update the persistent Storage
-    jsonStr = BinToCredJSON(gCred);
-
-    if(jsonStr)
+    if(UpdatePersistentStorage(gCred))
     {
-        cJSON *jsonCred = cJSON_Parse(jsonStr);
-        OICFree(jsonStr);
+        ret = OC_STACK_OK;
+    }
 
-        if((jsonCred) && (OC_STACK_OK == UpdateSVRDatabase(OIC_JSON_CRED_NAME, jsonCred)))
+exit:
+    return ret;
+}
+
+OCStackResult RemoveCredential(const OicUuid_t *subject)
+{
+    OCStackResult ret = OC_STACK_ERROR;
+    OicSecCred_t *cred = NULL;
+    OicSecCred_t *tempCred = NULL;
+    bool deleteFlag = false;
+
+    LL_FOREACH_SAFE(gCred, cred, tempCred)
+    {
+        if(memcmp(cred->subject.id, subject->id, sizeof(subject->id)) == 0)
         {
-            ret = OC_STACK_OK;
+            LL_DELETE(gCred, cred);
+            FreeCred(cred);
+            deleteFlag = 1;
         }
-        cJSON_Delete(jsonCred);
     }
 
-exit:
+    if(deleteFlag)
+    {
+        if(UpdatePersistentStorage(gCred))
+        {
+            ret = OC_STACK_RESOURCE_DELETED;
+        }
+    }
     return ret;
+
 }
 
 static OCEntityHandlerResult HandlePostRequest(const OCEntityHandlerRequest * ehRequest)
@@ -520,6 +584,49 @@ static OCEntityHandlerResult HandlePostRequest(const OCEntityHandlerRequest * eh
     return ret;
 }
 
+static OCEntityHandlerResult HandleDeleteRequest(const OCEntityHandlerRequest *ehRequest)
+{
+    OC_LOG_V (INFO, TAG, PCF("Processing CredDeleteRequest"));
+
+    OCEntityHandlerResult ehRet = OC_EH_ERROR;
+
+    if(NULL == ehRequest->query)
+   {
+       return ehRet;
+   }
+
+   OicParseQueryIter_t parseIter = {.attrPos=NULL};
+   OicUuid_t subject = {.id={0}};
+
+   //Parsing REST query to get the subject
+   ParseQueryIterInit((unsigned char *)ehRequest->query, &parseIter);
+   while(GetNextQuery(&parseIter))
+   {
+       if(strncasecmp((char *)parseIter.attrPos, OIC_JSON_SUBJECT_NAME,
+               parseIter.attrLen) == 0)
+       {
+           unsigned char base64Buff[sizeof(((OicUuid_t*)0)->id)] = {};
+           uint32_t outLen = 0;
+           B64Result b64Ret = B64_OK;
+
+           b64Ret = b64Decode((char *)parseIter.valPos, parseIter.valLen,
+                   base64Buff, sizeof(base64Buff), &outLen);
+
+           VERIFY_SUCCESS(TAG, (b64Ret == B64_OK && outLen <= sizeof(subject.id)), ERROR);
+           memcpy(subject.id, base64Buff, outLen);
+       }
+   }
+
+   if(OC_STACK_RESOURCE_DELETED == RemoveCredential(&subject))
+   {
+       ehRet = OC_EH_RESOURCE_DELETED;
+   }
+
+exit:
+    return ehRet;
+}
+
+
 /*
  * This internal method is the entity handler for Cred resources
  * to handle REST request (PUT/POST/DEL)
@@ -546,6 +653,9 @@ OCEntityHandlerResult CredEntityHandler (OCEntityHandlerFlag flag,
             case OC_REST_POST:
                 ret = HandlePostRequest(ehRequest);
                 break;
+            case OC_REST_DELETE:
+                ret = HandleDeleteRequest(ehRequest);
+                break;
             default:
                 ret = OC_EH_ERROR;
                 break;
@@ -655,16 +765,16 @@ const OicSecCred_t* GetCredResourceData(const OicUuid_t* subject)
 {
     OicSecCred_t *cred = NULL;
 
-    if ( NULL == subject)
+   if ( NULL == subject)
     {
-        return NULL;
+       return NULL;
     }
 
     LL_FOREACH(gCred, cred)
     {
         if(memcmp(cred->subject.id, subject->id, sizeof(subject->id)) == 0)
         {
-             return cred;
+            return cred;
         }
     }
     return NULL;
index f295fce12d8662b6d4053d138ab0c46c8a140cd2..746a16495e5a793f8e46531e91b0eed7884f56d1 100644 (file)
@@ -128,6 +128,7 @@ OCStackResult UpdateSVRDatabase(const char* rsrcName, cJSON* jsonObj)
 {
     OCStackResult ret = OC_STACK_ERROR;
     cJSON *jsonSVRDb = NULL;
+    OCPersistentStorage* ps = NULL;
 
     // Read SVR database from PS
     char* jsonSVRDbStr = GetSVRDatabase();
@@ -140,7 +141,13 @@ OCStackResult UpdateSVRDatabase(const char* rsrcName, cJSON* jsonObj)
     OICFree(jsonSVRDbStr);
     jsonSVRDbStr = NULL;
 
-    if (jsonObj->child )
+    //If Cred resource gets updated with empty list then delete the Cred
+    //object from database.
+    if(NULL == jsonObj && (0 == strcmp(rsrcName, OIC_JSON_CRED_NAME)))
+    {
+        cJSON_DeleteItemFromObject(jsonSVRDb, rsrcName);
+    }
+    else if (jsonObj->child )
     {
         // Create a duplicate of the JSON object which was passed.
         cJSON* jsonDuplicateObj = cJSON_Duplicate(jsonObj, 1);
@@ -164,31 +171,31 @@ OCStackResult UpdateSVRDatabase(const char* rsrcName, cJSON* jsonObj)
             // Replace the modified json object in existing SVR database json
             cJSON_ReplaceItemInObject(jsonSVRDb, rsrcName, jsonDuplicateObj->child);
         }
+    }
 
-        // Generate string representation of updated SVR database json object
-        jsonSVRDbStr = cJSON_PrintUnformatted(jsonSVRDb);
-        VERIFY_NON_NULL(TAG,jsonSVRDbStr, ERROR);
+    // Generate string representation of updated SVR database json object
+    jsonSVRDbStr = cJSON_PrintUnformatted(jsonSVRDb);
+    VERIFY_NON_NULL(TAG,jsonSVRDbStr, ERROR);
 
-        // Update the persistent storage with new SVR database
-        OCPersistentStorage* ps = SRMGetPersistentStorageHandler();
-        if (ps && ps->open)
+    // Update the persistent storage with new SVR database
+    ps = SRMGetPersistentStorageHandler();
+    if (ps && ps->open)
+    {
+        FILE* fp = ps->open(SVR_DB_FILE_NAME, "w");
+        if (fp)
         {
-            FILE* fp = ps->open(SVR_DB_FILE_NAME, "w");
-            if (fp)
+            size_t bytesWritten = ps->write(jsonSVRDbStr, 1, strlen(jsonSVRDbStr), fp);
+            if (bytesWritten == strlen(jsonSVRDbStr))
             {
-                size_t bytesWritten = ps->write(jsonSVRDbStr, 1, strlen(jsonSVRDbStr), fp);
-                if (bytesWritten == strlen(jsonSVRDbStr))
-                {
-                    ret = OC_STACK_OK;
-                }
-                OC_LOG_V(INFO, TAG, PCF("Written %d bytes into SVR database file"), bytesWritten);
-                ps->close(fp);
-                fp = NULL;
-            }
-            else
-            {
-                OC_LOG (ERROR, TAG, PCF("Unable to open SVR database file!! "));
+                ret = OC_STACK_OK;
             }
+            OC_LOG_V(INFO, TAG, PCF("Written %d bytes into SVR database file"), bytesWritten);
+            ps->close(fp);
+            fp = NULL;
+        }
+        else
+        {
+            OC_LOG (ERROR, TAG, PCF("Unable to open SVR database file!! "));
         }
     }
 
index 1930002e737a432e2b7153b7a4dc51aa02adc5b4..4cca17b31ee88213807f2483404c31321e8632f9 100644 (file)
@@ -99,5 +99,6 @@ const char * OXM_PRE_PROVISIONED_STRONG_CREDENTIAL = "oic.sec.doxm.ppsc";
 const char * OIC_SEC_TRUE = "true";
 const char * OIC_SEC_FALSE = "false";
 
-const char * OIC_SEC_REST_QUERY_SEPARATOR = "&";
+const char * OIC_SEC_REST_QUERY_SEPARATOR = ";";
 char OIC_SEC_REST_QUERY_DELIMETER = '=';
+
index 5649534576dba4f7520cdb0a70cfbb03b7306527..98b6698f8d1049833b0f9790046776059f310eef 100644 (file)
@@ -26,6 +26,7 @@
 #include "ocstack.h"
 #include "ocpayload.h"
 #include "oic_malloc.h"
+#include "oic_string.h"
 #include "cJSON.h"
 #include "cainterface.h"
 #include "secureresourcemanager.h"
 #include "srmresourcestrings.h"
 #include "aclresource.h"
 #include "srmtestcommon.h"
+#include "srmutility.h"
+#include "logger.h"
 
 using namespace std;
 
+#define TAG  PCF("SRM-ACL-UT")
+
 #ifdef __cplusplus
 extern "C" {
 #endif
+
 extern char * BinToAclJSON(const OicSecAcl_t * acl);
 extern OicSecAcl_t * JSONToAclBin(const char * jsonStr);
 extern void DeleteACLList(OicSecAcl_t* acl);
@@ -55,25 +61,6 @@ const char* ACL1_JSON_FILE_NAME = "oic_unittest_acl1.json";
 
 #define NUM_ACE_FOR_WILDCARD_IN_ACL1_JSON (2)
 
-
-void SetPersistentHandler(OCPersistentStorage *ps, bool set)
-{
-    if (set)
-    {
-        ps->open = fopen;
-        ps->read = fread;
-        ps->write = fwrite;
-        ps->close = fclose;
-        ps->unlink = unlink;
-    }
-    else
-    {
-        memset(ps, 0, sizeof(OCPersistentStorage));
-    }
-    EXPECT_EQ(OC_STACK_OK,
-            OCRegisterPersistentStorageHandler(ps));
-}
-
 // JSON Marshalling Tests
 TEST(ACLResourceTest, JSONMarshallingTests)
 {
@@ -218,4 +205,143 @@ TEST(ACLResourceTest, GetACLResourceTests)
         OICFree(jsonStr);
     }
 }
+//'DELETE' ACL test
+TEST(ACLResourceTest, ACLDeleteWithSingleResourceTest)
+{
+    OCEntityHandlerRequest ehReq = {};
+    static OCPersistentStorage ps = {};
+    char *jsonStr = NULL;
+    OicSecAcl_t acl = {};
+    OicSecAcl_t* savePtr = NULL;
+    const OicSecAcl_t* subjectAcl1 = NULL;
+    const OicSecAcl_t* subjectAcl2 = NULL;
+    OCEntityHandlerResult ehRet = OC_EH_ERROR;
+    char query[] = "sub=MjIyMjIyMjIyMjIyMjIyMg==;rsrc=/a/led";
+
+    SetPersistentHandler(&ps, true);
+
+    //ACE to POST
+    memcpy(acl.subject.id, "2222222222222222", sizeof(acl.subject.id));
+    acl.resourcesLen = 1;
+    acl.resources = (char**)OICCalloc(acl.resourcesLen, sizeof(char*));
+    VERIFY_NON_NULL(TAG, acl.resources, ERROR);
+    acl.resources[0] = (char*)OICMalloc(strlen("/a/led")+1);
+    VERIFY_NON_NULL(TAG, acl.resources[0], ERROR);
+    OICStrcpy(acl.resources[0], sizeof(acl.resources[0]), "/a/led");
+    acl.permission = 6;
+    acl.ownersLen = 1;
+    acl.owners = (OicUuid_t*)OICCalloc(acl.ownersLen, sizeof(OicUuid_t));
+    VERIFY_NON_NULL(TAG, acl.owners, ERROR);
+    memcpy(acl.owners->id, "1111111111111111", sizeof(acl.owners->id));
+
+    //GET json POST payload
+    jsonStr = BinToAclJSON(&acl);
+    VERIFY_NON_NULL(TAG, jsonStr, ERROR);
+
+    // Create Entity Handler POST request payload
+    ehReq.method = OC_REST_POST;
+    ehReq.payload = (OCPayload*)OCSecurityPayloadCreate(jsonStr);
+    ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq);
+    EXPECT_TRUE(OC_EH_ERROR == ehRet);
+
+    // Verify if SRM contains ACE for the subject
+    savePtr = NULL;
+    subjectAcl1 = GetACLResourceData(&acl.subject, &savePtr);
+    EXPECT_TRUE(NULL != subjectAcl1);
+
+    // Create Entity Handler DELETE request
+    ehReq.method = OC_REST_DELETE;
+    ehReq.query = (char*)OICMalloc(strlen(query)+1);
+    VERIFY_NON_NULL(TAG, ehReq.query, ERROR);
+    OICStrcpy(ehReq.query, strlen(query)+1, query);
+    ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq);
+    EXPECT_TRUE(OC_EH_ERROR == ehRet);
+
+    // Verify if SRM has deleted ACE for the subject
+    savePtr = NULL;
+    subjectAcl2 = GetACLResourceData(&acl.subject, &savePtr);
+    EXPECT_TRUE(NULL == subjectAcl2);
+
+exit:
+    // Perform cleanup
+    if(NULL != subjectAcl1)
+    {
+        DeInitACLResource();
+    }
+    OCPayloadDestroy(ehReq.payload);
+    OICFree(ehReq.query);
+    OICFree(jsonStr);
+
+}
+
+TEST(ACLResourceTest, ACLDeleteWithMultiResourceTest)
+{
+    OCEntityHandlerRequest ehReq = {};
+    static OCPersistentStorage ps = {};
+    OicSecAcl_t acl = {};
+    char *jsonStr = NULL;
+    OicSecAcl_t* savePtr = NULL;
+    const OicSecAcl_t* subjectAcl1 = NULL;
+    const OicSecAcl_t* subjectAcl2 = NULL;
+    OCEntityHandlerResult ehRet = OC_EH_ERROR;
+    char query[] = "sub=MjIyMjIyMjIyMjIyMjIyMg==;rsrc=/a/led";
+
+    SetPersistentHandler(&ps, true);
+
+    memcpy(acl.subject.id, "2222222222222222", sizeof(acl.subject.id));
+    acl.resourcesLen = 2;
+    acl.resources = (char**)OICCalloc(acl.resourcesLen, sizeof(char*));
+    VERIFY_NON_NULL(TAG, acl.resources, ERROR);
+    acl.resources[0] = (char*)OICMalloc(strlen("/a/led")+1);
+    VERIFY_NON_NULL(TAG, acl.resources[0], ERROR);
+    OICStrcpy(acl.resources[0], sizeof(acl.resources[0]), "/a/led");
+    acl.resources[1] = (char*)OICMalloc(strlen("/a/fan")+1);
+    VERIFY_NON_NULL(TAG, acl.resources[1], ERROR);
+    OICStrcpy(acl.resources[1], sizeof(acl.resources[1]), "/a/fan");
+    acl.permission = 6;
+    acl.ownersLen = 1;
+    acl.owners = (OicUuid_t*)OICCalloc(acl.ownersLen, sizeof(OicUuid_t));
+    VERIFY_NON_NULL(TAG, acl.owners, ERROR);
+    memcpy(acl.owners->id, "1111111111111111", sizeof(acl.owners->id));
+
+    jsonStr = BinToAclJSON(&acl);
+    VERIFY_NON_NULL(TAG, jsonStr, ERROR);
+
+    // Create Entity Handler POST request payload
+    ehReq.method = OC_REST_POST;
+    ehReq.payload = (OCPayload*)OCSecurityPayloadCreate(jsonStr);
+    ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq);
+    EXPECT_TRUE(OC_EH_ERROR == ehRet);
+
+    // Verify if SRM contains ACE for the subject with two resources
+    savePtr = NULL;
+    subjectAcl1 = GetACLResourceData(&acl.subject, &savePtr);
+    EXPECT_TRUE(NULL != subjectAcl1);
+    EXPECT_TRUE(subjectAcl1->resourcesLen == 2);
+
+    // Create Entity Handler DELETE request
+    ehReq.method = OC_REST_DELETE;
+    ehReq.query = (char*)OICMalloc(strlen(query)+1);
+    VERIFY_NON_NULL(TAG, ehReq.query, ERROR);
+    OICStrcpy(ehReq.query, strlen(query)+1, query);
+
+    ehRet = ACLEntityHandler(OC_REQUEST_FLAG, &ehReq);
+    EXPECT_TRUE(OC_EH_ERROR == ehRet);
+
+    // Verify if SRM contains ACL for the subject but only with one resource
+    savePtr = NULL;
+    subjectAcl2 = GetACLResourceData(&acl.subject, &savePtr);
+    EXPECT_TRUE(NULL != subjectAcl2);
+    EXPECT_TRUE(subjectAcl2->resourcesLen == 1);
+
+exit:
+    // Perform cleanup
+    if(NULL != subjectAcl1)
+    {
+        DeInitACLResource();
+    }
+    OCPayloadDestroy(ehReq.payload);
+    OICFree(ehReq.query);
+    OICFree(jsonStr);
+}
 
index 02ce7d470b5f7b5b619f7437a417e80e838dac1c..c59d13d83f45f12f3989ea858edc5cf1d2265779 100644 (file)
 
 #include "gtest/gtest.h"
 #include "ocstack.h"
+#include "ocpayload.h"
 #include "resourcemanager.h"
 #include "securevirtualresourcetypes.h"
 #include "credresource.h"
 #include "oic_malloc.h"
 #include "oic_string.h"
+#include "srmtestcommon.h"
+#include "srmutility.h"
 #include "logger.h"
 
 #define TAG PCF("SRM-CRED-UT")
@@ -40,76 +43,74 @@ OicSecCred_t * JSONToCredBin(const char * jsonStr);
 void InitSecCredInstance(OicSecCred_t * cred);
 void DeleteCredList(OicSecCred_t* cred);
 const OicSecCred_t* GetCredResourceData(const OicUuid_t* subject);
+
 #ifdef __cplusplus
 }
 #endif
 
+
+
 OicSecCred_t * getCredList()
 {
-    OicSecCred_t * cred = (OicSecCred_t*)OICCalloc(1, sizeof(OicSecCred_t));
-    if(!cred)
-    {
-        return NULL;
-    }
+
+    OicSecCred_t * cred = NULL;
+    size_t sz = 0;
+
+    cred = (OicSecCred_t*)OICCalloc(1, sizeof(OicSecCred_t));
+    VERIFY_NON_NULL(TAG, cred, ERROR);
     cred->credId = 1234;
     OICStrcpy((char *)cred->subject.id, sizeof(cred->subject.id), "subject1");
 
 #if 0
     cred->roleIdsLen = 2;
     cred->roleIds = (OicSecRole_t *)OICCalloc(cred->roleIdsLen, sizeof(OicSecRole_t));
+    VERIFY_NON_NULL(TAG, cred->roleIds, ERROR);
     OICStrcpy((char *)cred->roleIds[0].id, sizeof(cred->roleIds[0].id), "role11");
     OICStrcpy((char *)cred->roleIds[1].id, sizeof(cred->roleIds[1].id), "role12");
+
 #endif
 
     cred->credType = 1;
+    cred->privateData.data = (char *)OICCalloc(1, strlen("My private Key11") + 1);
+    VERIFY_NON_NULL(TAG, cred->privateData.data, ERROR);
+    strcpy(cred->privateData.data, "My private Key11");
     cred->ownersLen = 1;
     cred->owners = (OicUuid_t*)OICCalloc(cred->ownersLen, sizeof(OicUuid_t));
-    if(!cred->owners)
-    {
-        OICFree(cred);
-        return NULL;
-    }
+    VERIFY_NON_NULL(TAG, cred->owners, ERROR);
     OICStrcpy((char *)cred->owners[0].id, sizeof(cred->owners[0].id), "ownersId11");
 
     cred->next = (OicSecCred_t*)OICCalloc(1, sizeof(OicSecCred_t));
-    if(!cred->next)
-    {
-        OICFree(cred->owners);
-        OICFree(cred);
-        return NULL;
-    }
+    VERIFY_NON_NULL(TAG, cred->next, ERROR);
     cred->next->credId = 5678;
     OICStrcpy((char *)cred->next->subject.id, sizeof(cred->next->subject.id), "subject2");
 #if 0
     cred->next->roleIdsLen = 0;
 #endif
     cred->next->credType = 1;
-    size_t data_size = strlen("My private Key21") + 1;
-    cred->next->privateData.data = (char *)OICCalloc(1, data_size);
-    if(!cred->next->privateData.data)
-    {
-        OICFree(cred->next);
-        OICFree(cred->owners);
-        OICFree(cred);
-        return NULL;
-    }
-    OICStrcpy(cred->next->privateData.data, data_size,"My private Key21");
+    sz = strlen("My private Key21") + 1;
+    cred->next->privateData.data = (char *)OICCalloc(1, sz);
+    VERIFY_NON_NULL(TAG, cred->next->privateData.data, ERROR);
+    OICStrcpy(cred->next->privateData.data, sz,"My private Key21");
 #if 0
-    cred->next->publicData.data = (char *)OICCalloc(1, strlen("My Public Key123") + 1);
-    OICStrcpy(cred->next->publicData.data, sizeof(cred->next->publicData.data),"My Public Key123");
+    sz = strlen("My Public Key123") + 1
+    cred->next->publicData.data = (char *)OICCalloc(1, sz);
+    VERIFY_NON_NULL(TAG, cred->next->publicData.data, ERROR);
+    OICStrcpy(cred->next->publicData.data, sz,"My Public Key123");
 #endif
     cred->next->ownersLen = 2;
     cred->next->owners = (OicUuid_t*)OICCalloc(cred->next->ownersLen, sizeof(OicUuid_t));
-    if(!cred->next->owners)
-    {
-        OICFree(cred->next->privateData.data);
-        OICFree(cred->next);
-        OICFree(cred->owners);
-        OICFree(cred);
-        return NULL;
-    }
+    VERIFY_NON_NULL(TAG, cred->next->owners, ERROR);
     OICStrcpy((char *)cred->next->owners[0].id, sizeof(cred->next->owners[0].id), "ownersId21");
     OICStrcpy((char *)cred->next->owners[1].id, sizeof(cred->next->owners[1].id), "ownersId22");
+
+    return cred;
+
+exit:
+    if(cred)
+    {
+        DeleteCredList(cred);
+        cred = NULL;
+    }
     return cred;
 }
 
@@ -161,18 +162,75 @@ TEST(CreateCredResourceTest, CreateCredResource)
 TEST(CredEntityHandlerTest, CredEntityHandlerWithDummyRequest)
 {
     OCEntityHandlerRequest req;
-    EXPECT_EQ(OC_EH_ERROR, CredEntityHandler(OCEntityHandlerFlag::OC_REQUEST_FLAG, &req));
+    EXPECT_EQ(OC_EH_ERROR,
+            CredEntityHandler(OCEntityHandlerFlag::OC_REQUEST_FLAG, &req));
 }
 
 TEST(CredEntityHandlerTest, CredEntityHandlerWithNULLRequest)
 {
-    EXPECT_EQ(OC_EH_ERROR, CredEntityHandler(OCEntityHandlerFlag::OC_REQUEST_FLAG, NULL));
+    EXPECT_EQ(OC_EH_ERROR,
+            CredEntityHandler(OCEntityHandlerFlag::OC_REQUEST_FLAG, NULL));
 }
 
 TEST(CredEntityHandlerTest, CredEntityHandlerInvalidFlag)
 {
     OCEntityHandlerRequest req;
-    EXPECT_EQ(OC_EH_ERROR, CredEntityHandler(OCEntityHandlerFlag::OC_OBSERVE_FLAG, &req));
+    EXPECT_EQ(OC_EH_ERROR,
+            CredEntityHandler(OCEntityHandlerFlag::OC_OBSERVE_FLAG, &req));
+}
+
+//Cred DELETE request
+TEST(CredEntityHandlerTest, CredEntityHandlerDeleteTest)
+{
+    OCEntityHandlerRequest ehReq = {};
+    static OCPersistentStorage ps = {};
+    const OicSecCred_t* subjectCred1 = NULL;
+    const OicSecCred_t* subjectCred2 = NULL;
+    char *jsonStr = NULL;
+    OCEntityHandlerResult ehRet = OC_EH_ERROR;
+    char query[] = "sub=c3ViamVjdDE=";
+
+    SetPersistentHandler(&ps, true);
+
+    OicSecCred_t *cred = getCredList();
+    VERIFY_NON_NULL(TAG, cred, ERROR);
+
+    jsonStr = BinToCredJSON(cred);
+    VERIFY_NON_NULL(TAG, jsonStr, ERROR);
+
+    // Create Entity Handler POST request payload
+    ehReq.method = OC_REST_POST;
+    ehReq.payload = (OCPayload*)OCSecurityPayloadCreate(jsonStr);
+    ehRet = CredEntityHandler(OC_REQUEST_FLAG, &ehReq);
+    EXPECT_TRUE(OC_EH_ERROR == ehRet);
+
+    // Verify if SRM contains Credential for the subject
+    subjectCred1 = GetCredResourceData(&cred->subject);
+    EXPECT_TRUE(NULL != subjectCred1);
+
+   // Create Entity Handler DELETE request
+   ehReq.method = OC_REST_DELETE;
+   ehReq.query = (char*)OICMalloc(strlen(query)+1);
+   VERIFY_NON_NULL(TAG, ehReq.query, ERROR);
+   OICStrcpy(ehReq.query, strlen(query)+1, query);
+
+   ehRet = CredEntityHandler(OC_REQUEST_FLAG, &ehReq);
+   EXPECT_TRUE(OC_EH_ERROR == ehRet);
+
+   // Verify if SRM has deleted ACE for the subject
+   subjectCred2 = GetCredResourceData(&cred->subject);
+   EXPECT_TRUE(NULL == subjectCred2);
+
+exit:
+   // Perform cleanup
+   OICFree(ehReq.query);
+   OICFree(jsonStr);
+   OCPayloadDestroy(ehReq.payload);
+   if(NULL != cred)
+   {
+       DeInitCredResource();
+       DeleteCredList(cred);
+   }
 }
 
 //BinToCredJSON Tests
@@ -189,6 +247,7 @@ TEST(BinToCredJSONTest, BinToCredJSONValidCred)
 
     json = BinToCredJSON(cred);
 
+    OC_LOG_V(INFO, TAG, PCF("BinToCredJSON:%s\n"), json);
     EXPECT_TRUE(json != NULL);
     DeleteCredList(cred);
     OICFree(json);
@@ -202,7 +261,7 @@ TEST(JSONToCredBinTest, JSONToCredBinValidJSON)
 
     EXPECT_TRUE(json != NULL);
     OicSecCred_t *cred2 = JSONToCredBin(json);
-    EXPECT_TRUE(cred2 == NULL);
+    EXPECT_TRUE(cred2 != NULL);
     DeleteCredList(cred1);
     DeleteCredList(cred2);
     OICFree(json);
@@ -236,6 +295,7 @@ TEST(CredGenerateCredentialTest, GenerateCredentialValidInput)
                              privateKey, 1, owners);
     printCred(cred);
 
+    EXPECT_TRUE(NULL != cred);
     DeleteCredList(cred);
 }
 
index 1395e87b3a70bafda52df574c9b99f3df14efccb..4c098655ac3334d1b7587e67dd1bed0d95015e7c 100644 (file)
@@ -25,6 +25,9 @@
 #include "ocserverrequest.h"
 #include "oic_string.h"
 #include "oic_malloc.h"
+#include "logger.h"
+
+#define TAG  PCF("SRM-DOXM")
 
 #ifdef __cplusplus
 extern "C" {
@@ -126,7 +129,7 @@ TEST(DoxmEntityHandlerTest, DoxmEntityHandlerInvalidFlag)
 TEST(DoxmEntityHandlerTest, DoxmEntityHandlerValidRequest)
 {
     EXPECT_EQ(OC_STACK_INVALID_PARAM, InitDoxmResource());
-    char query[] = "oxm=0&owned=false&owner=owner1";
+    char query[] = "oxm=0;owned=false;owner=owner1";
     OCEntityHandlerRequest req = {};
     req.method = OC_REST_GET;
     req.query = OICStrdup(query);
@@ -147,6 +150,7 @@ TEST(BinToDoxmJSONTest, BinToDoxmJSONValidDoxm)
     OicSecDoxm_t * doxm =  getBinDoxm();
 
     char * json = BinToDoxmJSON(doxm);
+    OC_LOG_V(INFO, TAG, PCF("BinToDoxmJSON:%s"), json);
     EXPECT_TRUE(json != NULL);
 
     DeleteDoxmBinData(doxm);
index 2de6f8599e7dae5f0033d8c97ae4573e1d61736b..6f513298443b808ff2d5de14fe485923519ba0e1 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "gtest/gtest.h"
 #include "oic_malloc.h"
+#include "ocstack.h"
 
 char* ReadFile(const char* filename)
 {
@@ -53,3 +54,20 @@ char* ReadFile(const char* filename)
     return data;
 }
 
+void SetPersistentHandler(OCPersistentStorage *ps, bool set)
+{
+    if (set)
+    {
+        ps->open = fopen;
+        ps->read = fread;
+        ps->write = fwrite;
+        ps->close = fclose;
+        ps->unlink = unlink;
+    }
+    else
+    {
+        memset(ps, 0, sizeof(OCPersistentStorage));
+    }
+    EXPECT_EQ(OC_STACK_OK,
+            OCRegisterPersistentStorageHandler(ps));
+}
index 08f8c632d4450190a8f7bfeae30bb20e86254f55..1a8685ec7d272c9bfa436e9052bb9c4d0a9acafd 100644 (file)
@@ -22,6 +22,6 @@
 #define IOTVT_SRM_TEST_COMMON_H
 
 char* ReadFile(const char* filename);
+void SetPersistentHandler(OCPersistentStorage *ps, bool set);
 
 #endif //IOTVT_SRM_TEST_COMMON_H
-
index 7dd22170aee6e96153c59372fed7ccedf5bd5afc..5d7216f7b2441f804322cb91322ec115d5ca75e1 100644 (file)
@@ -21,7 +21,6 @@
 #include "srmutility.h"
 #include "oic_string.h"
 
-
 //ParseRestQuery Tests
 TEST(ParseRestQueryTest, ParseRestQueryEmpty)
 {
@@ -43,13 +42,12 @@ TEST(ParseRestQueryTest, ParseSingleRestQuery)
     OICStrcpyPartial(attr, sizeof(attr), (char *)parseIter.attrPos, parseIter.attrLen);
     OICStrcpyPartial(val, sizeof(val), (char *)parseIter.valPos, parseIter.valLen);
     printf("\nAttribute: %s  value: %s\n\n", attr, val);
-
 }
 
 TEST(ParseRestQueryTest, ParseRestMultipleQuery)
 {
     char attr[10], val[10];
-    unsigned char query[] = "oxm=0&owned=true&owner=owner1";
+    unsigned char query[] = "oxm=0;owned=true;owner=owner1";
 
     OicParseQueryIter_t parseIter = {};
     ParseQueryIterInit(query, &parseIter);
index 42b2c29dca41f4a765818fe9a1239dde2cee22e7..8621818c873c4c0c4150dad203da251c7df4a80a 100644 (file)
              "perms": 2,
              "ownrs" : ["MTExMTExMTExMTExMTExMQ=="]
         },
+        {
+            "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
+            "rsrc": ["/oic/sec/acl",
+                      "/oic/sec/cred"],
+            "perms": 8,
+            "ownrs" : ["MjIyMjIyMjIyMjIyMjIyMg=="]
+        },
         {
             "sub": "MjIyMjIyMjIyMjIyMjIyMg==",
             "rsrc": ["/a/led"],