+ EXPECT_EQ(OC_EH_ERROR,
+ CredEntityHandler(OCEntityHandlerFlag::OC_OBSERVE_FLAG, &req));
+}
+
+//Cred DELETE request
+TEST(CredEntityHandlerTest, CredEntityHandlerDeleteTest)
+{
+ OCEntityHandlerRequest ehReq = OCEntityHandlerRequest();
+ static OCPersistentStorage ps = OCPersistentStorage();
+ 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);
+ }