void
testValidationSetV1_KeyId_KeyLocator_KeyId_KeyName(TestData *data,
                                                   bool (*set)(CCNxTlvDictionary *message, const PARCBuffer *keyid,
                                                               const CCNxKeyLocator *keyLocator),
                                                   bool (*test)(const CCNxTlvDictionary *message))
{
    CCNxName *name = ccnxName_CreateFromURI("lci:/parc/validation/test");
    CCNxTlvDictionary *packetV1 = ccnxContentObject_CreateWithImplAndPayload(&CCNxContentObjectFacadeV1_Implementation,
                                                                             name,
                                                                             CCNxPayloadType_DATA,
                                                                             NULL);
    bool success = set(packetV1, data->keyid, data->locatorByName);
    assertTrue(success, "Failed to set on V1");

    bool testResult = test(packetV1);
    assertTrue(testResult, "Test function failed on V1 packet");

    PARCBuffer *testKeyId = ccnxValidationFacadeV1_GetKeyId(packetV1);
    assertTrue(parcBuffer_Equals(testKeyId, data->keyid), "keyid not equal");

    // XXX: TODO: GetKeyName() returns a Link, so it should be GetLink().
    //            It also creates a new object (the CCNxLink), so... needs thinking about.
    //            See BugzId: 3322

    CCNxLink *testLink = ccnxValidationFacadeV1_GetKeyName(packetV1);
    assertTrue(ccnxName_Equals(ccnxLink_GetName(testLink), data->keyname), "Keynames not equal");
    ccnxLink_Release(&testLink);

    ccnxName_Release(&name);
    ccnxTlvDictionary_Release(&packetV1);
}
LONGBOW_TEST_CASE(Global, ccnxKeyLocator_GetKeyName)
{
    CCNxName *keyURIName = ccnxName_CreateFromCString("lci://name/test");
    CCNxLink *keyLink = ccnxLink_Create(keyURIName, NULL, NULL);
    CCNxKeyLocator *keyLocator = ccnxKeyLocator_CreateFromKeyLink(keyLink);

    ccnxKeyLocator_AssertValid(keyLocator);
    const CCNxName *actual = ccnxLink_GetName(ccnxKeyLocator_GetKeyLink(keyLocator));
    assertTrue(ccnxName_Equals(actual, keyURIName), "Actual keyName did not match the one returned by GetKeyName()");

    ccnxKeyLocator_Release(&keyLocator);
    ccnxName_Release(&keyURIName);
    ccnxLink_Release(&keyLink);
}
Example #3
0
LONGBOW_TEST_CASE(Global, ccnxLink_GetName)
{
    CCNxName *name = ccnxName_CreateFromCString("lci:/foo/bar/name");
    PARCBuffer *keyId = parcBuffer_Allocate(10);
    PARCBuffer *contentObjectHash = parcBuffer_Allocate(10);

    CCNxLink *object = ccnxLink_Create(name, keyId, contentObjectHash);

    const CCNxName *actualName = ccnxLink_GetName(object);
    assertNotNull(actualName, "Expected non-null return value.");
    assertTrue(ccnxName_Equals(name, actualName), "Expected the same name back");

    ccnxLink_Release(&object);

    ccnxName_Release(&name);
    parcBuffer_Release(&keyId);
    parcBuffer_Release(&contentObjectHash);
}