1111class TestAriesAgentController :
1212
1313 admin_url = "0.0.0.0"
14- webhook_host = ""
14+ webhook_host = "0.0.0.0 "
1515 webhook_port = 8000
1616 webhook_base = ""
1717
@@ -42,7 +42,9 @@ async def test_init_args_multi_true(self):
4242 @pytest .mark .asyncio
4343 async def test_init_webhook_server (self ):
4444 ac = AriesAgentController (admin_url = self .admin_url , is_multitenant = True )
45- ac .init_webhook_server (self .webhook_host , self .webhook_port , self .webhook_base )
45+ await ac .init_webhook_server (
46+ self .webhook_host , self .webhook_port , self .webhook_base
47+ )
4648 assert type (ac .webhook_server ) == AriesWebhookServer
4749 assert ac .webhook_server .webhook_base == self .webhook_base
4850 assert ac .webhook_server .webhook_port == self .webhook_port
@@ -51,22 +53,53 @@ async def test_init_webhook_server(self):
5153 await ac .terminate ()
5254
5355 @pytest .mark .asyncio
54- async def test_listen_webhooks_error (self , caplog ):
55- caplog .set_level (logging .WARNING )
56- ac = AriesAgentController (admin_url = self .admin_url , is_multitenant = True )
57- with pytest .raises (AttributeError ) as ae :
58- await ac .listen_webhooks ()
59- assert "Webhook server not initialised." in str (ae .value )
60- assert "Webhook server not initialised." in caplog .text
61- await ac .terminate ()
56+ async def test_init_webhook_server_args_host_type (self ):
57+ with pytest .raises (AssertionError ):
58+ ac = AriesAgentController (admin_url = self .admin_url , is_multitenant = True )
59+ await ac .init_webhook_server (
60+ webhook_host = 1234 , webhook_port = 1234 , webhook_base = self .webhook_base
61+ )
62+
63+ @pytest .mark .asyncio
64+ async def test_init_webhook_server_invalid_ip (self ):
65+ with pytest .raises (
66+ ValueError , match = "does not appear to be an IPv4 or IPv6 address"
67+ ):
68+ ac = AriesAgentController (admin_url = self .admin_url , is_multitenant = True )
69+ await ac .init_webhook_server (
70+ webhook_host = "12345.123456.1234.0" ,
71+ webhook_port = 1234 ,
72+ webhook_base = self .webhook_base ,
73+ )
74+
75+ @pytest .mark .asyncio
76+ async def test_init_webhook_server_empty_invalid_ip (self ):
77+ with pytest .raises (
78+ ValueError , match = "does not appear to be an IPv4 or IPv6 address"
79+ ):
80+ ac = AriesAgentController (admin_url = self .admin_url , is_multitenant = True )
81+ await ac .init_webhook_server (
82+ webhook_host = "" , webhook_port = 1234 , webhook_base = self .webhook_base
83+ )
84+
85+ @pytest .mark .asyncio
86+ async def test_init_webhook_server_args_port (self ):
87+ with pytest .raises (AssertionError ):
88+ ac = AriesAgentController (admin_url = self .admin_url , is_multitenant = True )
89+ await ac .init_webhook_server (
90+ webhook_host = self .webhook_host ,
91+ webhook_port = "1234" ,
92+ webhook_base = self .webhook_base ,
93+ )
6294
6395 @pytest .mark .asyncio
6496 async def test_init_webhook_server_terminate (self , caplog ):
6597 caplog .set_level (logging .INFO )
6698 ac = AriesAgentController (admin_url = self .admin_url , is_multitenant = True )
67- ac .init_webhook_server (self .webhook_host , self .webhook_port , self .webhook_base )
68- await ac .listen_webhooks ()
69- assert "Webhook server started." in caplog .text
99+ await ac .init_webhook_server (
100+ self .webhook_host , self .webhook_port , self .webhook_base
101+ )
102+ assert "Webhook server started" in caplog .text
70103 res = await ac .webhook_server .terminate ()
71104 assert "Webhook server terminated." in caplog .text
72105 assert res is None
0 commit comments