Skip to content

Commit f01df42

Browse files
authored
Update interop tests to use modern package lock file (#1615)
1 parent 7057da7 commit f01df42

File tree

4 files changed

+5264
-750
lines changed

4 files changed

+5264
-750
lines changed

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,33 +80,35 @@ protected override string PeerCore
8080
// Follows the standard at https://github.com/grpc/grpc/blob/master/doc/naming.md
8181
if (_peer == null)
8282
{
83-
var connection = HttpContext.Connection;
84-
if (connection.RemoteIpAddress != null)
85-
{
86-
switch (connection.RemoteIpAddress.AddressFamily)
87-
{
88-
case AddressFamily.InterNetwork:
89-
_peer = "ipv4:" + connection.RemoteIpAddress + ":" + connection.RemotePort;
90-
break;
91-
case AddressFamily.InterNetworkV6:
92-
_peer = "ipv6:[" + connection.RemoteIpAddress + "]:" + connection.RemotePort;
93-
break;
94-
default:
95-
// TODO(JamesNK) - Test what should be output when used with UDS and named pipes
96-
_peer = "unknown:" + connection.RemoteIpAddress + ":" + connection.RemotePort;
97-
break;
98-
}
99-
}
100-
else
101-
{
102-
_peer = "unknown"; // Match Grpc.Core
103-
}
83+
_peer = BuildPeer();
10484
}
10585

10686
return _peer;
10787
}
10888
}
10989

90+
private string BuildPeer()
91+
{
92+
var connection = HttpContext.Connection;
93+
if (connection.RemoteIpAddress != null)
94+
{
95+
switch (connection.RemoteIpAddress.AddressFamily)
96+
{
97+
case AddressFamily.InterNetwork:
98+
return $"ipv4:{connection.RemoteIpAddress}:{connection.RemotePort}";
99+
case AddressFamily.InterNetworkV6:
100+
return $"ipv6:[{connection.RemoteIpAddress}]:{connection.RemotePort}";
101+
default:
102+
// TODO(JamesNK) - Test what should be output when used with UDS and named pipes
103+
return $"unknown:{connection.RemoteIpAddress}:{connection.RemotePort}";
104+
}
105+
}
106+
else
107+
{
108+
return "unknown"; // Match Grpc.Core
109+
}
110+
}
111+
110112
protected override DateTime DeadlineCore => DeadlineManager?.Deadline ?? DateTime.MaxValue;
111113

112114
protected override Metadata RequestHeadersCore

testassets/InteropTestsGrpcWebWebsite/Tests/custom-environment.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
// custom-environment.js
1+
// For some reason the expect-puppeteer require is returning a module rather than the function.
2+
// Helper function unwraps the module and returns the inner function.
3+
function _interopDefault(ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4+
25
const PuppeteerEnvironment = require('jest-environment-puppeteer');
3-
const expect = require('expect-puppeteer');
6+
const expect = _interopDefault(require('expect-puppeteer'));
47

58
class CustomEnvironment extends PuppeteerEnvironment {
69
// Load page and get test names to run

0 commit comments

Comments
 (0)