Fixed regression in unauthenticated API client w/ integration tests

This commit is contained in:
hackrush 2018-08-15 13:56:07 +05:30 committed by Jack Robison
parent 49c659b832
commit 8c6c442fdd
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 32 additions and 1 deletions

View file

@ -25,8 +25,10 @@ async def execute_command(method, params, conf_path=None):
# this actually executes the method
try:
resp = await api.call(method, params)
if not api.session.closed:
try:
await api.session.close()
except AttributeError:
pass
print(json.dumps(resp["result"], indent=2))
except KeyError:
if resp["error"]["code"] == -32500:

View file

@ -40,3 +40,32 @@ class AuthCLIIntegrationTest(unittest.TestCase):
@defer.inlineCallbacks
def tearDown(self):
yield self.daemon._shutdown()
class UnAuthCLIIntegrationTest(unittest.TestCase):
@defer.inlineCallbacks
def setUp(self):
skip = [
DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT,
DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, STREAM_IDENTIFIER_COMPONENT, FILE_MANAGER_COMPONENT,
PEER_PROTOCOL_SERVER_COMPONENT, REFLECTOR_COMPONENT, UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT,
RATE_LIMITER_COMPONENT, PAYMENT_RATE_COMPONENT
]
conf.initialize_settings(load_conf_file=False)
conf.settings["components_to_skip"] = skip
conf.settings.initialize_post_conf_load()
Daemon.component_attributes = {}
self.daemon = Daemon()
yield self.daemon.start_listening()
def test_cli_status_command_with_auth(self):
self.assertTrue(self.daemon._use_authentication)
actual_output = StringIO()
with contextlib.redirect_stdout(actual_output):
cli.main(["status"])
actual_output = actual_output.getvalue()
self.assertIn("connection_status", actual_output)
@defer.inlineCallbacks
def tearDown(self):
yield self.daemon._shutdown()