コード例 #1
0
    def test_instruction_invalid_arg_separator(self):
        """
        Instruction with invalid arg separator.
        """
        instruction_str = '3.args8.hostname,4.port;'

        with self.assertRaises(InvalidInstruction):
            Instruction.load(instruction_str)
コード例 #2
0
ファイル: test.py プロジェクト: mohabusama/pyguacamole
    def test_instruction_invalid_arg_separator(self):
        """
        Instruction with invalid arg separator.
        """
        instruction_str = '3.args8.hostname,4.port;'

        with self.assertRaises(InvalidInstruction):
            Instruction.load(instruction_str)
コード例 #3
0
ファイル: test.py プロジェクト: mohabusama/pyguacamole
    def test_instruction_invalid_element_separator(self):
        """
        Instruction with invalid element separator.
        """
        instruction_str = '3args,8.hostname,4.port;'

        with self.assertRaises(InvalidInstruction):
            Instruction.load(instruction_str)
コード例 #4
0
ファイル: test.py プロジェクト: mohabusama/pyguacamole
    def test_instruction_invalid_termination(self):
        """
        Instruction with invalid terminator.
        """
        instruction_str = '4.args,8.hostname,4.port'

        with self.assertRaises(InvalidInstruction):
            Instruction.load(instruction_str)
コード例 #5
0
ファイル: test.py プロジェクト: mohabusama/pyguacamole
    def test_instruction_invalid_arg_length_large(self):
        """
        Instruction with invalid large arg length.
        """
        instruction_str = '1000.args,8.hostname,4.port;'

        with self.assertRaises(InvalidInstruction):
            Instruction.load(instruction_str)
コード例 #6
0
    def test_instruction_invalid_element_separator(self):
        """
        Instruction with invalid element separator.
        """
        instruction_str = '3args,8.hostname,4.port;'

        with self.assertRaises(InvalidInstruction):
            Instruction.load(instruction_str)
コード例 #7
0
    def test_instruction_invalid_arg_length_large(self):
        """
        Instruction with invalid large arg length.
        """
        instruction_str = '1000.args,8.hostname,4.port;'

        with self.assertRaises(InvalidInstruction):
            Instruction.load(instruction_str)
コード例 #8
0
    def test_instruction_invalid_termination(self):
        """
        Instruction with invalid terminator.
        """
        instruction_str = '4.args,8.hostname,4.port'

        with self.assertRaises(InvalidInstruction):
            Instruction.load(instruction_str)
コード例 #9
0
ファイル: test.py プロジェクト: mohabusama/pyguacamole
    def test_instruction_valid_encode(self):
        """
        Test valid instruction encoding.
        """
        instruction_str = '4.args,8.hostname,4.port,4.1984;'
        instruction_opcode = 'args'
        instruction_args = ('hostname', 'port', 1984)

        instruction = Instruction('args', 'hostname', 'port', 1984)

        self.assertEqual(instruction_str, instruction.encode())
        self.assertEqual(instruction_opcode, instruction.opcode)
        self.assertEqual(instruction_args, instruction.args)
コード例 #10
0
    def test_instruction_valid_encode(self):
        """
        Test valid instruction encoding.
        """
        instruction_str = '4.args,8.hostname,4.port,4.1984;'
        instruction_opcode = 'args'
        instruction_args = ('hostname', 'port', 1984)

        instruction = Instruction('args', 'hostname', 'port', 1984)

        self.assertEqual(instruction_str, instruction.encode())
        self.assertEqual(instruction_opcode, instruction.opcode)
        self.assertEqual(instruction_args, instruction.args)
コード例 #11
0
ファイル: test.py プロジェクト: mohabusama/pyguacamole
    def test_instruction_valid_encode_with_protocol_chars(self):
        """
        Test valid instruction encoding with arg containing
        protocol characters.
        """
        # arg includes ARG_SEP, ELEM_SEP, INST_TERM and a white space.
        arg_protocol_chars = 'p,.; t'
        instruction_str = '4.args,8.hostname,%s.%s;' %\
            (len(arg_protocol_chars), arg_protocol_chars)

        instruction_opcode = 'args'
        instruction_args = ('hostname', arg_protocol_chars)

        instruction = Instruction('args', 'hostname', arg_protocol_chars)

        self.assertEqual(instruction_str, instruction.encode())
        self.assertEqual(instruction_opcode, instruction.opcode)
        self.assertEqual(instruction_args, instruction.args)
コード例 #12
0
ファイル: consumers.py プロジェクト: bab3l/guacozy
 async def accept_and_send_error(self, error_text, error_code):
     """
     Handle errors during connect with a reason and code
     In order for client side guacamole client to receive error code/text
     we need to accept connection and immediately send error instruction
     """
     await self.accept(subprotocol='guacamole')
     await self.send(text_data=GuacamoleInstruction("error", error_text,
                                                    error_code).encode())
