@@ -30,113 +30,133 @@ void main() {
30
30
31
31
test ('returns null if allowUrl is set and does not match with url' ,
32
32
() async {
33
- SentryEvent ? event = SentryEvent (
34
- request: SentryRequest (
35
- url: 'foo.bar' ,
36
- ),
37
- );
33
+ final event = _createEventWithException ("foo.bar" );
38
34
fixture.options.allowUrls = ["another.url" ];
39
35
40
36
var eventProcessor = fixture.getSut ();
41
- event = await eventProcessor.apply (event, Hint ());
37
+ final processedEvent = await eventProcessor.apply (event, Hint ());
42
38
43
- expect (event , isNull);
39
+ expect (processedEvent , isNull);
44
40
});
45
41
46
42
test ('returns event if allowUrl is set and does partially match with url' ,
47
43
() async {
48
- SentryEvent ? event = SentryEvent (
49
- request: SentryRequest (
50
- url: 'foo.bar' ,
51
- ),
52
- );
44
+ final event = _createEventWithException ("foo.bar" );
53
45
fixture.options.allowUrls = ["bar" ];
54
46
55
47
var eventProcessor = fixture.getSut ();
56
- event = await eventProcessor.apply (event, Hint ());
48
+ final processedEvent = await eventProcessor.apply (event, Hint ());
57
49
58
- expect (event , isNotNull);
50
+ expect (processedEvent , isNotNull);
59
51
});
60
52
61
53
test ('returns event if denyUrl is set and does not match with url' ,
62
54
() async {
63
- SentryEvent ? event = SentryEvent (
64
- request: SentryRequest (
65
- url: 'foo.bar' ,
66
- ),
67
- );
55
+ final event = _createEventWithException ("foo.bar" );
68
56
fixture.options.denyUrls = ["another.url" ];
69
57
70
58
var eventProcessor = fixture.getSut ();
71
- event = await eventProcessor.apply (event, Hint ());
59
+ final processedEvent = await eventProcessor.apply (event, Hint ());
72
60
73
- expect (event , isNotNull);
61
+ expect (processedEvent , isNotNull);
74
62
});
75
63
76
64
test ('returns null if denyUrl is set and partially matches with url' ,
77
65
() async {
78
- SentryEvent ? event = SentryEvent (
79
- request: SentryRequest (
80
- url: 'foo.bar' ,
81
- ),
82
- );
66
+ final event = _createEventWithException ("foo.bar" );
83
67
fixture.options.denyUrls = ["bar" ];
84
68
85
69
var eventProcessor = fixture.getSut ();
86
- event = await eventProcessor.apply (event, Hint ());
70
+ final processedEvent = await eventProcessor.apply (event, Hint ());
87
71
88
- expect (event , isNull);
72
+ expect (processedEvent , isNull);
89
73
});
90
74
91
75
test (
92
76
'returns null if it is part of the allowed domain, but blocked for subdomain' ,
93
77
() async {
94
- SentryEvent ? event = SentryEvent (
95
- request: SentryRequest (
96
- url: 'this.is/a/special/url/for-testing/this-feature' ,
97
- ),
98
- );
78
+ final event = _createEventWithException (
79
+ "this.is/a/special/url/for-testing/this-feature" );
80
+
99
81
fixture.options.allowUrls = ["^this.is/.*\$ " ];
100
82
fixture.options.denyUrls = ["special" ];
101
83
102
84
var eventProcessor = fixture.getSut ();
103
- event = await eventProcessor.apply (event, Hint ());
85
+ final processedEvent = await eventProcessor.apply (event, Hint ());
104
86
105
- expect (event , isNull);
87
+ expect (processedEvent , isNull);
106
88
});
107
89
108
90
test (
109
91
'returns event if it is part of the allowed domain, and not of the blocked for subdomain' ,
110
92
() async {
111
- SentryEvent ? event = SentryEvent (
112
- request: SentryRequest (
113
- url: 'this.is/a/test/url/for-testing/this-feature' ,
114
- ),
115
- );
93
+ final event = _createEventWithException (
94
+ "this.is/a/test/url/for-testing/this-feature" );
116
95
fixture.options.allowUrls = ["^this.is/.*\$ " ];
117
96
fixture.options.denyUrls = ["special" ];
118
97
119
98
var eventProcessor = fixture.getSut ();
120
- event = await eventProcessor.apply (event, Hint ());
99
+ final processedEvent = await eventProcessor.apply (event, Hint ());
121
100
122
- expect (event , isNotNull);
101
+ expect (processedEvent , isNotNull);
123
102
});
124
103
125
104
test (
126
105
'returns null if it is not part of the allowed domain, and not of the blocked for subdomain' ,
127
106
() async {
128
- SentryEvent ? event = SentryEvent (
129
- request: SentryRequest (
130
- url: 'another.url/for/a/test/testing/this-feature' ,
131
- ),
132
- );
107
+ final event = _createEventWithException (
108
+ "another.url/for/a/test/testing/this-feature" );
133
109
fixture.options.allowUrls = ["^this.is/.*\$ " ];
134
110
fixture.options.denyUrls = ["special" ];
135
111
136
112
var eventProcessor = fixture.getSut ();
137
- event = await eventProcessor.apply (event, Hint ());
113
+ final processedEvent = await eventProcessor.apply (event, Hint ());
114
+
115
+ expect (processedEvent, isNull);
116
+ });
117
+
118
+ test (
119
+ 'returns event if denyUrl is set and not matching with url of first exception' ,
120
+ () async {
121
+ final frame1 = SentryStackFrame (absPath: "test.url" );
122
+ final st1 = SentryStackTrace (frames: [frame1]);
123
+ final exception1 = SentryException (
124
+ type: "test-type" , value: "test-value" , stackTrace: st1);
125
+
126
+ final frame2 = SentryStackFrame (absPath: "foo.bar" );
127
+ final st2 = SentryStackTrace (frames: [frame2]);
128
+ final exception2 = SentryException (
129
+ type: "test-type" , value: "test-value" , stackTrace: st2);
130
+
131
+ SentryEvent event = SentryEvent (exceptions: [exception1, exception2]);
132
+
133
+ fixture.options.denyUrls = ["bar" ];
134
+
135
+ var eventProcessor = fixture.getSut ();
136
+ final processedEvent = await eventProcessor.apply (event, Hint ());
138
137
139
- expect (event, isNull);
138
+ expect (processedEvent, isNotNull);
139
+ });
140
+
141
+ test (
142
+ 'returns event if denyUrl is set and not matching with url of first stacktraceframe' ,
143
+ () async {
144
+ final frame1 = SentryStackFrame (absPath: "test.url" );
145
+ final st1 = SentryStackTrace (frames: [frame1]);
146
+ final thread1 = SentryThread (stacktrace: st1);
147
+
148
+ final frame2 = SentryStackFrame (absPath: "foo.bar" );
149
+ final st2 = SentryStackTrace (frames: [frame2]);
150
+ final thread2 = SentryThread (stacktrace: st2);
151
+
152
+ SentryEvent event = SentryEvent (threads: [thread1, thread2]);
153
+
154
+ fixture.options.denyUrls = ["bar" ];
155
+
156
+ var eventProcessor = fixture.getSut ();
157
+ final processedEvent = await eventProcessor.apply (event, Hint ());
158
+
159
+ expect (processedEvent, isNotNull);
140
160
});
141
161
});
142
162
}
@@ -147,3 +167,13 @@ class Fixture {
147
167
return UrlFilterEventProcessor (options);
148
168
}
149
169
}
170
+
171
+ SentryEvent _createEventWithException (String url) {
172
+ final frame = SentryStackFrame (absPath: url);
173
+ final st = SentryStackTrace (frames: [frame]);
174
+ final exception =
175
+ SentryException (type: "test-type" , value: "test-value" , stackTrace: st);
176
+ SentryEvent event = SentryEvent (exceptions: [exception]);
177
+
178
+ return event;
179
+ }
0 commit comments