JSON conformance test fixes
- Spot an Any without a type URL - In the conformance test runner, catch exceptions due to generally-invalid JSON
This commit is contained in:
parent
73c003c309
commit
f2fe50bfc5
@ -101,6 +101,10 @@ namespace Google.Protobuf.Conformance
|
||||
{
|
||||
return new ConformanceResponse { ParseError = e.Message };
|
||||
}
|
||||
catch (InvalidJsonException e)
|
||||
{
|
||||
return new ConformanceResponse { ParseError = e.Message };
|
||||
}
|
||||
switch (request.RequestedOutputFormat)
|
||||
{
|
||||
case global::Conformance.WireFormat.JSON:
|
||||
|
@ -762,6 +762,13 @@ namespace Google.Protobuf
|
||||
Assert.Throws<InvalidOperationException>(() => Any.Parser.ParseJson(json));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Any_NoTypeUrl()
|
||||
{
|
||||
string json = "{ \"foo\": \"bar\" }";
|
||||
Assert.Throws<InvalidProtocolBufferException>(() => Any.Parser.ParseJson(json));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Any_WellKnownType()
|
||||
{
|
||||
|
@ -464,6 +464,11 @@ namespace Google.Protobuf
|
||||
{
|
||||
tokens.Add(token);
|
||||
token = tokenizer.Next();
|
||||
|
||||
if (tokenizer.ObjectDepth < typeUrlObjectDepth)
|
||||
{
|
||||
throw new InvalidProtocolBufferException("Any message with no @type");
|
||||
}
|
||||
}
|
||||
|
||||
// Don't add the @type property or its value to the recorded token list
|
||||
|
Loading…
Reference in New Issue
Block a user