|
|
|
@ -5,9 +5,13 @@ Tests using API.
|
|
|
|
|
import base64
|
|
|
|
|
import json
|
|
|
|
|
import time
|
|
|
|
|
import xmlrpclib # nosec
|
|
|
|
|
|
|
|
|
|
from test_process import TestProcessProto, TestProcessShutdown
|
|
|
|
|
try: # nosec
|
|
|
|
|
from xmlrpclib import ServerProxy, ProtocolError
|
|
|
|
|
except ImportError:
|
|
|
|
|
from xmlrpc.client import ServerProxy, ProtocolError
|
|
|
|
|
|
|
|
|
|
from .test_process import TestProcessProto, TestProcessShutdown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestAPIProto(TestProcessProto):
|
|
|
|
@ -19,7 +23,7 @@ class TestAPIProto(TestProcessProto):
|
|
|
|
|
"""Setup XMLRPC proxy for pybitmessage API"""
|
|
|
|
|
super(TestAPIProto, cls).setUpClass()
|
|
|
|
|
cls.addresses = []
|
|
|
|
|
cls.api = xmlrpclib.ServerProxy(
|
|
|
|
|
cls.api = ServerProxy(
|
|
|
|
|
"http://username:password@127.0.0.1:8442/")
|
|
|
|
|
for _ in range(5):
|
|
|
|
|
if cls._get_readline('.api_started'):
|
|
|
|
@ -65,8 +69,8 @@ class TestAPI(TestAPIProto):
|
|
|
|
|
|
|
|
|
|
def test_user_password(self):
|
|
|
|
|
"""Trying to connect with wrong username/password"""
|
|
|
|
|
api_wrong = xmlrpclib.ServerProxy("http://test:wrong@127.0.0.1:8442/")
|
|
|
|
|
with self.assertRaises(xmlrpclib.ProtocolError):
|
|
|
|
|
api_wrong = ServerProxy("http://test:wrong@127.0.0.1:8442/")
|
|
|
|
|
with self.assertRaises(ProtocolError):
|
|
|
|
|
api_wrong.clientStatus()
|
|
|
|
|
|
|
|
|
|
def test_connection(self):
|
|
|
|
|