KineticStatus KineticAdminClient_GetDeviceSpecificLog(KineticSession * const session, ByteArray name, KineticLogInfo** info, KineticCompletionClosure* closure) { KINETIC_ASSERT(session != NULL); KINETIC_ASSERT(info != NULL); KineticOperation* operation = KineticAllocator_NewOperation(session); if (operation == NULL) {return KINETIC_STATUS_MEMORY_ERROR;} // Initialize request KineticBuilder_BuildGetLog(operation, COM__SEAGATE__KINETIC__PROTO__COMMAND__GET_LOG__TYPE__DEVICE, name, info); // Execute the operation return KineticController_ExecuteOperation(operation, closure); }
KineticStatus KineticAdminClient_GetLog(KineticSession * const session, KineticLogInfo_Type type, KineticLogInfo** info, KineticCompletionClosure* closure) { KINETIC_ASSERT(session != NULL); KINETIC_ASSERT(info != NULL); Com__Seagate__Kinetic__Proto__Command__GetLog__Type protoType = KineticLogInfo_Type_to_Com__Seagate__Kinetic__Proto__Command__GetLog__Type(type); if (protoType == COM__SEAGATE__KINETIC__PROTO__COMMAND__GET_LOG__TYPE__INVALID_TYPE) { return KINETIC_STATUS_INVALID_LOG_TYPE; } KineticOperation* operation = KineticAllocator_NewOperation(session); if (operation == NULL) {return KINETIC_STATUS_MEMORY_ERROR;} // Initialize request KineticBuilder_BuildGetLog(operation, protoType, BYTE_ARRAY_NONE, info); // Execute the operation return KineticController_ExecuteOperation(operation, closure); }
void test_KineticBuilder_BuildPut_should_build_and_execute_a_PUT_operation_to_create_a_new_object_with_calculated_tag(void) { ByteArray value = ByteArray_CreateWithCString("Luke, I am your father"); ByteArray key = ByteArray_CreateWithCString("foobar"); ByteArray newVersion = ByteArray_CreateWithCString("v1.0"); ByteArray tag = ByteArray_CreateWithCString("some_tag"); KineticEntry entry = { .key = ByteBuffer_CreateWithArray(key), .newVersion = ByteBuffer_CreateWithArray(newVersion), .tag = ByteBuffer_CreateWithArray(tag), .algorithm = KINETIC_ALGORITHM_SHA1, .value = ByteBuffer_CreateWithArray(value), .computeTag = true, }; KineticOperation_ValidateOperation_Expect(&Operation); KineticMessage_ConfigureKeyValue_Expect(&Operation.request->message, &entry); // Build the operation KineticBuilder_BuildPut(&Operation, &entry); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL_PTR(entry.value.array.data, Operation.value.data); TEST_ASSERT_EQUAL(entry.value.bytesUsed, Operation.value.len); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__PUT, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_ByteArray(value, Operation.entry->value.array); TEST_ASSERT_EQUAL(0, Operation.entry->value.bytesUsed); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); } uint8_t ValueData[KINETIC_OBJ_SIZE]; void test_KineticBuilder_BuildGet_should_build_a_GET_operation(void) { const ByteArray key = ByteArray_CreateWithCString("foobar"); ByteArray value = {.data = ValueData, .len = sizeof(ValueData)}; KineticEntry entry = { .key = ByteBuffer_CreateWithArray(key), .value = ByteBuffer_CreateWithArray(value), }; entry.value.bytesUsed = 123; // Set to non-empty state, since it should be reset to 0 KineticOperation_ValidateOperation_Expect(&Operation); KineticMessage_ConfigureKeyValue_Expect(&Request.message, &entry); KineticBuilder_BuildGet(&Operation, &entry); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__GET, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(KineticCallbacks_Get, Operation.opCallback); TEST_ASSERT_EQUAL_PTR(value.data, Operation.entry->value.array.data); TEST_ASSERT_EQUAL(value.len, Operation.entry->value.array.len); TEST_ASSERT_EQUAL(0, Operation.entry->value.bytesUsed); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); TEST_ASSERT_FALSE(Operation.entry->metadataOnly); } void test_KineticBuilder_BuildGet_should_build_a_GET_operation_requesting_metadata_only(void) { const ByteArray key = ByteArray_CreateWithCString("foobar"); ByteArray value = ByteArray_Create(ValueData, sizeof(ValueData)); KineticEntry entry = { .key = ByteBuffer_CreateWithArray(key), .metadataOnly = true, .value = ByteBuffer_CreateWithArray(value), }; entry.value.bytesUsed = 123; // Set to non-empty state, since it should be reset to 0 for a metadata-only request KineticOperation_ValidateOperation_Expect(&Operation); KineticMessage_ConfigureKeyValue_Expect(&Request.message, &entry); KineticBuilder_BuildGet(&Operation, &entry); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__GET, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(KineticCallbacks_Get, Operation.opCallback); TEST_ASSERT_EQUAL_PTR(value.data, Operation.entry->value.array.data); TEST_ASSERT_EQUAL_PTR(value.len, Operation.entry->value.array.len); TEST_ASSERT_EQUAL(0, Operation.entry->value.bytesUsed); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); TEST_ASSERT_TRUE(Operation.entry->metadataOnly); } void test_KineticBuilder_BuildGetNext_should_build_a_GETNEXT_operation(void) { const ByteArray key = ByteArray_CreateWithCString("foobar"); ByteArray value = {.data = ValueData, .len = sizeof(ValueData)}; KineticEntry entry = { .key = ByteBuffer_CreateWithArray(key), .value = ByteBuffer_CreateWithArray(value), }; entry.value.bytesUsed = 123; // Set to non-empty state, since it should be reset to 0 KineticOperation_ValidateOperation_Expect(&Operation); KineticMessage_ConfigureKeyValue_Expect(&Request.message, &entry); KineticBuilder_BuildGetNext(&Operation, &entry); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__GETNEXT, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(KineticCallbacks_Get, Operation.opCallback); TEST_ASSERT_EQUAL_PTR(value.data, Operation.entry->value.array.data); TEST_ASSERT_EQUAL(value.len, Operation.entry->value.array.len); TEST_ASSERT_EQUAL(0, Operation.entry->value.bytesUsed); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); TEST_ASSERT_FALSE(Operation.entry->metadataOnly); } void test_KineticBuilder_BuildGetNext_should_build_a_GETNEXT_operation_with_metadata_only(void) { const ByteArray key = ByteArray_CreateWithCString("foobar"); ByteArray value = ByteArray_Create(ValueData, sizeof(ValueData)); KineticEntry entry = { .key = ByteBuffer_CreateWithArray(key), .metadataOnly = true, .value = ByteBuffer_CreateWithArray(value), }; entry.value.bytesUsed = 123; // Set to non-empty state, since it should be reset to 0 for a metadata-only request KineticOperation_ValidateOperation_Expect(&Operation); KineticMessage_ConfigureKeyValue_Expect(&Request.message, &entry); KineticBuilder_BuildGetNext(&Operation, &entry); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__GETNEXT, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(KineticCallbacks_Get, Operation.opCallback); TEST_ASSERT_EQUAL_PTR(value.data, Operation.entry->value.array.data); TEST_ASSERT_EQUAL_PTR(value.len, Operation.entry->value.array.len); TEST_ASSERT_EQUAL(0, Operation.entry->value.bytesUsed); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); TEST_ASSERT_TRUE(Operation.entry->metadataOnly); } void test_KineticBuilder_BuildGetPrevious_should_build_a_GETPREVIOUS_operation(void) { const ByteArray key = ByteArray_CreateWithCString("foobar"); ByteArray value = {.data = ValueData, .len = sizeof(ValueData)}; KineticEntry entry = { .key = ByteBuffer_CreateWithArray(key), .value = ByteBuffer_CreateWithArray(value), }; entry.value.bytesUsed = 123; // Set to non-empty state, since it should be reset to 0 KineticOperation_ValidateOperation_Expect(&Operation); KineticMessage_ConfigureKeyValue_Expect(&Request.message, &entry); KineticBuilder_BuildGetPrevious(&Operation, &entry); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__GETPREVIOUS, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(KineticCallbacks_Get, Operation.opCallback); TEST_ASSERT_EQUAL_PTR(value.data, Operation.entry->value.array.data); TEST_ASSERT_EQUAL(value.len, Operation.entry->value.array.len); TEST_ASSERT_EQUAL(0, Operation.entry->value.bytesUsed); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); TEST_ASSERT_FALSE(Operation.entry->metadataOnly); } void test_KineticBuilder_BuildGetPrevious_should_build_a_GETPREVIOUS_operation_with_metadata_only(void) { const ByteArray key = ByteArray_CreateWithCString("foobar"); ByteArray value = ByteArray_Create(ValueData, sizeof(ValueData)); KineticEntry entry = { .key = ByteBuffer_CreateWithArray(key), .metadataOnly = true, .value = ByteBuffer_CreateWithArray(value), }; entry.value.bytesUsed = 123; // Set to non-empty state, since it should be reset to 0 for a metadata-only request KineticOperation_ValidateOperation_Expect(&Operation); KineticMessage_ConfigureKeyValue_Expect(&Request.message, &entry); KineticBuilder_BuildGetPrevious(&Operation, &entry); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__GETPREVIOUS, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(KineticCallbacks_Get, Operation.opCallback); TEST_ASSERT_EQUAL_PTR(value.data, Operation.entry->value.array.data); TEST_ASSERT_EQUAL_PTR(value.len, Operation.entry->value.array.len); TEST_ASSERT_EQUAL(0, Operation.entry->value.bytesUsed); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); TEST_ASSERT_TRUE(Operation.entry->metadataOnly); } void test_KineticBuilder_BuildFlush_should_build_a_FLUSHALLDATA_operation(void) { KineticOperation_ValidateOperation_Expect(&Operation); KineticBuilder_BuildFlush(&Operation); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__FLUSHALLDATA, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(KineticCallbacks_Basic, Operation.opCallback); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); } void test_KineticBuilder_BuildDelete_should_build_a_DELETE_operation(void) { const ByteArray key = ByteArray_CreateWithCString("foobar"); ByteArray value = ByteArray_Create(ValueData, sizeof(ValueData)); KineticEntry entry = {.key = ByteBuffer_CreateWithArray(key), .value = ByteBuffer_CreateWithArray(value)}; KineticOperation_ValidateOperation_Expect(&Operation); KineticMessage_ConfigureKeyValue_Expect(&Request.message, &entry); KineticBuilder_BuildDelete(&Operation, &entry); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__DELETE, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(KineticCallbacks_Delete, Operation.opCallback); TEST_ASSERT_EQUAL_PTR(value.data, Operation.entry->value.array.data); TEST_ASSERT_EQUAL_PTR(value.len, Operation.entry->value.array.len); TEST_ASSERT_EQUAL(0, Operation.entry->value.bytesUsed); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); } void test_KineticBuilder_BuildGetKeyRange_should_build_a_GetKeyRange_request(void) { const int maxKeyLen = 32; // arbitrary key length for test uint8_t startKeyData[maxKeyLen]; uint8_t endKeyData[maxKeyLen]; ByteBuffer startKey, endKey; startKey = ByteBuffer_Create(startKeyData, sizeof(startKeyData), 0); ByteBuffer_AppendCString(&startKey, "key_range_00_00"); endKey = ByteBuffer_Create(endKeyData, sizeof(endKeyData), 0); ByteBuffer_AppendCString(&endKey, "key_range_00_03"); const int numKeysInRange = 4; KineticKeyRange range = { .startKey = startKey, .endKey = endKey, .startKeyInclusive = true, .endKeyInclusive = true, .maxReturned = numKeysInRange, .reverse = false, }; uint8_t keysData[numKeysInRange][maxKeyLen]; ByteBuffer keyBuffers[numKeysInRange]; for (int i = 0; i < numKeysInRange; i++) { keyBuffers[i] = ByteBuffer_Create(keysData[i], maxKeyLen, 0); } ByteBufferArray keys = {.buffers = keyBuffers, .count = numKeysInRange}; KineticOperation_ValidateOperation_Expect(&Operation); KineticMessage_ConfigureKeyRange_Expect(&Request.message, &range); KineticBuilder_BuildGetKeyRange(&Operation, &range, &keys); TEST_ASSERT_TRUE(Request.command->header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__GETKEYRANGE, Request.command->header->messagetype); TEST_ASSERT_EQUAL_PTR(KineticCallbacks_GetKeyRange, Operation.opCallback); TEST_ASSERT_NULL(Operation.entry); TEST_ASSERT_EQUAL_PTR(&Request, Operation.request); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); TEST_ASSERT_EQUAL_PTR(&Request.message.command, Request.command); } void test_KineticBuilder_BuildP2POperation_should_build_a_P2POperation_request(void) { ByteBuffer oldKey1 = ByteBuffer_Create((void*)0x1234, 10, 10); ByteBuffer newKey1 = ByteBuffer_Create((void*)0x4321, 33, 33); ByteBuffer version1 = ByteBuffer_Create((void*)0xABC, 6, 6); ByteBuffer oldKey2 = ByteBuffer_Create((void*)0x5678, 12, 12); ByteBuffer newKey2 = ByteBuffer_Create((void*)0x8765, 200, 200); KineticP2P_OperationData ops2[] ={ { .key = oldKey2, .newKey = newKey2, } }; KineticP2P_Operation chained_p2pOp = { .peer = { .hostname = "hostname1", .port = 4321, }, .numOperations = 1, .operations = ops2 }; KineticP2P_OperationData ops[] ={ { .key = oldKey1, .version = version1, .newKey = newKey1, .chainedOperation = &chained_p2pOp, }, { .key = oldKey2, .newKey = newKey2, } }; KineticP2P_Operation p2pOp = { .peer = { .hostname = "hostname", .port = 1234, .tls = true, }, .numOperations = 2, .operations = ops }; KineticOperation_ValidateOperation_Expect(&Operation); KineticBuilder_BuildP2POperation(&Operation, &p2pOp); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__PEER2PEERPUSH, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(&Request.message.body, Request.command->body); TEST_ASSERT_NOT_NULL(Request.command->body->p2poperation); TEST_ASSERT_EQUAL("hostname", Request.command->body->p2poperation->peer->hostname); TEST_ASSERT_TRUE(Request.command->body->p2poperation->peer->has_port); TEST_ASSERT_EQUAL(1234, Request.command->body->p2poperation->peer->port); TEST_ASSERT_TRUE(Request.command->body->p2poperation->peer->has_tls); TEST_ASSERT_TRUE(Request.command->body->p2poperation->peer->tls); TEST_ASSERT_FALSE(Request.command->body->p2poperation->allchildoperationssucceeded); TEST_ASSERT_FALSE(Request.command->body->p2poperation->has_allchildoperationssucceeded); TEST_ASSERT_EQUAL(2, Request.command->body->p2poperation->n_operation); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[0]->has_key); TEST_ASSERT_EQUAL(oldKey1.array.data, Request.command->body->p2poperation->operation[0]->key.data); TEST_ASSERT_EQUAL(oldKey1.bytesUsed, Request.command->body->p2poperation->operation[0]->key.len); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[0]->has_newkey); TEST_ASSERT_EQUAL(newKey1.array.data, Request.command->body->p2poperation->operation[0]->newkey.data); TEST_ASSERT_EQUAL(newKey1.bytesUsed, Request.command->body->p2poperation->operation[0]->newkey.len); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[0]->has_version); TEST_ASSERT_EQUAL(version1.array.data, Request.command->body->p2poperation->operation[0]->version.data); TEST_ASSERT_EQUAL(version1.bytesUsed, Request.command->body->p2poperation->operation[0]->version.len); TEST_ASSERT_FALSE(Request.command->body->p2poperation->operation[0]->has_force); TEST_ASSERT_FALSE(Request.command->body->p2poperation->operation[0]->force); TEST_ASSERT_NOT_NULL(Request.command->body->p2poperation->operation[0]->p2pop); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[0]->p2pop->peer->has_port); TEST_ASSERT_EQUAL(4321, Request.command->body->p2poperation->operation[0]->p2pop->peer->port); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[0]->p2pop->peer->has_tls); TEST_ASSERT_FALSE(Request.command->body->p2poperation->operation[0]->p2pop->peer->tls); TEST_ASSERT_EQUAL(1, Request.command->body->p2poperation->operation[0]->p2pop->n_operation); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[0]->p2pop->operation[0]->has_key); TEST_ASSERT_EQUAL(oldKey2.array.data, Request.command->body->p2poperation->operation[0]->p2pop->operation[0]->key.data); TEST_ASSERT_EQUAL(oldKey2.bytesUsed, Request.command->body->p2poperation->operation[0]->p2pop->operation[0]->key.len); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[0]->p2pop->operation[0]->has_newkey); TEST_ASSERT_EQUAL(newKey2.array.data, Request.command->body->p2poperation->operation[0]->p2pop->operation[0]->newkey.data); TEST_ASSERT_EQUAL(newKey2.bytesUsed, Request.command->body->p2poperation->operation[0]->p2pop->operation[0]->newkey.len); TEST_ASSERT_FALSE(Request.command->body->p2poperation->operation[0]->p2pop->operation[0]->has_version); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[0]->p2pop->operation[0]->has_force); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[0]->p2pop->operation[0]->force); TEST_ASSERT_NULL(Request.command->body->p2poperation->operation[0]->status); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[1]->has_key); TEST_ASSERT_EQUAL(oldKey2.array.data, Request.command->body->p2poperation->operation[1]->key.data); TEST_ASSERT_EQUAL(oldKey2.bytesUsed, Request.command->body->p2poperation->operation[1]->key.len); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[1]->has_newkey); TEST_ASSERT_EQUAL(newKey2.array.data, Request.command->body->p2poperation->operation[1]->newkey.data); TEST_ASSERT_EQUAL(newKey2.bytesUsed, Request.command->body->p2poperation->operation[1]->newkey.len); TEST_ASSERT_FALSE(Request.command->body->p2poperation->operation[1]->has_version); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[1]->has_force); TEST_ASSERT_TRUE(Request.command->body->p2poperation->operation[1]->force); TEST_ASSERT_NULL(Request.command->body->p2poperation->operation[1]->p2pop); TEST_ASSERT_NULL(Request.command->body->p2poperation->operation[1]->status); TEST_ASSERT_EQUAL_PTR(&p2pOp, Operation.p2pOp); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); // This just free's the malloc'd memory and sets statuses to "invalid" (since no operation was actually performed) KineticAllocator_FreeP2PProtobuf(Request.command->body->p2poperation); } /******************************************************************************* * Admin Client Operations *******************************************************************************/ void test_KineticBuilder_BuildGetLog_should_build_a_GetLog_request(void) { KineticLogInfo* pInfo; KineticOperation_ValidateOperation_Expect(&Operation); KineticStatus status = KineticBuilder_BuildGetLog(&Operation, KINETIC_DEVICE_INFO_TYPE_STATISTICS, BYTE_ARRAY_NONE, &pInfo); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__GETLOG, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(&Request.message.body, Request.command->body); TEST_ASSERT_EQUAL_PTR(&Request.message.getLog, Request.command->body->getlog); TEST_ASSERT_NOT_NULL(Request.command->body->getlog->types); TEST_ASSERT_EQUAL(1, Request.command->body->getlog->n_types); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__GET_LOG__TYPE__STATISTICS, Request.command->body->getlog->types[0]); TEST_ASSERT_EQUAL_PTR(&pInfo, Operation.deviceInfo); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); } void test_KineticBuilder_BuildGetLog_should_build_a_GetLog_request_to_retrieve_device_specific_log_info(void) { KineticLogInfo* pInfo; const char nameData[] = "com.WD"; ByteArray name = ByteArray_CreateWithCString(nameData); KineticOperation_ValidateOperation_Expect(&Operation); KineticStatus status = KineticBuilder_BuildGetLog(&Operation, COM__SEAGATE__KINETIC__PROTO__COMMAND__GET_LOG__TYPE__DEVICE, name, &pInfo); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__GETLOG, Request.message.command.header->messagetype); TEST_ASSERT_EQUAL_PTR(&Request.message.body, Request.command->body); TEST_ASSERT_EQUAL_PTR(&Request.message.getLog, Request.command->body->getlog); TEST_ASSERT_NOT_NULL(Request.command->body->getlog->types); TEST_ASSERT_EQUAL(1, Request.command->body->getlog->n_types); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__GET_LOG__TYPE__DEVICE, Request.command->body->getlog->types[0]); TEST_ASSERT_EQUAL_PTR(&Request.message.getLogDevice, Request.command->body->getlog->device); TEST_ASSERT_TRUE(Request.command->body->getlog->device->has_name); TEST_ASSERT_EQUAL_PTR(nameData, Request.command->body->getlog->device->name.data); TEST_ASSERT_EQUAL(strlen(nameData), Request.command->body->getlog->device->name.len); TEST_ASSERT_EQUAL_PTR(&pInfo, Operation.deviceInfo); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_NULL(Operation.response); } void test_KineticBuilder_BuildGetLog_should_return_KINETIC_STATUS_DEVICE_NAME_REQUIRED_if_name_not_specified_correctly(void) { KineticLogInfo* pInfo; char nameData[] = "com.WD"; ByteArray name; KineticStatus status; // Length is zero name.data = (uint8_t*)nameData; name.len = 0; KineticOperation_ValidateOperation_Expect(&Operation); status = KineticBuilder_BuildGetLog(&Operation, COM__SEAGATE__KINETIC__PROTO__COMMAND__GET_LOG__TYPE__DEVICE, name, &pInfo); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_DEVICE_NAME_REQUIRED, status); // Data is NULL name.data = NULL; name.len = strlen(nameData); KineticOperation_ValidateOperation_Expect(&Operation); status = KineticBuilder_BuildGetLog(&Operation, COM__SEAGATE__KINETIC__PROTO__COMMAND__GET_LOG__TYPE__DEVICE, name, &pInfo); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_DEVICE_NAME_REQUIRED, status); // Length is zero and data is NULL name.data = NULL; name.len = 0; KineticOperation_ValidateOperation_Expect(&Operation); status = KineticBuilder_BuildGetLog(&Operation, COM__SEAGATE__KINETIC__PROTO__COMMAND__GET_LOG__TYPE__DEVICE, name, &pInfo); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_DEVICE_NAME_REQUIRED, status); }