コード例 #1
0
    def test_validate_token_with_coordinator_throws_communication_error(self):
        http_request = MagicMock(side_effect=requests.RequestException)

        with patch.object(correlator, '_get_config_from_cache',
                          self.get_config),\
            patch('meniscus.correlation.correlator.http_request',
                  http_request):

            with self.assertRaises(errors.CoordinatorCommunicationError):
                correlator._validate_token_with_coordinator(
                    self.tenant_id, self.message_token, self.src_msg)
コード例 #2
0
    def test_validate_token_with_coordinator_throws_communication_error(self):
        http_request = MagicMock(side_effect=requests.RequestException)

        with patch.object(correlator, '_get_config_from_cache',
                          self.get_config),\
            patch('meniscus.correlation.correlator.http_request',
                  http_request):

            with self.assertRaises(errors.CoordinatorCommunicationError):
                correlator._validate_token_with_coordinator(
                    self.tenant_id, self.message_token, self.src_msg)
コード例 #3
0
    def test_validate_token_with_coordinator_throws_auth_error(self):
        response = MagicMock()
        response.status_code = httplib.NOT_FOUND
        http_request = MagicMock(return_value=response)

        with patch.object(correlator, '_get_config_from_cache',
                          self.get_config), \
                patch('meniscus.correlation.correlator.http_request',
                      http_request):

            with self.assertRaises(errors.MessageAuthenticationError):
                correlator._validate_token_with_coordinator(
                    self.tenant_id, self.invalid_message_token, self.src_msg)
コード例 #4
0
    def test_validate_token_with_coordinator_throws_auth_error(self):
        response = MagicMock()
        response.status_code = httplib.NOT_FOUND
        http_request = MagicMock(return_value=response)

        with patch.object(correlator, '_get_config_from_cache',
                          self.get_config), \
                patch('meniscus.correlation.correlator.http_request',
                      http_request):

            with self.assertRaises(errors.MessageAuthenticationError):
                correlator._validate_token_with_coordinator(
                    self.tenant_id, self.invalid_message_token, self.src_msg)
コード例 #5
0
 def test_validate_token_with_coordinator_calls_get_tenant(self):
     response = MagicMock()
     response.status_code = httplib.OK
     http_request = MagicMock(return_value=response)
     get_tenant_from_coordinator_func = MagicMock()
     with patch.object(correlator, '_get_config_from_cache',
                       self.get_config), \
         patch('meniscus.correlation.correlator.http_request',
               http_request),\
         patch('meniscus.correlation.correlator.'
               '_get_tenant_from_coordinator',
               get_tenant_from_coordinator_func):
         correlator._validate_token_with_coordinator(
             self.tenant_id, self.message_token, self.src_msg)
     get_tenant_from_coordinator_func.assert_called_once_with(
         self.tenant_id, self.message_token, self.src_msg)
コード例 #6
0
 def test_validate_token_with_coordinator_calls_get_tenant(self):
     response = MagicMock()
     response.status_code = httplib.OK
     http_request = MagicMock(return_value=response)
     get_tenant_from_coordinator_func = MagicMock()
     with patch.object(correlator, '_get_config_from_cache',
                       self.get_config), \
         patch('meniscus.correlation.correlator.http_request',
               http_request),\
         patch('meniscus.correlation.correlator.'
               '_get_tenant_from_coordinator',
               get_tenant_from_coordinator_func):
         correlator._validate_token_with_coordinator(self.tenant_id,
                                                     self.message_token,
                                                     self.src_msg)
     get_tenant_from_coordinator_func.assert_called_once_with(
         self.tenant_id, self.message_token, self.src_msg)