@@ -155,3 +155,59 @@ def test_add_group_members(tmp_path, monkeypatch):
155
155
result = fh .read ()
156
156
assert "group addmembers quarry_workers" in result
157
157
assert "fflintstone,brubble" in result
158
+
159
+
160
+ @pytest .mark .parametrize (
161
+ "cfg,ifaces,expected" ,
162
+ [
163
+ ({}, ["foo" , "bar" ], None ),
164
+ (
165
+ {"include_pattern" : "^eth.*$" },
166
+ ["lo" , "eth0" , "eth1" , "biff1" ],
167
+ ["lo" , "eth0" , "eth1" ],
168
+ ),
169
+ (
170
+ {"include_pattern" : "^nope$" },
171
+ ["lo" , "eth0" , "eth1" , "biff1" ],
172
+ ["lo" ],
173
+ ),
174
+ (
175
+ {"include_pattern" : "^biff[0-9]+$" },
176
+ ["lo" , "eth0" , "eth1" , "biff1" ],
177
+ ["lo" , "biff1" ],
178
+ ),
179
+ (
180
+ {"exclude_pattern" : "^docker[0-9]+$" },
181
+ ["lo" , "eno1" , "eno2" , "docker0" ],
182
+ ["lo" , "eno1" , "eno2" ],
183
+ ),
184
+ (
185
+ {"exclude_pattern" : "^.*$" },
186
+ ["lo" , "eno1" , "eno2" , "docker0" ],
187
+ ["lo" ],
188
+ ),
189
+ (
190
+ {
191
+ "include_pattern" : "^[ed].*$" ,
192
+ "exclude_pattern" : "^docker[0-9]+$" ,
193
+ },
194
+ ["lo" , "eno1" , "eno2" , "docker0" ],
195
+ ["lo" , "eno1" , "eno2" ],
196
+ ),
197
+ (
198
+ {
199
+ "include_pattern" : "^[ed].*$" ,
200
+ "exclude_pattern" : "^.*0$" ,
201
+ },
202
+ ["lo" , "dx1f2" , "docker0" ],
203
+ ["lo" , "dx1f2" ],
204
+ ),
205
+ ],
206
+ )
207
+ def test_filtered_interfaces (cfg , ifaces , expected ):
208
+ ic = sambacc .config .DCInterfaceConfig (cfg )
209
+ if cfg :
210
+ assert ic .configured
211
+ assert sambacc .addc .filtered_interfaces (ic , ifaces ) == expected
212
+ else :
213
+ assert not ic .configured
0 commit comments