-
-
Notifications
You must be signed in to change notification settings - Fork 277
Support for new DSN format (without secretKey) and remove the quiver dependency. #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Code review modifications.
- Loading branch information
commit 11c14e23cb07c8391eb9ce8c11692558b4eb9a36
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ | |
| # Name/Organization <email address> | ||
|
|
||
| Google Inc. | ||
| Simon Lightfoot <[email protected]> | ||
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import 'package:sentry/sentry.dart'; | |
| import 'package:test/test.dart'; | ||
|
|
||
| const String _testDsn = 'https://public:[email protected]/1'; | ||
| const String _testDsnWithoutSecret = 'https://[email protected]/1'; | ||
|
|
||
| void main() { | ||
| group('$SentryClient', () { | ||
|
|
@@ -23,6 +24,70 @@ void main() { | |
| await client.close(); | ||
| }); | ||
|
|
||
| test('can parse DSN without secret', () async { | ||
| final SentryClient client = new SentryClient(dsn: _testDsnWithoutSecret); | ||
| expect(client.dsnUri, Uri.parse(_testDsnWithoutSecret)); | ||
| expect(client.postUri, 'https://sentry.example.com/api/1/store/'); | ||
| expect(client.publicKey, 'public'); | ||
| expect(client.secretKey, null); | ||
| expect(client.projectId, '1'); | ||
| await client.close(); | ||
| }); | ||
|
|
||
| test('sends client auth header without secret', () async { | ||
| final MockClient httpMock = new MockClient(); | ||
| final ClockProvider fakeClockProvider = () => new DateTime.utc(2017, 1, 2); | ||
|
|
||
| Map<String, String> headers; | ||
|
|
||
| httpMock.answerWith((Invocation invocation) async { | ||
| if (invocation.memberName == #close) { | ||
| return null; | ||
| } | ||
| if (invocation.memberName == #post) { | ||
| headers = invocation.namedArguments[#headers]; | ||
| return new Response('{"id": "test-event-id"}', 200); | ||
| } | ||
| fail('Unexpected invocation of ${invocation.memberName} in HttpMock'); | ||
| }); | ||
|
|
||
| final SentryClient client = new SentryClient( | ||
| dsn: _testDsnWithoutSecret, | ||
| httpClient: httpMock, | ||
| clock: fakeClockProvider, | ||
| compressPayload: false, | ||
| uuidGenerator: () => 'X' * 32, | ||
| environmentAttributes: const Event( | ||
| serverName: 'test.server.com', | ||
| release: '1.2.3', | ||
| environment: 'staging', | ||
| ), | ||
| ); | ||
|
|
||
| try { | ||
| throw new ArgumentError('Test error'); | ||
| } catch (error, stackTrace) { | ||
| final SentryResponse response = await client.captureException( | ||
| exception: error, stackTrace: stackTrace); | ||
| expect(response.isSuccessful, true); | ||
| expect(response.eventId, 'test-event-id'); | ||
| expect(response.error, null); | ||
| } | ||
|
|
||
| final Map<String, String> expectedHeaders = <String, String>{ | ||
| 'User-Agent': '$sdkName/$sdkVersion', | ||
| 'Content-Type': 'application/json', | ||
| 'X-Sentry-Auth': 'Sentry sentry_version=6, ' | ||
| 'sentry_client=${SentryClient.sentryClient}, ' | ||
| 'sentry_timestamp=${fakeClockProvider().millisecondsSinceEpoch}, ' | ||
| 'sentry_key=public', | ||
| }; | ||
|
|
||
| expect(headers, expectedHeaders); | ||
|
|
||
| await client.close(); | ||
| }); | ||
|
|
||
| testCaptureException(bool compressPayload) async { | ||
| final MockClient httpMock = new MockClient(); | ||
| final ClockProvider fakeClockProvider = | ||
|
|
@@ -131,7 +196,7 @@ void main() { | |
|
|
||
| test('reads error message from the x-sentry-error header', () async { | ||
| final MockClient httpMock = new MockClient(); | ||
| final ClockProvider fakeClockProvider = () => DateTime(2017, 1, 2); | ||
| final ClockProvider fakeClockProvider = () => new DateTime.utc(2017, 1, 2); | ||
|
|
||
| httpMock.answerWith((Invocation invocation) async { | ||
| if (invocation.memberName == #close) { | ||
|
|
@@ -174,7 +239,7 @@ void main() { | |
|
|
||
| test('$Event userContext overrides client', () async { | ||
| final MockClient httpMock = new MockClient(); | ||
| final ClockProvider fakeClockProvider = () => DateTime(2017, 1, 2); | ||
| final ClockProvider fakeClockProvider = () => new DateTime.utc(2017, 1, 2); | ||
|
|
||
| String loggedUserId; // used to find out what user context was sent | ||
| httpMock.answerWith((Invocation invocation) async { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
References to in-scope identifiers should be wrapped in square brackets so that dartdoc can create links to them, in this case
[ClockProvider].