11
11
class TestAriesAgentController :
12
12
13
13
admin_url = "0.0.0.0"
14
- webhook_host = ""
14
+ webhook_host = "0.0.0.0 "
15
15
webhook_port = 8000
16
16
webhook_base = ""
17
17
@@ -42,7 +42,9 @@ async def test_init_args_multi_true(self):
42
42
@pytest .mark .asyncio
43
43
async def test_init_webhook_server (self ):
44
44
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
+ )
46
48
assert type (ac .webhook_server ) == AriesWebhookServer
47
49
assert ac .webhook_server .webhook_base == self .webhook_base
48
50
assert ac .webhook_server .webhook_port == self .webhook_port
@@ -51,22 +53,53 @@ async def test_init_webhook_server(self):
51
53
await ac .terminate ()
52
54
53
55
@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
+ )
62
94
63
95
@pytest .mark .asyncio
64
96
async def test_init_webhook_server_terminate (self , caplog ):
65
97
caplog .set_level (logging .INFO )
66
98
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
70
103
res = await ac .webhook_server .terminate ()
71
104
assert "Webhook server terminated." in caplog .text
72
105
assert res is None
0 commit comments