-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rephrased documentation and split up tests for web and mobile platform.
- Loading branch information
1 parent
8523a6d
commit a30a862
Showing
4 changed files
with
190 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
flutter/test/event_processor/url_filter/io_filter_event_processor_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@TestOn('vm') | ||
library flutter_test; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
import 'package:sentry_flutter/src/event_processor/url_filter/url_filter_event_processor.dart'; | ||
|
||
void main() { | ||
group("ignore allowUrls and denyUrls for non Web", () { | ||
late Fixture fixture; | ||
|
||
setUp(() async { | ||
fixture = Fixture(); | ||
}); | ||
|
||
test('returns the event and ignore allowUrls and denyUrls for non Web', | ||
() async { | ||
SentryEvent? event = SentryEvent( | ||
request: SentryRequest( | ||
url: 'another.url/for/a/special/test/testing/this-feature', | ||
), | ||
); | ||
fixture.options.allowUrls = ["^this.is/.*\$"]; | ||
fixture.options.denyUrls = ["special"]; | ||
|
||
var eventProcessor = fixture.getSut(); | ||
event = await eventProcessor.apply(event, Hint()); | ||
|
||
expect(event, isNotNull); | ||
}); | ||
}); | ||
} | ||
|
||
class Fixture { | ||
SentryFlutterOptions options = SentryFlutterOptions(); | ||
UrlFilterEventProcessor getSut() { | ||
return UrlFilterEventProcessor(options); | ||
} | ||
} |
149 changes: 149 additions & 0 deletions
149
flutter/test/event_processor/url_filter/web_url_filter_event_processor_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
@TestOn('browser') | ||
library flutter_test; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
import 'package:sentry_flutter/src/event_processor/url_filter/url_filter_event_processor.dart'; | ||
|
||
// can be tested on command line with | ||
// `flutter test --platform=chrome test/event_processor/url_filter/web_url_filter_event_processor_test.dart` | ||
void main() { | ||
group(UrlFilterEventProcessor, () { | ||
late Fixture fixture; | ||
|
||
setUp(() { | ||
fixture = Fixture(); | ||
}); | ||
|
||
test('returns event if no allowUrl and no denyUrl is set', () async { | ||
SentryEvent? event = SentryEvent( | ||
request: SentryRequest( | ||
url: 'foo.bar', | ||
), | ||
); | ||
|
||
var eventProcessor = fixture.getSut(); | ||
event = await eventProcessor.apply(event, Hint()); | ||
|
||
expect(event, isNotNull); | ||
}); | ||
|
||
test('returns null if allowUrl is set and does not match with url', | ||
() async { | ||
SentryEvent? event = SentryEvent( | ||
request: SentryRequest( | ||
url: 'foo.bar', | ||
), | ||
); | ||
fixture.options.allowUrls = ["another.url"]; | ||
|
||
var eventProcessor = fixture.getSut(); | ||
event = await eventProcessor.apply(event, Hint()); | ||
|
||
expect(event, isNull); | ||
}); | ||
|
||
test('returns event if allowUrl is set and does partially match with url', | ||
() async { | ||
SentryEvent? event = SentryEvent( | ||
request: SentryRequest( | ||
url: 'foo.bar', | ||
), | ||
); | ||
fixture.options.allowUrls = ["bar"]; | ||
|
||
var eventProcessor = fixture.getSut(); | ||
event = await eventProcessor.apply(event, Hint()); | ||
|
||
expect(event, isNotNull); | ||
}); | ||
|
||
test('returns event if denyUrl is set and does not match with url', | ||
() async { | ||
SentryEvent? event = SentryEvent( | ||
request: SentryRequest( | ||
url: 'foo.bar', | ||
), | ||
); | ||
fixture.options.denyUrls = ["another.url"]; | ||
|
||
var eventProcessor = fixture.getSut(); | ||
event = await eventProcessor.apply(event, Hint()); | ||
|
||
expect(event, isNotNull); | ||
}); | ||
|
||
test('returns null if denyUrl is set and partially matches with url', | ||
() async { | ||
SentryEvent? event = SentryEvent( | ||
request: SentryRequest( | ||
url: 'foo.bar', | ||
), | ||
); | ||
fixture.options.denyUrls = ["bar"]; | ||
|
||
var eventProcessor = fixture.getSut(); | ||
event = await eventProcessor.apply(event, Hint()); | ||
|
||
expect(event, isNull); | ||
}); | ||
|
||
test( | ||
'returns null if it is part of the allowed domain, but blocked for subdomain', | ||
() async { | ||
SentryEvent? event = SentryEvent( | ||
request: SentryRequest( | ||
url: 'this.is/a/special/url/for-testing/this-feature', | ||
), | ||
); | ||
fixture.options.allowUrls = ["^this.is/.*\$"]; | ||
fixture.options.denyUrls = ["special"]; | ||
|
||
var eventProcessor = fixture.getSut(); | ||
event = await eventProcessor.apply(event, Hint()); | ||
|
||
expect(event, isNull); | ||
}); | ||
|
||
test( | ||
'returns event if it is part of the allowed domain, and not of the blocked for subdomain', | ||
() async { | ||
SentryEvent? event = SentryEvent( | ||
request: SentryRequest( | ||
url: 'this.is/a/test/url/for-testing/this-feature', | ||
), | ||
); | ||
fixture.options.allowUrls = ["^this.is/.*\$"]; | ||
fixture.options.denyUrls = ["special"]; | ||
|
||
var eventProcessor = fixture.getSut(); | ||
event = await eventProcessor.apply(event, Hint()); | ||
|
||
expect(event, isNotNull); | ||
}); | ||
|
||
test( | ||
'returns null if it is not part of the allowed domain, and not of the blocked for subdomain', | ||
() async { | ||
SentryEvent? event = SentryEvent( | ||
request: SentryRequest( | ||
url: 'another.url/for/a/test/testing/this-feature', | ||
), | ||
); | ||
fixture.options.allowUrls = ["^this.is/.*\$"]; | ||
fixture.options.denyUrls = ["special"]; | ||
|
||
var eventProcessor = fixture.getSut(); | ||
event = await eventProcessor.apply(event, Hint()); | ||
|
||
expect(event, isNull); | ||
}); | ||
}); | ||
} | ||
|
||
class Fixture { | ||
SentryFlutterOptions options = SentryFlutterOptions(); | ||
UrlFilterEventProcessor getSut() { | ||
return UrlFilterEventProcessor(options); | ||
} | ||
} |
173 changes: 0 additions & 173 deletions
173
flutter/test/event_processor/url_filter_event_processor_test.dart
This file was deleted.
Oops, something went wrong.