@@ -236,3 +236,93 @@ def test_session_aggregates_invalid_release(
236236 )
237237
238238 sessions_consumer .assert_empty ()
239+
240+
241+ def test_session_filtering (mini_sentry , relay_with_processing , sessions_consumer ):
242+ relay = relay_with_processing ()
243+ sessions_consumer = sessions_consumer ()
244+
245+ project_id = 42
246+ project_config = mini_sentry .add_full_project_config (project_id )
247+ filter_settings = project_config ["config" ]["filterSettings" ]
248+ filter_settings ["webCrawlers" ] = {"isEnabled" : True }
249+ filter_settings ["clientIps" ] = {"blacklistedIps" : ["1.2.3.0/24" ]}
250+ filter_settings ["releases" ] = {"releases" : ["sentry-bad*" ]}
251+
252+ timestamp = datetime .now (tz = timezone .utc )
253+ relay .send_session (
254+ project_id ,
255+ {
256+ "sid" : "8333339f-5675-4f89-a9a0-1c935255ab58" ,
257+ "timestamp" : timestamp .isoformat (),
258+ "started" : timestamp .isoformat (),
259+ "attrs" : {"release" : "sentry-test@1.0.0" , "user_agent" : "BingBot" },
260+ },
261+ )
262+
263+ relay .send_session (
264+ project_id ,
265+ {
266+ "sid" : "8333339f-5675-4f89-a9a0-1c935255ab59" ,
267+ "timestamp" : timestamp .isoformat (),
268+ "started" : timestamp .isoformat (),
269+ "attrs" : {"release" : "sentry-test@1.0.0" , "ip_address" : "1.2.3.0/24" },
270+ },
271+ )
272+
273+ relay .send_session (
274+ project_id ,
275+ {
276+ "sid" : "8333339f-5675-4f89-a9a0-1c935255ab59" ,
277+ "timestamp" : timestamp .isoformat (),
278+ "started" : timestamp .isoformat (),
279+ "attrs" : {"release" : "sentry-bad@1.0.0" , "ip_address" : "127.0.0.1" },
280+ },
281+ )
282+
283+ relay .send_session_aggregates (
284+ project_id ,
285+ {
286+ "aggregates" : [
287+ {
288+ "started" : timestamp .isoformat (),
289+ "did" : "foobarbaz" ,
290+ "exited" : 2 ,
291+ "errored" : 3 ,
292+ },
293+ ],
294+ "attrs" : {"release" : "sentry-test@1.0.0" , "user_agent" : "BingBot" },
295+ },
296+ )
297+
298+ relay .send_session_aggregates (
299+ project_id ,
300+ {
301+ "aggregates" : [
302+ {
303+ "started" : timestamp .isoformat (),
304+ "did" : "foobarbaz" ,
305+ "exited" : 2 ,
306+ "errored" : 3 ,
307+ },
308+ ],
309+ "attrs" : {"release" : "sentry-test@1.0.0" , "ip_address" : "1.2.3.0/24" },
310+ },
311+ )
312+
313+ relay .send_session_aggregates (
314+ project_id ,
315+ {
316+ "aggregates" : [
317+ {
318+ "started" : timestamp .isoformat (),
319+ "did" : "foobarbaz" ,
320+ "exited" : 2 ,
321+ "errored" : 3 ,
322+ },
323+ ],
324+ "attrs" : {"release" : "sentry-bad@1.0.0" , "ip_address" : "127.0.0.1" },
325+ },
326+ )
327+
328+ sessions_consumer .assert_empty ()
0 commit comments