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

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: address comments (re-upload) 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
« no previous file with comments | « pkg/analysis_server/lib/src/protocol.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2767cc72d1dd51bddac8332c53f0186e5304425e 100644
--- a/pkg/analysis_server/test/protocol_test.dart
+++ b/pkg/analysis_server/test/protocol_test.dart
@@ -22,6 +22,9 @@ 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_invalidParams', RequestTest.fromJson_invalidParams);
test('fromJson_withParams', RequestTest.fromJson_withParams);
test('toJson', RequestTest.toJson);
test('toJson_withParams', RequestTest.toJson_withParams);
@@ -116,6 +119,24 @@ 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() {
+ String json = '{"id":"one","method":{"boo":"aMethod"},"params":{"foo":"bar"}}';
+ Request request = new Request.fromString(json);
+ expect(request, isNull);
+ }
+
+ static void fromJson_invalidParams() {
+ String json = '{"id":"one","method":"aMethod","params":"foobar"}';
+ Request request = new Request.fromString(json);
+ expect(request, isNull);
+ }
+
static void fromJson_withParams() {
Request original = new Request('one', 'aMethod');
original.setParameter('foo', 'bar');
« no previous file with comments | « 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