def test_check_header_with_flags_nodata_size(_mocked_exists, mocked_data_file, _mocked_index, flags):
    """Tested valid headers with different flags combination.

    :param eblob_kit.RecordFlags flags: bit flags to be used with eblob_kit.DiskControl

    """
    # DataFile mock
    mocked_data_file.return_value.__len__.return_value = 512

    header = make_header(flags=RecordFlags(flags), disk_size=128)

    blob_repairer = BlobRepairer(TEST_BLOB_PATH)
    assert blob_repairer.check_header(header)
Beispiel #2
0
def test_check_header_with_flags_nodata_size(_mocked_exists, mocked_data_file,
                                             _mocked_index, flags):
    """Tested valid headers with different flags combination.

    :param eblob_kit.RecordFlags flags: bit flags to be used with eblob_kit.DiskControl

    """
    # DataFile mock
    mocked_data_file.return_value.__len__.return_value = 512

    header = make_header(flags=RecordFlags(flags), disk_size=128)

    blob_repairer = BlobRepairer(TEST_BLOB_PATH)
    assert blob_repairer.check_header(header)
Beispiel #3
0
def test_check_header_without_flags(_mocked_index, mocked_data_file,
                                    mocked_exist, header, data_len,
                                    check_result):
    """Check generated header whith BlobRepairer.check_header.

    Constructs various headers and check them for validity.

    :param eblob_kit.DiskControl header: header stub.

    """
    # DataFile mock
    mocked_data_file.return_value.__len__.return_value = data_len

    # Blob mock
    blob_repairer = BlobRepairer(TEST_BLOB_PATH)

    assert blob_repairer.check_header(header) == check_result
Beispiel #4
0
def test_check_header_with_exthdr_and_datasize(_mocked_exists,
                                               mocked_data_file, _index_file,
                                               data_size, disk_size, expect):
    """Check header with EXTHDR and incorrect data_size.

    Checks for:

      header.data_size + EllipticsHeader.size(48) + checksum_size(64) > header.disk_size

    """
    header = make_header(data_size=data_size,
                         disk_size=disk_size,
                         flags=RecordFlags(RecordFlags.EXTHDR))

    # Return big enough constant to suppress preliminary checks in BlobRepairer.check_header.
    mocked_data_file.return_value.__len__.return_value = 512

    blob_repairer = BlobRepairer(TEST_BLOB_PATH)
    assert blob_repairer.check_header(header) == expect
def test_check_header_without_flags(_mocked_index,
                                    mocked_data_file,
                                    mocked_exist,
                                    header,
                                    data_len,
                                    check_result):
    """Check generated header whith BlobRepairer.check_header.

    Constructs various headers and check them for validity.

    :param eblob_kit.DiskControl header: header stub.

    """
    # DataFile mock
    mocked_data_file.return_value.__len__.return_value = data_len

    # Blob mock
    blob_repairer = BlobRepairer(TEST_BLOB_PATH)

    assert blob_repairer.check_header(header) == check_result
def test_check_header_with_exthdr_and_datasize(_mocked_exists,
                                               mocked_data_file,
                                               _index_file,
                                               data_size,
                                               disk_size,
                                               expect):
    """Check header with EXTHDR and incorrect data_size.

    Checks for:

      header.data_size + EllipticsHeader.size(48) + checksum_size(64) > header.disk_size

    """
    header = make_header(data_size=data_size, disk_size=disk_size, flags=RecordFlags(RecordFlags.EXTHDR))

    # Return big enough constant to suppress preliminary checks in BlobRepairer.check_header.
    mocked_data_file.return_value.__len__.return_value = 512

    blob_repairer = BlobRepairer(TEST_BLOB_PATH)
    assert blob_repairer.check_header(header) == expect