Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: pkg/analysis_server/test/protocol_test.dart

Issue 180743020: guard against invalid request id / method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/protocol_test.dart
diff --git a/pkg/analysis_server/test/protocol_test.dart b/pkg/analysis_server/test/protocol_test.dart
index 5d6fd715bdbe4e9a5ba2fb37401a10031a1fad8d..282bb558ec30bbb0501ca4eb3c1d107f9f0e9615 100644
--- a/pkg/analysis_server/test/protocol_test.dart
+++ b/pkg/analysis_server/test/protocol_test.dart
@@ -22,6 +22,8 @@ main() {
test('getRequiredParameter_defined', RequestTest.getRequiredParameter_defined);
test('getRequiredParameter_undefined', RequestTest.getRequiredParameter_undefined);
test('fromJson', RequestTest.fromJson);
+ test('fromJson_invalidId', RequestTest.fromJson_invalidId);
+ test('fromJson_invalidMethod', RequestTest.fromJson_invalidMethod);
test('fromJson_withParams', RequestTest.fromJson_withParams);
test('toJson', RequestTest.toJson);
test('toJson_withParams', RequestTest.toJson_withParams);
@@ -116,6 +118,18 @@ class RequestTest {
expect(request.method, equals('aMethod'));
}
+ static void fromJson_invalidId() {
+ String json = '{"id":{"one":"two"},"method":"aMethod","params":{"foo":"bar"}}';
+ Request request = new Request.fromString(json);
+ expect(request, isNull);
+ }
+
+ static void fromJson_invalidMethod() {
Brian Wilkerson 2014/03/05 16:15:16 It would be good to have a test "fromJson_invalidP
danrubel 2014/03/05 18:39:07 Done.
+ String json = '{"id":"one","method":{"boo":"aMethod"},"params":{"foo":"bar"}}';
+ Request request = new Request.fromString(json);
+ expect(request, isNull);
+ }
+
static void fromJson_withParams() {
Request original = new Request('one', 'aMethod');
original.setParameter('foo', 'bar');
« pkg/analysis_server/lib/src/protocol.dart ('K') | « pkg/analysis_server/lib/src/protocol.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698