OicSecCred_t *cred = (OicSecCred_t *)OICCalloc(1, sizeof(*cred));
VERIFY_NON_NULL(TAG, cred, ERROR);
cred->credId = 1234;
- OICStrcpy((char *)cred->subject.id, sizeof(cred->subject.id), "subject1");
+ OICStrcpy((char *)cred->subject.id, sizeof(cred->subject.id)+1, "1111111111111111");
#if 0
cred->roleIdsLen = 2;
cred->privateData.data = (uint8_t *)OICCalloc(1, strlen("My private Key11") + 1);
VERIFY_NON_NULL(TAG, cred->privateData.data, ERROR);
OICStrcpy((char *)cred->privateData.data, strlen("My private Key11")+1,"My private Key11");
- cred->ownersLen = 1;
- cred->owners = (OicUuid_t *)OICCalloc(cred->ownersLen, sizeof(*cred->owners));
- VERIFY_NON_NULL(TAG, cred->owners, ERROR);
- OICStrcpy((char *)cred->owners[0].id, sizeof(cred->owners[0].id), "ownersId11");
+ OICStrcpy((char *)cred->rownerID.id, sizeof(cred->rownerID.id), "aaaaaaaaaaaaaaaa");
cred->next = (OicSecCred_t*)OICCalloc(1, sizeof(*cred->next));
VERIFY_NON_NULL(TAG, cred->next, ERROR);
cred->next->credId = 5678;
- OICStrcpy((char *)cred->next->subject.id, sizeof(cred->next->subject.id), "subject2");
+ OICStrcpy((char *)cred->next->subject.id, sizeof(cred->next->subject.id)+1, "2222222222222222");
#if 0
cred->next->roleIdsLen = 0;
#endif
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(*cred->next->owners));
- 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");
+ OICStrcpy((char *)cred->next->rownerID.id, sizeof(cred->next->rownerID.id), "bbbbbbbbbbbbbbbb");
return cred;
OIC_LOG_V(INFO, TAG, "cred->publicData.data = %s", credTmp1->publicData.data);
}
#endif /* __WITH_X509__ */
- OIC_LOG_V(INFO, TAG, "cred->ownersLen = %zu", credTmp1->ownersLen);
- for(size_t i = 0; i < cred->ownersLen; i++)
- {
- OIC_LOG_V(INFO, TAG, "cred->owners[%zu].id = %s", i, credTmp1->owners[i].id);
- }
+ OIC_LOG_V(INFO, TAG, "cred->rownerID = %s", credTmp1->rownerID.id);
}
}
const OicSecCred_t* subjectCred1 = NULL;
const OicSecCred_t* subjectCred2 = NULL;
OCEntityHandlerResult ehRet = OC_EH_ERROR;
- char query[] = "sub=c3ViamVjdDE="; //base64 Encoding of subject1
+ char query[] = "subjectuuid=31313131-3131-3131-3131-313131313131"; //canonical uuid of subject1
SetPersistentHandler(&ps, true);
OicSecCred_t *cred = getCredList();
ASSERT_TRUE(NULL != cred);
-
uint8_t *payload = NULL;
size_t size = 0;
EXPECT_EQ(OC_STACK_OK, CredToCBORPayload(cred, &payload, &size));
subjectCred1 = GetCredResourceData(&cred->subject);
EXPECT_TRUE(NULL != subjectCred1);
- // Create Entity Handler DELETE request
- ehReq.method = OC_REST_DELETE;
- ehReq.query = (char *)OICCalloc(1, strlen(query)+1);
- if (!ehReq.query)
- {
- OICFree(payload);
- DeleteCredList(cred);
- }
- ASSERT_TRUE(NULL != ehReq.query);
- OICStrcpy(ehReq.query, strlen(query)+1, query);
-
- ehRet = CredEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
- EXPECT_EQ(OC_EH_ERROR, ehRet);
-
- // Verify if SRM has deleted ACE for the subject
- subjectCred2 = GetCredResourceData(&cred->subject);
- EXPECT_TRUE(NULL == subjectCred2);
-
- // Perform cleanup
- OICFree(ehReq.query);
- OICFree(payload);
- DeInitCredResource();
- DeleteCredList(cred);
- OCPayloadDestroy((OCPayload *)ehReq.payload);
+ // Create Entity Handler DELETE request
+ ehReq.method = OC_REST_DELETE;
+ ehReq.query = (char *)OICCalloc(1, strlen(query)+1);
+ if (!ehReq.query)
+ {
+ OICFree(payload);
+ DeleteCredList(cred);
+ }
+ ASSERT_TRUE(NULL != ehReq.query);
+ OICStrcpy(ehReq.query, strlen(query)+1, query);
+
+ ehRet = CredEntityHandler(OC_REQUEST_FLAG, &ehReq, NULL);
+ EXPECT_EQ(OC_EH_ERROR, ehRet);
+
+ // Verify if SRM has deleted ACE for the subject
+ subjectCred2 = GetCredResourceData(&cred->subject);
+ EXPECT_TRUE(NULL == subjectCred2);
+
+ // Perform cleanup
+ OICFree(ehReq.query);
+ OICFree(payload);
+ DeInitCredResource();
+ DeleteCredList(cred);
+ OCPayloadDestroy((OCPayload *)ehReq.payload);
}
TEST(CredResourceTest, CredToCBORPayloadNULL)
TEST(CredResourceTest, GenerateCredentialValidInput)
{
- OicUuid_t owners[1];
- OICStrcpy((char *)owners[0].id, strlen("ownersId21"), "ownersId21");
+ OicUuid_t rownerID = {{0}};
+ OICStrcpy((char *)rownerID.id, strlen("ownersId21"), "ownersId21");
OicUuid_t subject = {{0}};
OICStrcpy((char *)subject.id, strlen("subject11"), "subject11");
OicSecKey_t key = {privateKey, sizeof(privateKey)};
OicSecCred_t * cred = NULL;
-
cred = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
- &key, 1, owners);
+ &key, &rownerID);
printCred(cred);
ASSERT_TRUE(NULL != cred);
TEST(CredResourceTest, GenerateAndAddCredentialValidInput)
{
- OicUuid_t owners[1];
- OICStrcpy((char *)owners[0].id, sizeof(owners[0].id), "ownersId11");
+ OicUuid_t rownerID = {{0}};
+ OICStrcpy((char *)rownerID.id, sizeof(rownerID.id), "ownersId11");
OicUuid_t subject = {{0}};
OICStrcpy((char *)subject.id, sizeof(subject.id), "subject11");
OicSecCred_t *headCred = NULL;
cred1 = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
- &key, 1, owners);
+ &key, &rownerID);
EXPECT_EQ(OC_STACK_OK, AddCredential(cred1));
headCred = cred1;
- OICStrcpy((char *)owners[0].id, sizeof(owners[0].id), "ownersId22");
+ OICStrcpy((char *)rownerID.id, sizeof(rownerID.id), "ownersId22");
OICStrcpy((char *)subject.id, sizeof(subject.id), "subject22");
cred1 = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
- &key, 1, owners);
+ &key, &rownerID);
EXPECT_EQ(OC_STACK_OK, AddCredential(cred1));
- OICStrcpy((char *)owners[0].id, sizeof(owners[0].id), "ownersId33");
+ OICStrcpy((char *)rownerID.id, sizeof(rownerID.id), "ownersId33");
OICStrcpy((char *)subject.id, sizeof(subject.id), "subject33");
cred1 = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
- &key, 1, owners);
+ &key, &rownerID);
EXPECT_EQ(OC_STACK_OK, AddCredential(cred1));
const OicSecCred_t* credList = GetCredResourceData(&headCred->subject);