Home | Trees | Indices | Help |
---|
|
1 # 2 # Copyright (c) 2013, EMC Corporation 3 # All rights reserved. 4 # 5 # Redistribution and use in source and binary forms, with or without 6 # modification, are permitted provided that the following conditions are met: 7 # 8 # 1. Redistributions of source code must retain the above copyright notice, 9 # this list of conditions and the following disclaimer. 10 # 2. Redistributions in binary form must reproduce the above copyright notice, 11 # this list of conditions and the following disclaimer in the documentation 12 # and/or other materials provided with the distribution. 13 # 14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 # POSSIBILITY OF SUCH DAMAGE. 25 # 26 # Module Name: 27 # 28 # query.py 29 # 30 # Abstract: 31 # 32 # SMB2_QUERY_INFO command tests with SMB2_0_INFO_FILE type. 33 # 34 # Authors: Rafal Szczesniak (rafal.szczesniak@isilon.com) 35 # 36 37 import pike.model 38 import pike.smb2 39 import pike.test 40 import pike.ntstatus 41 42 from pike.test import unittest 434913751 """Helper to open basic file""" 52 self.chan, self.tree = self.tree_connect() 53 return self.chan.create(self.tree, "test.txt", disposition=pike.smb2.FILE_SUPERSEDE).result()5456 """Helper to perform a basic query test""" 57 handle = self.open_file() 58 info = self.chan.query_file_info(handle, level) 59 self.chan.close(handle)6062 """Helper to perform a test size mismatch""" 63 handle = self.open_file() 64 65 with self.assert_error(pike.ntstatus.STATUS_INFO_LENGTH_MISMATCH): 66 self.chan.query_file_info(handle, level, output_buffer_length = size) 67 self.chan.close(handle)68 69 # The following tests simply try each info level 72 75 78 81 84 87 90 93 94 97 100 103 106 109 112 115 118 119 # Querying a security descriptor with output buffer size 0 should 120 # return STATUS_BUFFER_TOO_SMALL and tell us how many bytes are needed122 handle = self.open_file() 123 smb2_req = self.chan.request(obj=handle) 124 query_req = pike.smb2.QueryInfoRequest(smb2_req) 125 query_req.info_type = pike.smb2.SMB2_0_INFO_SECURITY 126 query_req.additional_information = pike.smb2.OWNER_SECURITY_INFORMATION | pike.smb2.DACL_SECURITY_INFORMATION 127 query_req.output_buffer_length = 0 128 query_req.file_id = handle.file_id 129 130 with self.assert_error(pike.ntstatus.STATUS_BUFFER_TOO_SMALL) as cm: 131 self.chan.connection.transceive(smb2_req.parent) 132 133 err = cm.response[0] 134 135 self.assertEqual(err[0].data_length, 4) 136 self.assertTrue(err[0].minimum_buffer_length > 0)
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Jun 29 08:51:26 2017 | http://epydoc.sourceforge.net |