Sha256: 682e93439a055530fe7d44376dda52f8c224afab41294e81eb53a075b32800c5

Contents?: true

Size: 1.44 KB

Versions: 28

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

RSpec.describe RubySMB::Fscc::FileInformation::FileNormalizedNameInformation do
  it 'references the correct class level' do
    expect(described_class).to be_const_defined(:CLASS_LEVEL)
    expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_NORMALIZED_NAME_INFORMATION
  end

  subject(:struct) { described_class.new }

  it { should respond_to :file_name_length }
  it { should respond_to :file_name }

  it 'is little endian' do
    expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
  end

  it 'tracks the file name length in a Uint32 field' do
    expect(struct.file_name_length).to be_a BinData::Uint32le
  end

  it 'tracks the file name in a String16 field' do
    expect(struct.file_name).to be_a RubySMB::Field::String16
  end

  describe '#file_name' do
    it 'automatically encodes the file name in UTF-16LE' do
      name = 'Hello_world.txt'
      struct.file_name = name
      expect(struct.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
    end

    describe 'reading in from a blob' do
      it 'uses the file_name_length to know when to stop reading' do
        name = 'Hello_world.txt'
        struct.file_name = name
        blob = struct.to_binary_s
        blob << 'AAAA'
        new_from_blob = described_class.read(blob)
        expect(new_from_blob.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ruby_smb-3.3.13 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.12 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.11 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.10 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.9 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.7 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.6 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.5 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.4 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.3 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.2 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.1 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.3.0 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.2.8 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.2.7 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.2.6 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.2.5 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.2.4 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.2.3 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb
ruby_smb-3.2.2 spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb