add support for port 3000 + fix some of the tests, still some errors in the unit tests I'll come back to

This commit is contained in:
Aaron Blankstein
2017-07-17 14:06:28 -04:00
parent 99c4f58202
commit 7a005ff1d9
2 changed files with 15 additions and 10 deletions

View File

@@ -64,6 +64,7 @@ import proxy
from proxy import json_is_error, json_is_exception
DEFAULT_UI_PORT = 8888
DEVELOPMENT_UI_PORT = 3000
from .constants import BLOCKSTACK_DEBUG, BLOCKSTACK_TEST, RPC_MAX_ZONEFILE_LEN, CONFIG_PATH, WALLET_FILENAME, TX_MIN_CONFIRMATIONS, DEFAULT_API_PORT, SERIES_VERSION, TX_MAX_FEE
from .method_parser import parse_methods
@@ -3519,13 +3520,15 @@ class BlockstackAPIEndpointHandler(SimpleHTTPRequestHandler):
},
}
LOCALHOST = [
'http://localhost:{}'.format(DEFAULT_UI_PORT),
'http://{}:{}'.format(socket.gethostname(), DEFAULT_UI_PORT),
'http://127.0.0.1:{}'.format(DEFAULT_UI_PORT),
'http://::1:{}'.format(DEFAULT_UI_PORT)
]
LOCALHOST = []
for port in [DEFAULT_UI_PORT, DEVELOPMENT_UI_PORT]:
LOCALHOST += [
'http://localhost:{}'.format(port),
'http://{}:{}'.format(socket.gethostname(), port),
'http://127.0.0.1:{}'.format(port),
'http://::1:{}'.format(port)
]
path_info = self.get_path_and_qs()
if 'error' in path_info:
self._send_headers(status_code=401, content_type='text/plain')

View File

@@ -111,10 +111,11 @@ class APITestCase(unittest.TestCase):
traceback.print_exc()
raise e
def get_auth_header(key = None):
def get_auth_header(key = None, port = 8888):
if key is None:
key = API_PASSWORD
return {'Authorization' : 'bearer {}'.format(key)}
return {'Authorization' : 'bearer {}'.format(key),
'Origin' : 'http://localhost:{}'.format(port)}
def check_data(cls, data, required_keys={}):
for k in required_keys:
@@ -138,7 +139,8 @@ class AuthInternal(APITestCase):
privkey = ("a28ea1a6f11fb1c755b1d102990d64d6" +
"b4468c10705bbcbdfca8bc4497cf8da8")
auth_header = get_auth_header()
# test support for the development UI port as well (3000)
auth_header = get_auth_header(port = 3000)
request = {
'app_domain': 'test.com',
'app_public_key': blockstack_client.keys.get_pubkey_hex(privkey),