0
class Protocol::V01::TestAttributes < Net::SFTP::TestCase
0
def test_from_buffer_should_correctly_parse_buffer_and_return_attribute_object
0
- attributes =
Net::SFTP::Protocol::V01::Attributes.from_buffer(full_buffer)
0
+ attributes =
attributes_factory.from_buffer(full_buffer)
0
assert_equal 1234567890, attributes.size
0
assert_equal 100, attributes.uid
0
def test_from_buffer_should_correctly_parse_buffer_with_attribute_subset_and_return_attribute_object
0
buffer = Net::SSH::Buffer.from(:long, 0x4, :long, 0755)
0
- attributes =
Net::SFTP::Protocol::V01::Attributes.from_buffer(buffer)
0
+ attributes =
attributes_factory.from_buffer(buffer)
0
assert_equal 0755, attributes.permissions
0
def test_attributes_to_s_should_build_binary_representation
0
- attributes =
Net::SFTP::Protocol::V01::Attributes.new(
0
+ attributes =
attributes_factory.new(
0
:uid => 100, :gid => 200,
0
def test_attributes_to_s_should_build_binary_representation_when_subset_is_present
0
- attributes =
Net::SFTP::Protocol::V01::Attributes.new(:permissions => 0755)
0
+ attributes =
attributes_factory.new(:permissions => 0755)
0
assert_equal Net::SSH::Buffer.from(:long, 0x4, :long, 0755).to_s, attributes.to_s
0
def test_attributes_to_s_with_owner_and_group_should_translate_to_uid_and_gid
0
- attributes =
Net::SFTP::Protocol::V01::Attributes.new(:owner => "jamis", :group => "sftp")
0
+ attributes =
attributes_factory.new(:owner => "jamis", :group => "sftp")
0
attributes.expects(:require).with("etc").times(2)
0
Etc.expects(:getpwnam).with("jamis").returns(mock('user', :uid => 100))
0
Etc.expects(:getgrnam).with("sftp").returns(mock('group', :gid => 200))
0
def test_owner_should_translate_from_uid
0
- attributes =
Net::SFTP::Protocol::V01::Attributes.new(:uid => 100)
0
+ attributes =
attributes_factory.new(:uid => 100)
0
attributes.expects(:require).with("etc")
0
Etc.expects(:getpwuid).with(100).returns(mock('user', :name => "jamis"))
0
assert_equal "jamis", attributes.owner
0
def test_group_should_translate_from_gid
0
- attributes =
Net::SFTP::Protocol::V01::Attributes.new(:gid => 200)
0
+ attributes =
attributes_factory.new(:gid => 200)
0
attributes.expects(:require).with("etc")
0
Etc.expects(:getgrgid).with(200).returns(mock('group', :name => "sftp"))
0
assert_equal "sftp", attributes.group
0
+ def test_type_should_infer_type_from_permissions
0
+ assert_equal af::T_SOCKET, af.new(:permissions => 0140755).type
0
+ assert_equal af::T_SYMLINK, af.new(:permissions => 0120755).type
0
+ assert_equal af::T_REGULAR, af.new(:permissions => 0100755).type
0
+ assert_equal af::T_BLOCK_DEVICE, af.new(:permissions => 060755).type
0
+ assert_equal af::T_DIRECTORY, af.new(:permissions => 040755).type
0
+ assert_equal af::T_CHAR_DEVICE, af.new(:permissions => 020755).type
0
+ assert_equal af::T_FIFO, af.new(:permissions => 010755).type
0
+ assert_equal af::T_UNKNOWN, af.new(:permissions => 0755).type
0
+ assert_equal af::T_UNKNOWN, af.new.type
0
:long, 0755, :long, 1234567890, :long, 2345678901,
0
:long, 1, :string, "first", :string, "second")
0
+ def attributes_factory
0
+ Net::SFTP::Protocol::V01::Attributes
0
+ alias af attributes_factory
Comments
No one has commented yet.