コード例 #13
0
    def test_instruction_valid_encode_with_protocol_chars(self):
        """
        Test valid instruction encoding with arg containing
        protocol characters.
        """
        # arg includes ARG_SEP, ELEM_SEP, INST_TERM and a white space.
        arg_protocol_chars = 'p,.; t'
        instruction_str = '4.args,8.hostname,%s.%s;' %\
            (len(arg_protocol_chars), arg_protocol_chars)

        instruction_opcode = 'args'
        instruction_args = ('hostname', arg_protocol_chars)

        instruction = Instruction('args', 'hostname', arg_protocol_chars)

        self.assertEqual(instruction_str, instruction.encode())
        self.assertEqual(instruction_opcode, instruction.opcode)
        self.assertEqual(instruction_args, instruction.args)
コード例 #14
0
ファイル: test.py プロジェクト: mohabusama/pyguacamole
    def test_instruction_valid_encode_unicode(self):
        """
        Test valid instruction encoding with unicode characters.
        """
        # instruction str for validation!
        instruction_str = '4.args,8.hostname,%s.%s;' %\
            (self.u_arg_len, self.u_arg_utf8)

        instruction_opcode = 'args'
        instruction_args = ('hostname', self.u_arg)

        # passing a unicode arg!
        instruction = Instruction('args', 'hostname', self.u_arg)

        self.assertEqual(instruction_opcode, instruction.opcode)
        self.assertEqual(instruction_args, instruction.args)

        # all args should be utf_8 after instruction.encode()
        self.assertEqual(instruction_str, instruction.encode())
コード例 #15
0
    def test_instruction_valid_encode_unicode(self):
        """
        Test valid instruction encoding with unicode characters.
        """
        # instruction str for validation!
        instruction_str = '4.args,8.hostname,%s.%s;' %\
            (self.u_arg_len, self.u_arg_utf8)

        instruction_opcode = 'args'
        instruction_args = ('hostname', self.u_arg)

        # passing a unicode arg!
        instruction = Instruction('args', 'hostname', self.u_arg)

        self.assertEqual(instruction_opcode, instruction.opcode)
        self.assertEqual(instruction_args, instruction.args)

        # all args should be utf_8 after instruction.encode()
        self.assertEqual(instruction_str, instruction.encode())
コード例 #16
0
ファイル: test.py プロジェクト: mohabusama/pyguacamole
    def test_instruction_valid_decode_unicode(self):
        """
        Test valid instruction decoding with unicode characters.
        """
        # messing up by passing unicode instruction (with valid arg length!)
        instruction_str_u = u'4.args,8.hostname,%s.%s;' %\
            (self.u_arg_len, self.u_arg)

        # instruction str for validation!
        instruction_str = '4.args,8.hostname,%s.%s;' %\
            (self.u_arg_len, self.u_arg_utf8)

        instruction_opcode = 'args'
        instruction_args = ('hostname', self.u_arg_utf8)

        # Instruction.load should handle unicode string!
        instruction = Instruction.load(instruction_str_u)

        self.assertEqual(instruction_str, instruction.encode())
        self.assertEqual(instruction_opcode, instruction.opcode)
        self.assertEqual(instruction_args, instruction.args)
コード例 #17
0
    def test_instruction_valid_decode_unicode(self):
        """
        Test valid instruction decoding with unicode characters.
        """
        # messing up by passing unicode instruction (with valid arg length!)
        instruction_str_u = u'4.args,8.hostname,%s.%s;' %\
            (self.u_arg_len, self.u_arg)

        # instruction str for validation!
        instruction_str = '4.args,8.hostname,%s.%s;' %\
            (self.u_arg_len, self.u_arg_utf8)

        instruction_opcode = 'args'
        instruction_args = ('hostname', self.u_arg_utf8)

        # Instruction.load should handle unicode string!
        instruction = Instruction.load(instruction_str_u)

        self.assertEqual(instruction_str, instruction.encode())
        self.assertEqual(instruction_opcode, instruction.opcode)
        self.assertEqual(instruction_args, instruction.args)
コード例 #18
0
ファイル: client.py プロジェクト: zhengge2017/pyguacamole
 def read_instruction(self):
     """
     Read and decode instruction.
     """
     self.logger.debug('Reading instruction.')
     return Instruction.load(self.receive())
コード例 #19
0
ファイル: client.py プロジェクト: mohabusama/pyguacamole
 def read_instruction(self):
     """
     Read and decode instruction.
     """
     self.logger.debug('Reading instruction.')
     return Instruction.load(self.receive())