@@ -254,3 +254,50 @@ def test_parse_wireguard_peer(self):
254254 }
255255 o = OpenWrt (native = native )
256256 self .assertEqual (o .config , expected )
257+
258+ _multiple_peers_netjson = {
259+ "wireguard_peers" : [
260+ {
261+ "interface" : "wg0" ,
262+ "public_key" : "rn+isMBpyQ4HX6ZzE709bKnZw5IaLZoIS3hIjmfKCkk=" ,
263+ "allowed_ips" : ["10.0.0.1/32" ],
264+ "preshared_key" : "oPZmGdHBseaV1TF0julyElNuJyeKs2Eo+o62R/09IB4=" ,
265+ "persistent_keepalive" : 30 ,
266+ "route_allowed_ips" : True ,
267+ },
268+ {
269+ "interface" : "wg0" ,
270+ "public_key" : "e8yh3kIrMjLVZPi5DS1BU3j3mWkYWrCXvnLSvNkW7HM=" ,
271+ "allowed_ips" : ["10.0.0.2/32" ],
272+ "preshared_key" : "oPZmGdHBseaV1TF0julyElNuJyeKs2Eo+o62R/09IB4=" ,
273+ "persistent_keepalive" : 30 ,
274+ "route_allowed_ips" : True ,
275+ },
276+ ]
277+ }
278+
279+ _multiple_peers_uci = """package network
280+
281+ config wireguard_wg0 'wgpeer_wg0'
282+ list allowed_ips '10.0.0.1/32'
283+ option persistent_keepalive '30'
284+ option preshared_key 'oPZmGdHBseaV1TF0julyElNuJyeKs2Eo+o62R/09IB4='
285+ option public_key 'rn+isMBpyQ4HX6ZzE709bKnZw5IaLZoIS3hIjmfKCkk='
286+ option route_allowed_ips '1'
287+
288+ config wireguard_wg0 'wgpeer_wg0_2'
289+ list allowed_ips '10.0.0.2/32'
290+ option persistent_keepalive '30'
291+ option preshared_key 'oPZmGdHBseaV1TF0julyElNuJyeKs2Eo+o62R/09IB4='
292+ option public_key 'e8yh3kIrMjLVZPi5DS1BU3j3mWkYWrCXvnLSvNkW7HM='
293+ option route_allowed_ips '1'
294+ """
295+
296+ def test_render_multiple_wireguard_peers (self ):
297+ o = OpenWrt (self ._multiple_peers_netjson )
298+ expected = self ._tabs (self ._multiple_peers_uci )
299+ self .assertEqual (o .render (), expected )
300+
301+ def test_parse_multiple_wireguard_peers (self ):
302+ o = OpenWrt (native = self ._multiple_peers_uci )
303+ self .assertEqual (o .config , self ._multiple_peers_netjson )
0 commit comments