Beispiel #1
0
 def test_inbound_with_failed_auth(self):
     headers = {'Authorization': basic_auth_string("user-1", "bad-pass")}
     d = http_request(self.transport_url + "foo",
                      '',
                      headers=headers,
                      method='GET')
     response = yield d
     self.assertEqual(response, 'Unauthorized')
Beispiel #2
0
 def test_inbound_with_failed_auth(self):
     headers = {
         'Authorization': basic_auth_string("user-1", "bad-pass")
     }
     d = http_request(self.transport_url + "foo", '',
                      headers=headers, method='GET')
     response = yield d
     self.assertEqual(response, 'Unauthorized')
Beispiel #3
0
 def _call_relay(self, data, auth=None):
     data = json.dumps(data)
     host = self.app.web_resource.getHost()
     send_url = "http://127.0.0.1:%d/send" % (host.port, )
     headers = {}
     if auth is not None:
         headers['Authorization'] = basic_auth_string(*auth)
     return http_request_full(send_url, data, headers=headers)
Beispiel #4
0
 def _call_relay(self, data, auth=None):
     data = json.dumps(data)
     host = self.app.web_resource.getHost()
     send_url = "http://127.0.0.1:%d/send" % (host.port,)
     headers = {}
     if auth is not None:
         headers['Authorization'] = basic_auth_string(*auth)
     return http_request_full(send_url, data, headers=headers)
Beispiel #5
0
 def test_inbound_with_successful_auth(self):
     headers = {'Authorization': basic_auth_string("user-1", "pass-secret")}
     d = http_request(self.transport_url + "foo",
                      '',
                      headers=headers,
                      method='GET')
     [msg] = yield self.tx_helper.wait_for_dispatched_inbound(1)
     rep = yield self.tx_helper.make_dispatch_reply(msg, "OK")
     response = yield d
     self.assertEqual(response, 'OK')
     [ack] = yield self.tx_helper.wait_for_dispatched_events(1)
     self.assertEqual(ack['user_message_id'], rep['message_id'])
     self.assertEqual(ack['sent_message_id'], rep['message_id'])
Beispiel #6
0
 def test_inbound_with_successful_auth(self):
     headers = {
         'Authorization': basic_auth_string("user-1", "pass-secret")
     }
     d = http_request(self.transport_url + "foo", '',
                      headers=headers, method='GET')
     [msg] = yield self.tx_helper.wait_for_dispatched_inbound(1)
     rep = yield self.tx_helper.make_dispatch_reply(msg, "OK")
     response = yield d
     self.assertEqual(response, 'OK')
     [ack] = yield self.tx_helper.wait_for_dispatched_events(1)
     self.assertEqual(ack['user_message_id'], rep['message_id'])
     self.assertEqual(ack['sent_message_id'], rep['message_id'])
Beispiel #7
0
 def list_bindings(self):
     try:
         # Note utils.callback() does a POST not a GET
         # which may lead to errors if the RabbitMQ Management REST api
         # changes
         resp = yield http_request(
             "http://localhost:55672/api/bindings",
             headers={
                 "Authorization": basic_auth_string(self.vumi_options["username"], self.vumi_options["password"])
             },
         )
         bindings = json.loads(resp)
         bound_routing_keys = {}
         for b in bindings:
             if b["vhost"] == self.vumi_options["vhost"] and b["source"] == self.exchange_name:
                 bound_routing_keys[b["routing_key"]] = bound_routing_keys.get(b["routing_key"], []) + [
                     b["destination"]
                 ]
     except:
         bound_routing_keys = {"bindings": "undetected"}
     returnValue(bound_routing_keys)
Beispiel #8
0
 def list_bindings(self):
     try:
         # Note utils.callback() does a POST not a GET
         # which may lead to errors if the RabbitMQ Management REST api
         # changes
         resp = yield http_request(
             "http://localhost:55672/api/bindings", headers={
                 'Authorization': basic_auth_string(
                     self.vumi_options['username'],
                     self.vumi_options['password']),
                 })
         bindings = json.loads(resp)
         bound_routing_keys = {}
         for b in bindings:
             if (b['vhost'] == self.vumi_options['vhost'] and
                 b['source'] == self.exchange_name):
                 bound_routing_keys[b['routing_key']] = \
                         bound_routing_keys.get(b['routing_key'], []) + \
                         [b['destination']]
     except:
         bound_routing_keys = {"bindings": "undetected"}
     returnValue(bound_routing_keys)