Esempio n. 1
0
    def test_message_received(self, mockmr):
        procmock = Mock()
        procmock.push_context = MagicMock()


        ep = ProcessRPCResponseEndpointUnit(process=procmock, interceptors={})
        ep._routing_obj = procmock

        msg_dict = {'iam':'adict'}
        header_dict =   {'op':'anyop'}
        ep.message_received(msg_dict, header_dict)

        ep._routing_obj.anyop.assert_called_once_with(iam='adict')

        def deny_anyop(self, operation, id=None):
            raise Unauthorized('The anyop operation has been denied')

        msg_dict2 = {'iam':'adict2'}
        ep._routing_obj._service_op_preconditions = {'anyop': 'deny_anyop'}
        ep._routing_obj.container.governance_controller.check_process_operation_preconditions = deny_anyop
        with self.assertRaises(Unauthorized) as cm:
            ep.message_received(msg_dict2, header_dict)
        self.assertIn('The anyop operation has been denied',cm.exception.message)

        #Using the internal mock counter to see if it was still only called once.
        ep._routing_obj.anyop.assert_called_once_with(iam='adict')
Esempio n. 2
0
    def test_message_received(self, mockmr):
        procmock = Mock()
        procmock.push_context = MagicMock()

        ep = ProcessRPCResponseEndpointUnit(process=procmock, interceptors={})
        ep._routing_obj = procmock

        msg_dict = {'iam': 'adict'}
        header_dict = {'op': 'anyop'}
        ep.message_received(msg_dict, header_dict)

        ep._routing_obj.anyop.assert_called_once_with(iam='adict')

        def deny_anyop(self, operation, id=None):
            raise Unauthorized('The anyop operation has been denied')

        msg_dict2 = {'iam': 'adict2'}
        ep._routing_obj._service_op_preconditions = {'anyop': 'deny_anyop'}
        ep._routing_obj.container.governance_controller.check_process_operation_preconditions = deny_anyop
        with self.assertRaises(Unauthorized) as cm:
            ep.message_received(msg_dict2, header_dict)
        self.assertIn('The anyop operation has been denied',
                      cm.exception.message)

        #Using the internal mock counter to see if it was still only called once.
        ep._routing_obj.anyop.assert_called_once_with(iam='adict')
Esempio n. 3
0
    def message_received(self, msg, headers):

        # Try to be backward compatiable with non conversation endpoints
        if "conv-msg-type" in headers:
            self.participant.receive_invitation(msg, headers)
            # TODO = reject an invitation is not supported yet
            self.participant.accept_next_invitation(self, merge_with_first_send=True)

        result, response_headers = ProcessRPCResponseEndpointUnit.message_received(self, msg, headers)

        return result, response_headers
Esempio n. 4
0
    def message_received(self, msg, headers):

        #Try to be backward compatiable with non conversation endpoints
        if 'conv-msg-type' in headers:
            self.participant.receive_invitation(msg, headers)
            #TODO = reject an invitation is not supported yet
            self.participant.accept_next_invitation(self,
                                                    merge_with_first_send=True)

        result, response_headers = ProcessRPCResponseEndpointUnit.message_received(
            self, msg, headers)

        return result, response_headers