Skip to content

Commit f98933c

Browse files
authored
Fix to ignore unknown methods (#791)
1 parent af93d32 commit f98933c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Grpc.AspNetCore.Server/Internal/ServerCallHandlerFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public RequestDelegate CreateUnimplementedMethod()
113113
}
114114

115115
public bool IgnoreUnknownServices => _globalOptions.IgnoreUnknownServices ?? false;
116-
public bool IgnoreUnknownMethods => _serviceOptions.IgnoreUnknownServices ?? false;
116+
public bool IgnoreUnknownMethods => _serviceOptions.IgnoreUnknownServices ?? _globalOptions.IgnoreUnknownServices ?? false;
117117

118118
public RequestDelegate CreateUnimplementedService()
119119
{

test/Grpc.AspNetCore.Server.Tests/GrpcEndpointRouteBuilderExtensionsTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ public void MapGrpcService_IgnoreUnknownServicesGlobalTrue_DontRegisterUnknownHa
333333
.ToList();
334334

335335
Assert.IsNull(endpoints.SingleOrDefault(e => e.DisplayName == "gRPC - Unimplemented service"));
336-
Assert.IsNull(endpoints.SingleOrDefault(e => e.DisplayName == "gRPC - Unimplemented method for GreeterServiceWithMetadataAttributes"));
336+
Assert.IsNull(endpoints.SingleOrDefault(e => e.DisplayName == "gRPC - Unimplemented method for greet.Greeter"));
337+
338+
Assert.AreEqual(0, endpoints.Count(e => e.Metadata.GetMetadata<GrpcMethodMetadata>() == null));
337339
}
338340

339341
[Test]

0 commit comments

Comments
 (0)