void test_Flush_should_be_idempotent(void) { KineticStatus status = KineticClient_Flush(Fixture.session, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); status = KineticClient_Flush(Fixture.session, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void setUp(void) { SystemTestSetup(1, false); uint8_t version_data[DEFAULT_SIZE], tag_data[DEFAULT_SIZE]; ByteBuffer version_buffer, tag_buffer; version_buffer = ByteBuffer_CreateAndAppendCString(version_data, sizeof(version_data), "v1.0"); tag_buffer = ByteBuffer_CreateAndAppendCString(tag_data, sizeof(tag_data), "SomeTagValue"); ByteBuffer key_buffers[TOTAL_PUT_KEYS]; ByteBuffer value_buffers[TOTAL_PUT_KEYS]; unsigned int i; for (i=0; i<TOTAL_PUT_KEYS; i++) { key_buffers[i] = generate_entry_key_by_index(i); printf("key: %s", (char *)key_buffers[i].array.data); value_buffers[i] = generate_entry_value_by_index(i); KineticEntry putEntry = { .key = key_buffers[i], .tag = tag_buffer, .newVersion = version_buffer, .algorithm = KINETIC_ALGORITHM_SHA1, .value = value_buffers[i], .force = true, .synchronization = KINETIC_SYNCHRONIZATION_WRITETHROUGH, }; KineticStatus status = KineticClient_Put(Fixture.session, &putEntry, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); ByteBuffer_Free(key_buffers[i]); ByteBuffer_Free(value_buffers[i]); } } void tearDown(void) { SystemTestShutDown(); } void test_media_scan_should_succeed_for_existing_key_range(void) { KineticMediaScan_Operation mediascan_operation = {"my_key 1","my_key 5", true, true}; KineticCommand_Priority priority = PRIORITY_NORMAL; KineticStatus status = KineticAdminClient_MediaScan(Fixture.session, &mediascan_operation, priority); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void test_KineticPDU_Send_should_send_the_PDU_and_return_true_upon_successful_transmission_of_full_PDU_with_value_payload(void) { LOG_LOCATION; ByteBuffer headerNBO = ByteBuffer_Create(&PDU.headerNBO, sizeof(KineticPDUHeader)); KINETIC_PDU_INIT_WITH_MESSAGE(&PDU, &Connection); uint8_t valueData[128]; ByteBuffer valueBuffer = ByteBuffer_Create(valueData, sizeof(valueData)); ByteBuffer_AppendCString(&valueBuffer, "Some arbitrary value"); KineticEntry entry = {.value = valueBuffer}; KineticPDU_AttachEntry(&PDU, &entry); KineticHMAC_Init_Expect(&PDU.hmac, KINETIC_PROTO_SECURITY_ACL_HMACALGORITHM_HmacSHA1); KineticHMAC_Populate_Expect(&PDU.hmac, &PDU.protoData.message.proto, PDU.connection->session.hmacKey); KineticSocket_Write_ExpectAndReturn(Connection.socket, &headerNBO, KINETIC_STATUS_SUCCESS); KineticSocket_WriteProtobuf_ExpectAndReturn(Connection.socket, &PDU, KINETIC_STATUS_SUCCESS); KineticSocket_Write_ExpectAndReturn(Connection.socket, &PDU.entry.value, KINETIC_STATUS_SUCCESS); TEST_IGNORE_MESSAGE("Need to figure out how to handle address of PDU header"); KineticStatus status = KineticPDU_Send(&PDU); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void test_KineticPDU_Send_should_send_the_PDU_and_return_true_upon_successful_transmission_of_full_PDU_with_no_value_payload(void) { LOG_LOCATION; KINETIC_PDU_INIT_WITH_MESSAGE(&PDU, &Connection); ByteBuffer headerNBO = ByteBuffer_Create(&PDU.headerNBO, sizeof(KineticPDUHeader)); KineticEntry entry = {.value = BYTE_BUFFER_NONE}; KineticPDU_AttachEntry(&PDU, &entry); // Create NBO copy of header for sending PDU.headerNBO.versionPrefix = 'F'; PDU.headerNBO.protobufLength = KineticNBO_FromHostU32(KineticProto__get_packed_size(PDU.proto)); PDU.headerNBO.valueLength = 0; KineticHMAC_Init_Expect(&PDU.hmac, KINETIC_PROTO_SECURITY_ACL_HMACALGORITHM_HmacSHA1); KineticHMAC_Populate_Expect(&PDU.hmac, &PDU.protoData.message.proto, PDU.connection->session.hmacKey); KineticSocket_Write_ExpectAndReturn(Connection.socket, &headerNBO, KINETIC_STATUS_SUCCESS); KineticSocket_WriteProtobuf_ExpectAndReturn(Connection.socket, &PDU, KINETIC_STATUS_SUCCESS); TEST_IGNORE_MESSAGE("Need to figure out how to handle address of PDU header"); KineticStatus status = KineticPDU_Send(&PDU); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void test_KineticClient_Get_should_execute_GET_operation(void) { uint8_t KeyData[64]; ByteArray Key = ByteArray_Create(KeyData, sizeof(KeyData)); ByteBuffer KeyBuffer = ByteBuffer_CreateWithArray(Key); uint8_t ValueData[64]; ByteArray Value = ByteArray_Create(ValueData, sizeof(ValueData)); ByteBuffer ValueBuffer = ByteBuffer_CreateWithArray(Value); ByteBuffer_AppendDummyData(&KeyBuffer, Key.len); KineticEntry entry = { .key = KeyBuffer, .value = ValueBuffer, }; KineticOperation operation; KineticAllocator_NewOperation_ExpectAndReturn(&Session, &operation); KineticBuilder_BuildGet_ExpectAndReturn(&operation, &entry, KINETIC_STATUS_SUCCESS); KineticController_ExecuteOperation_ExpectAndReturn(&operation, NULL, KINETIC_STATUS_CLUSTER_MISMATCH); KineticStatus status = KineticClient_Get(&Session, &entry, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_CLUSTER_MISMATCH, status); }
void test_KineticClient_Delete_should_execute_DELETE_operation(void) { ByteArray key = ByteArray_CreateWithCString("some_key"); ByteArray tag = ByteArray_CreateWithCString("SomeTagValue"); KineticEntry entry = { .key = ByteBuffer_CreateWithArray(key), .tag = ByteBuffer_CreateWithArray(tag), }; KineticConnection_FromHandle_ExpectAndReturn(DummyHandle, &Connection); KineticAllocator_NewPDU_ExpectAndReturn(&Connection.pdus, &Request); KineticAllocator_NewPDU_ExpectAndReturn(&Connection.pdus, &Response); KineticPDU_Init_Expect(&Request, &Connection); KineticPDU_Init_Expect(&Response, &Connection); KineticConnection_IncrementSequence_Expect(&Connection); KineticMessage_ConfigureKeyValue_Expect(&Request.protoData.message, &entry); KineticPDU_Send_ExpectAndReturn(&Request, KINETIC_STATUS_SUCCESS); KineticPDU_Receive_ExpectAndReturn(&Response, KINETIC_STATUS_SUCCESS); KineticPDU_GetStatus_ExpectAndReturn(&Response, KINETIC_STATUS_SUCCESS); KineticAllocator_FreePDU_Expect(&Connection.pdus, &Request); KineticAllocator_FreePDU_Expect(&Connection.pdus, &Response); KineticStatus status = KineticClient_Delete(DummyHandle, &entry); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void setUp(void) { memset(&Session, 0, sizeof(Session)); Session.config = (KineticSessionConfig) { .host = "somehost.com", .port = 17, .clusterVersion = 6, }; Client.bus = &MessageBus; KineticCountingSemaphore_Create_ExpectAndReturn(KINETIC_MAX_OUTSTANDING_OPERATIONS_PER_SESSION, &Semaphore); KineticStatus status = KineticSession_Create(&Session, &Client); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); TEST_ASSERT_FALSE(Session.connected); TEST_ASSERT_EQUAL_STRING(Session.config.host, "somehost.com"); TEST_ASSERT_EQUAL(17, Session.config.port); KineticRequest_Init(&Request, &Session); OperationCompleteCallbackCount = 0; LastStatus = KINETIC_STATUS_INVALID; } void tearDown(void) { KineticLogger_Close(); } void test_KineticSession_Create_should_return_KINETIC_STATUS_SESSION_EMPTY_upon_NULL_session(void) { TEST_ASSERT_EQUAL(KINETIC_STATUS_SESSION_EMPTY, KineticSession_Create(NULL, NULL)); }
void test_Flush_should_call_callback_after_completion(void) { completion_test_env env; memset(&env, 0, sizeof(env)); TEST_ASSERT_EQUAL(0, pthread_cond_init(&env.cond, NULL)); TEST_ASSERT_EQUAL(0, pthread_mutex_init(&env.mutex, NULL)); KineticCompletionClosure closure = { .callback = completion_cb, .clientData = (void *)&env }; KineticStatus status = KineticClient_Flush(Fixture.session, &closure); /* Wait up to 10 seconds for the callback to fire. */ struct timeval tv; gettimeofday(&tv, NULL); struct timespec ts = {ts.tv_sec = tv.tv_sec + 10}; int res = pthread_cond_timedwait(&env.cond, &env.mutex, &ts); TEST_ASSERT_EQUAL(0, res); TEST_ASSERT_TRUE(env.flag); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); TEST_ASSERT_EQUAL(0, pthread_cond_destroy(&env.cond)); } static void no_op_callback(KineticCompletionData* kinetic_data, void* client_data) { (void)kinetic_data; (void)client_data; }
void test_KineticClient_GetKeyRange_should_return_a_list_of_keys_within_the_specified_range(void) { ByteBuffer_AppendCString(&StartKey, "key_range_00_00"); ByteBuffer_AppendCString(&EndKey, "key_range_00_03"); KineticKeyRange keyRange = { .startKey = StartKey, .endKey = EndKey, .startKeyInclusive = true, .endKeyInclusive = true, .maxReturned = MAX_KEYS_RETRIEVED, .reverse = false, }; ByteBufferArray keyArray = { .buffers = &Keys[0], .count = MAX_KEYS_RETRIEVED }; KineticOperation operation; KineticAllocator_NewOperation_ExpectAndReturn(&Session, &operation); KineticBuilder_BuildGetKeyRange_ExpectAndReturn(&operation, &keyRange, &keyArray, KINETIC_STATUS_SUCCESS); KineticController_ExecuteOperation_ExpectAndReturn(&operation, NULL, KINETIC_STATUS_BUFFER_OVERRUN); KineticStatus status = KineticClient_GetKeyRange(&Session, &keyRange, &keyArray, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_BUFFER_OVERRUN, status); }
void tearDown(void) { if (ClusterVersionSet) { KineticStatus status = KineticAdminClient_SetClusterVersion(Fixture.adminSession, 0); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); } SystemTestShutDown(); }
void test_media_optimize_should_succeed_for_existing_key_range(void) { KineticMediaOptimize_Operation mediaoptimize_operation = {"my_key 6","my_key 9", true, true}; KineticCommand_Priority priority = PRIORITY_NORMAL; KineticStatus status = KineticAdminClient_MediaOptimize(Fixture.session, &mediaoptimize_operation, priority); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void test_KineticClient_Connect_should_return_KINETIC_STATUS_SESSION_EMPTY_upon_NULL_session_config(void) { SessionHandle = 17; KineticStatus status = KineticClient_Connect(NULL, &SessionHandle); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SESSION_EMPTY, status); TEST_ASSERT_EQUAL(KINETIC_HANDLE_INVALID, SessionHandle); }
void test_KineticAdminClient_GetLog_should_return_INVALID_LOG_TYPE_if_out_of_range(void) { KineticLogInfo* info; KineticStatus status = KineticAdminClient_GetLog(&Session, (KineticLogInfo_Type)1000, &info, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_INVALID_LOG_TYPE, status); }
void test_KineticClient_GetPrevious_should_get_error_MISSING_KEY_if_called_without_key(void) { KineticEntry entry; memset(&entry, 0, sizeof(entry)); KineticStatus status = KineticClient_GetPrevious(&Session, &entry, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_MISSING_KEY, status); }
void test_KineticClient_flush_should_expose_memory_error_from_CreateOperation(void) { KineticSession session; KineticAllocator_NewOperation_ExpectAndReturn(&session, NULL); KineticStatus status = KineticClient_Flush(&session, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_MEMORY_ERROR, status); }
void test_KineticSession_Connect_should_connect_to_specified_host(void) { const uint8_t hmacKey[] = {1, 6, 3, 5, 4, 8, 19}; KineticSession expected = { .config = (KineticSessionConfig) { .host = "valid-host.com", .port = 1234, .clusterVersion = 17, .identity = 12, .hmacKey = { .data = expected.config.keyData, .len = sizeof(hmacKey)}, }, .connected = true, .socket = 24, }; memcpy(expected.config.hmacKey.data, hmacKey, expected.config.hmacKey.len); KineticSession session = { .config = (KineticSessionConfig) { .host = "valid-host.com", .port = expected.config.port, .clusterVersion = expected.config.clusterVersion, .identity = expected.config.identity, .hmacKey = { .data = Session.config.keyData, .len = sizeof(hmacKey)}, }, .connected = true, .socket = 24, }; memcpy(session.config.hmacKey.data, hmacKey, expected.config.hmacKey.len); KineticSocket_Connect_ExpectAndReturn(expected.config.host, expected.config.port, expected.socket); Bus_RegisterSocket_ExpectAndReturn(NULL, BUS_SOCKET_PLAIN, expected.socket, &session, true); KineticResourceWaiter_WaitTilAvailable_ExpectAndReturn(&session.connectionReady, KINETIC_CONNECTION_TIMEOUT_SECS, true); // Establish connection KineticStatus status = KineticSession_Connect(&session); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); TEST_ASSERT_TRUE(session.connected); TEST_ASSERT_EQUAL(expected.socket, session.socket); TEST_ASSERT_EQUAL_STRING(expected.config.host, session.config.host); TEST_ASSERT_EQUAL(expected.config.port, session.config.port); TEST_ASSERT_EQUAL_INT64(expected.config.clusterVersion, session.config.clusterVersion); TEST_ASSERT_EQUAL_INT64(expected.config.identity, session.config.identity); TEST_ASSERT_EQUAL_ByteArray(expected.config.hmacKey, session.config.hmacKey); }
void test_KineticPDU_Receive_should_receive_a_message_with_no_value_payload_and_forward_status_upon_receipt_of_valid_PDU_with_non_successful_status(void) { LOG_LOCATION; KINETIC_PDU_INIT_WITH_MESSAGE(&PDU, &Connection); PDU.protoData.message.status.code = KINETIC_PROTO_STATUS_STATUS_CODE_PERM_DATA_ERROR; PDU.protoData.message.status.has_code = true; ByteBuffer headerNBO = ByteBuffer_Create(&PDU.headerNBO, sizeof(KineticPDUHeader)); // Fake value/payload length uint8_t data[1024]; ByteArray expectedValue = {.data = data, .len = sizeof(data)}; ByteArray_FillWithDummyData(expectedValue); KineticEntry entry = {.value = ByteBuffer_CreateWithArray(expectedValue)}; KineticPDU_AttachEntry(&PDU, &entry); PDU.headerNBO.valueLength = KineticNBO_FromHostU32(0); KineticSocket_Read_ExpectAndReturn(Connection.socket, &headerNBO, sizeof(KineticPDUHeader), KINETIC_STATUS_SUCCESS); KineticSocket_ReadProtobuf_ExpectAndReturn(Connection.socket, &PDU, KINETIC_STATUS_SUCCESS); KineticHMAC_Validate_ExpectAndReturn(PDU.proto, PDU.connection->session.hmacKey, true); EnableAndSetPDUStatus(&PDU, KINETIC_PROTO_STATUS_STATUS_CODE_PERM_DATA_ERROR); KineticStatus status = KineticPDU_Receive(&PDU); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_DATA_ERROR, status); TEST_ASSERT_EQUAL( KINETIC_PROTO_STATUS_STATUS_CODE_PERM_DATA_ERROR, PDU.protoData.message.status.code); } void test_KineticPDU_Receive_should_receive_a_message_for_the_exchange_and_return_false_upon_failure_to_read_header(void) { LOG_LOCATION; KINETIC_PDU_INIT_WITH_MESSAGE(&PDU, &Connection); ByteBuffer headerNBO = ByteBuffer_Create(&PDU.headerNBO, sizeof(KineticPDUHeader)); KineticSocket_Read_ExpectAndReturn(Connection.socket, &headerNBO, sizeof(KineticPDUHeader), KINETIC_STATUS_CONNECTION_ERROR); KineticStatus status = KineticPDU_Receive(&PDU); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_CONNECTION_ERROR, status); }
void SystemTestSetup(int log_level, bool secure_erase) { const uint8_t *key = (const uint8_t *)SESSION_HMAC_KEY; SystemTestSetupWithIdentity(log_level, SESSION_IDENTITY, key, strlen((const char*)key)); if (secure_erase) { InitPin = ByteArray_Create(InitPinData, 0); KineticStatus status = KineticAdminClient_SecureErase(Fixture.adminSession, InitPin); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); } }
void test_KineticClient_Get_should_get_error_MISSING_VALUE_BUFFER_if_called_without_value_buffer(void) { uint8_t KeyData[64]; ByteArray Key = ByteArray_Create(KeyData, sizeof(KeyData)); ByteBuffer KeyBuffer = ByteBuffer_CreateWithArray(Key); KineticEntry entry = { .key = KeyBuffer }; memset(&entry, 0, sizeof(entry)); KineticStatus status = KineticClient_Get(&Session, &entry, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_MISSING_KEY, status); }
void test_KineticClient_flush_should_get_success_if_no_writes_are_in_progress(void) { KineticOperation operation; KineticSession session; KineticAllocator_NewOperation_ExpectAndReturn(&session, &operation); KineticBuilder_BuildFlush_ExpectAndReturn(&operation, KINETIC_STATUS_SUCCESS); KineticController_ExecuteOperation_ExpectAndReturn(&operation, NULL, KINETIC_STATUS_SUCCESS); KineticStatus status = KineticClient_Flush(&session, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void test_KineticSession_Create_should_allocate_and_destroy_KineticConnections(void) { KineticSession session; memset(&session, 0, sizeof(session)); KineticCountingSemaphore_Create_ExpectAndReturn(KINETIC_MAX_OUTSTANDING_OPERATIONS_PER_SESSION, &Semaphore); KineticStatus status = KineticSession_Create(&session, &Client); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); TEST_ASSERT_FALSE(session.connected); TEST_ASSERT_EQUAL(-1, session.socket); TEST_ASSERT_EQUAL_INT64(0, session.sequence); TEST_ASSERT_EQUAL_INT64(0, session.connectionID); KineticCountingSemaphore_Destroy_Expect(&Semaphore); KineticAllocator_FreeSession_Expect(&session); status = KineticSession_Destroy(&session); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void test_KineticClient_Get_should_get_error_MISSING_KEY_if_called_without_key(void) { uint8_t ValueData[64]; ByteArray Value = ByteArray_Create(ValueData, sizeof(ValueData)); ByteBuffer ValueBuffer = ByteBuffer_CreateWithArray(Value); KineticEntry entry = {.value = ValueBuffer}; memset(&entry, 0, sizeof(entry)); KineticStatus status = KineticClient_Get(&Session, &entry, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_MISSING_KEY, status); }
void test_KineticAdminClient_GetLog_should_request_the_specified_log_data_from_the_device(void) { KineticLogInfo* info; KineticOperation operation; KineticAllocator_NewOperation_ExpectAndReturn(&Session, &operation); KineticBuilder_BuildGetLog_ExpectAndReturn(&operation, KINETIC_DEVICE_INFO_TYPE_UTILIZATIONS, BYTE_ARRAY_NONE, &info, KINETIC_STATUS_SUCCESS); KineticController_ExecuteOperation_ExpectAndReturn(&operation, NULL, KINETIC_STATUS_SUCCESS); KineticStatus status = KineticAdminClient_GetLog(&Session, KINETIC_DEVICE_INFO_TYPE_UTILIZATIONS, &info, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void test_KineticClient_P2POperation_should_execute_a_p2p_operation(void) { KineticSession session; KineticOperation operation; KineticP2P_Operation p2pOp; KineticAllocator_NewOperation_ExpectAndReturn(&session, &operation); KineticBuilder_BuildP2POperation_ExpectAndReturn(&operation, &p2pOp, KINETIC_STATUS_SUCCESS); KineticController_ExecuteOperation_ExpectAndReturn(&operation, NULL, KINETIC_STATUS_SUCCESS); KineticStatus status = KineticClient_P2POperation(&session, &p2pOp, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void setUp(void) { KINETIC_CONNECTION_INIT(&Connection); Connection.connected = false; // Ensure gets set appropriately by internal connect call HmacKey = ByteArray_CreateWithCString("some hmac key"); KINETIC_SESSION_INIT(&Session, "somehost.com", ClusterVersion, Identity, HmacKey); KineticConnection_NewConnection_ExpectAndReturn(&Session, DummyHandle); KineticConnection_FromHandle_ExpectAndReturn(DummyHandle, &Connection); KineticConnection_Connect_ExpectAndReturn(&Connection, KINETIC_STATUS_SUCCESS); KineticStatus status = KineticClient_Connect(&Session, &SessionHandle); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); TEST_ASSERT_EQUAL(DummyHandle, SessionHandle); }
void test_KineticClient_Put_should_execute_PUT_operation(void) { ByteArray value = ByteArray_CreateWithCString("Four score, and seven years ago"); KineticEntry entry = {.value = ByteBuffer_CreateWithArray(value)}; KineticOperation operation; operation.session = &Session; KineticAllocator_NewOperation_ExpectAndReturn(&Session, &operation); KineticBuilder_BuildPut_ExpectAndReturn(&operation, &entry, KINETIC_STATUS_SUCCESS); KineticController_ExecuteOperation_ExpectAndReturn(&operation, NULL, KINETIC_STATUS_VERSION_MISMATCH); KineticStatus status = KineticClient_Put(&Session, &entry, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_VERSION_MISMATCH, status); }
void test_KineticAdminClient_CreateSession_should_delegate_to_base_client(void) { KineticClient client; KineticSessionConfig config = { .port = 8765 }; KineticSession* session = &Session; KineticClient_CreateSession_ExpectAndReturn(&config, &client, &session, KINETIC_STATUS_CLUSTER_MISMATCH); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_CLUSTER_MISMATCH, KineticAdminClient_CreateSession(&config, &client, &session)); } void test_KineticAdminClient_DestroySession_should_delegate_to_base_client(void) { KineticSession session = { .config = (KineticSessionConfig) {.port = 4321}, }; KineticClient_DestroySession_ExpectAndReturn(&session, KINETIC_STATUS_SUCCESS); KineticStatus status = KineticAdminClient_DestroySession(&session); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void test_KineticAdminClient_GetDeviceSpecificLog_should_request_the_specified_device_specific_log_data_from_the_device(void) { const char* nameData = "com.Seagate"; ByteArray name = ByteArray_CreateWithCString(nameData); KineticLogInfo* info; KineticOperation operation; KineticAllocator_NewOperation_ExpectAndReturn(&Session, &operation); KineticBuilder_BuildGetLog_ExpectAndReturn(&operation, COM__SEAGATE__KINETIC__PROTO__COMMAND__GET_LOG__TYPE__DEVICE, name, &info, KINETIC_STATUS_SUCCESS); KineticController_ExecuteOperation_ExpectAndReturn(&operation, NULL, KINETIC_STATUS_SUCCESS); KineticStatus status = KineticAdminClient_GetDeviceSpecificLog(&Session, name, &info, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); }
void test_KineticClient_GetPrevious_should_expose_memory_errors(void) { uint8_t key[] = "schlage"; ByteBuffer KeyBuffer = ByteBuffer_Create(key, sizeof(key), sizeof(key)); uint8_t value[1024]; ByteBuffer ValueBuffer = ByteBuffer_Create(value, sizeof(value), 0); KineticEntry entry = { .key = KeyBuffer, .value = ValueBuffer, }; KineticAllocator_NewOperation_ExpectAndReturn(&Session, NULL); KineticStatus status = KineticClient_GetPrevious(&Session, &entry, NULL); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_MEMORY_ERROR, status); }
static void ConnectSession(void) { KINETIC_CONNECTION_INIT(&Connection); Connection.connected = false; // Ensure gets set appropriately by internal connect call Connection.connectionID = 12374626536; // Fake connection ID to allow connection to complete for these tests HmacKey = ByteArray_CreateWithCString("some hmac key"); KINETIC_SESSION_INIT(&Session, "somehost.com", ClusterVersion, Identity, HmacKey); KineticConnection_NewConnection_ExpectAndReturn(&Session, DummyHandle); KineticConnection_FromHandle_ExpectAndReturn(DummyHandle, &Connection); KineticConnection_Connect_ExpectAndReturn(&Connection, KINETIC_STATUS_SUCCESS); // KineticConnection_ReceiveDeviceStatusMessage_ExpectAndReturn(&Connection, KINETIC_STATUS_SUCCESS); KineticStatus status = KineticClient_Connect(&Session, &SessionHandle); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); TEST_ASSERT_EQUAL(DummyHandle, SessionHandle); }