From 6d416cd6b19f2f93f01eb291bea6a47b808392a9 Mon Sep 17 00:00:00 2001 From: Brennan Date: Thu, 20 Jan 2022 19:46:23 -0800 Subject: [PATCH 1/6] Fix browser cookie tests to only run with HTTPS (#39665) --- .../FunctionalTests/EchoConnectionHandler.cs | 10 - .../ts/FunctionalTests/ts/ConnectionTests.ts | 2 + .../FunctionalTests/ts/HubConnectionTests.ts | 205 +++++++++--------- src/SignalR/clients/ts/signalr/src/Utils.ts | 2 +- 4 files changed, 101 insertions(+), 118 deletions(-) diff --git a/src/SignalR/clients/ts/FunctionalTests/EchoConnectionHandler.cs b/src/SignalR/clients/ts/FunctionalTests/EchoConnectionHandler.cs index d2c0b1df43a9..cfddeaf1a10c 100644 --- a/src/SignalR/clients/ts/FunctionalTests/EchoConnectionHandler.cs +++ b/src/SignalR/clients/ts/FunctionalTests/EchoConnectionHandler.cs @@ -4,21 +4,11 @@ using System.Buffers; using System.Threading.Tasks; using Microsoft.AspNetCore.Connections; -using Microsoft.AspNetCore.Http.Connections; namespace FunctionalTests { public class EchoConnectionHandler : ConnectionHandler { - public override async Task OnConnectedAsync(ConnectionContext connection) - { - var context = connection.GetHttpContext(); - // The 'withCredentials' tests wont send a cookie for cross-site requests - if (!context.WebSockets.IsWebSocketRequest && !context.Request.Cookies.ContainsKey("testCookie")) - { - return; - } - while (true) { var result = await connection.Transport.Input.ReadAsync(); diff --git a/src/SignalR/clients/ts/FunctionalTests/ts/ConnectionTests.ts b/src/SignalR/clients/ts/FunctionalTests/ts/ConnectionTests.ts index 464bc7a92a09..9d2d6bf42357 100644 --- a/src/SignalR/clients/ts/FunctionalTests/ts/ConnectionTests.ts +++ b/src/SignalR/clients/ts/FunctionalTests/ts/ConnectionTests.ts @@ -185,6 +185,8 @@ describe("connection", () => { await connection.start(TransferFormat.Text); + await connection.stop(); + await closePromise; }); } diff --git a/src/SignalR/clients/ts/FunctionalTests/ts/HubConnectionTests.ts b/src/SignalR/clients/ts/FunctionalTests/ts/HubConnectionTests.ts index 4a9032b3afc3..c463fb7096b6 100644 --- a/src/SignalR/clients/ts/FunctionalTests/ts/HubConnectionTests.ts +++ b/src/SignalR/clients/ts/FunctionalTests/ts/HubConnectionTests.ts @@ -40,16 +40,17 @@ function getConnectionBuilder(transportType?: HttpTransportType, url?: string, o describe("hubConnection", () => { eachTransportAndProtocolAndHttpClient((transportType, protocol, httpClient) => { describe("using " + protocol.name + " over " + HttpTransportType[transportType] + " transport", () => { - it("can invoke server method and receive result", async (done) => { + it("can invoke server method and receive result", async () => { const message = "你好,世界!"; const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBeUndefined(); - done(); + closePromise.resolve(); }); await hubConnection.start(); @@ -57,20 +58,21 @@ describe("hubConnection", () => { expect(result).toBe(message); await hubConnection.stop(); - done(); + await closePromise; }); if (shouldRunHttpsTests) { - it("using https, can invoke server method and receive result", async (done) => { + it("using https, can invoke server method and receive result", async () => { const message = "你好,世界!"; const hubConnection = getConnectionBuilder(transportType, TESTHUBENDPOINT_HTTPS_URL, { httpClient }) .withHubProtocol(protocol) .build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBeUndefined(); - done(); + closePromise.resolve(); }); await hubConnection.start(); @@ -78,30 +80,31 @@ describe("hubConnection", () => { expect(result).toBe(message); await hubConnection.stop(); - done(); + await closePromise; }); } - it("can invoke server method non-blocking and not receive result", async (done) => { + it("can invoke server method non-blocking and not receive result", async () => { const message = "你好,世界!"; const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBe(undefined); - done(); + closePromise.resolve(); }); await hubConnection.start(); await hubConnection.send("Echo", message); await hubConnection.stop(); - done(); + await closePromise; }); - it("can invoke server method structural object and receive structural result", async (done) => { + it("can invoke server method structural object and receive structural result", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); @@ -112,23 +115,26 @@ describe("hubConnection", () => { await hubConnection.stop(); }); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBe(undefined); - done(); + closePromise.resolve(); }); await hubConnection.start(); await hubConnection.send("SendCustomObject", { Name: "test", Value: 42 }); + await closePromise; }); - it("can stream server method and receive result", async (done) => { + it("can stream server method and receive result", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBe(undefined); - done(); + closePromise.resolve(); }); const received: string[] = []; @@ -146,16 +152,18 @@ describe("hubConnection", () => { received.push(item); }, }); + await closePromise; }); - it("can stream server method and cancel stream", async (done) => { + it("can stream server method and cancel stream", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBe(undefined); - done(); + closePromise.resolve(); }); hubConnection.on("StreamCanceled", async () => { @@ -175,9 +183,10 @@ describe("hubConnection", () => { }); subscription.dispose(); + await closePromise; }); - it("rethrows an exception from the server when invoking", async (done) => { + it("rethrows an exception from the server when invoking", async () => { const errorMessage = "An unexpected error occurred invoking 'ThrowException' on the server. InvalidOperationException: An error occurred."; const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) @@ -193,10 +202,9 @@ describe("hubConnection", () => { } await hubConnection.stop(); - done(); }); - it("throws an exception when invoking streaming method with invoke", async (done) => { + it("throws an exception when invoking streaming method with invoke", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); @@ -212,10 +220,9 @@ describe("hubConnection", () => { } await hubConnection.stop(); - done(); }); - it("throws an exception when receiving a streaming result for method called with invoke", async (done) => { + it("throws an exception when receiving a streaming result for method called with invoke", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); @@ -231,15 +238,15 @@ describe("hubConnection", () => { } await hubConnection.stop(); - done(); }); - it("rethrows an exception from the server when streaming", async (done) => { + it("rethrows an exception from the server when streaming", async () => { const errorMessage = "An unexpected error occurred invoking 'StreamThrowException' on the server. InvalidOperationException: An error occurred."; const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); + const closePromise = new PromiseSource(); await hubConnection.start(); hubConnection.stream("StreamThrowException", "An error occurred.").subscribe({ async complete() { @@ -249,20 +256,22 @@ describe("hubConnection", () => { async error(err) { expect(err.message).toEqual(errorMessage); await hubConnection.stop(); - done(); + closePromise.resolve(); }, async next() { await hubConnection.stop(); fail(); }, }); + await closePromise; }); - it("throws an exception when invoking hub method with stream", async (done) => { + it("throws an exception when invoking hub method with stream", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); + const closePromise = new PromiseSource(); await hubConnection.start(); hubConnection.stream("Echo", "42").subscribe({ async complete() { @@ -272,16 +281,18 @@ describe("hubConnection", () => { async error(err) { expect(err.message).toEqual("The client attempted to invoke the non-streaming 'Echo' method with a streaming invocation."); await hubConnection.stop(); - done(); + closePromise.resolve(); }, async next() { await hubConnection.stop(); fail(); }, }); + + await closePromise; }); - it("can receive server calls", async (done) => { + it("can receive server calls", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); @@ -305,10 +316,9 @@ describe("hubConnection", () => { expect(receiveMsg).toBe(message); await hubConnection.stop(); - done(); }); - it("can receive server calls without rebinding handler when restarted", async (done) => { + it("can receive server calls without rebinding handler when restarted", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); @@ -323,6 +333,7 @@ describe("hubConnection", () => { let closeCount = 0; let invocationCount = 0; + const closePromise = new PromiseSource(); hubConnection.onclose(async (e) => { expect(e).toBeUndefined(); closeCount += 1; @@ -333,7 +344,7 @@ describe("hubConnection", () => { await hubConnection.stop(); } else { expect(invocationCount).toBe(2); - done(); + closePromise.resolve(); } }); @@ -345,37 +356,41 @@ describe("hubConnection", () => { await hubConnection.start(); await hubConnection.invoke("InvokeWithString", message); await hubConnection.stop(); + await closePromise; }); - it("closed with error or start fails if hub cannot be created", async (done) => { + it("closed with error or start fails if hub cannot be created", async () => { const hubConnection = getConnectionBuilder(transportType, ENDPOINT_BASE_URL + "/uncreatable", { httpClient }) .withHubProtocol(protocol) .build(); const expectedErrorMessage = "Server returned an error on close: Connection closed with an error. InvalidOperationException: Unable to resolve service for type 'System.Object' while attempting to activate 'FunctionalTests.UncreatableHub'."; + const closePromise = new PromiseSource(); // Either start will fail or onclose will be called. Never both. hubConnection.onclose((error) => { expect(error!.message).toEqual(expectedErrorMessage); - done(); + closePromise.resolve(); }); try { await hubConnection.start(); } catch (error) { expect(error!.message).toEqual(expectedErrorMessage); - done(); + closePromise.resolve(); } + await closePromise; }); - it("can handle different types", async (done) => { + it("can handle different types", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBe(undefined); - done(); + closePromise.resolve(); }); const complexObject = { @@ -395,16 +410,18 @@ describe("hubConnection", () => { expect(value).toEqual(complexObject); await hubConnection.stop(); + await closePromise; }); - it("can receive different types", async (done) => { + it("can receive different types", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBe(undefined); - done(); + closePromise.resolve(); }); const complexObject = { @@ -424,9 +441,10 @@ describe("hubConnection", () => { expect(value).toEqual(complexObject); await hubConnection.stop(); + await closePromise; }); - it("can be restarted", async (done) => { + it("can be restarted", async () => { const message = "你好,世界!"; const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) @@ -434,6 +452,7 @@ describe("hubConnection", () => { .build(); let closeCount = 0; + const closePromise = new PromiseSource(); hubConnection.onclose(async (error) => { expect(error).toBe(undefined); @@ -445,7 +464,7 @@ describe("hubConnection", () => { expect(value).toBe(message); await hubConnection.stop(); } else { - done(); + closePromise.resolve(); } }); @@ -454,9 +473,10 @@ describe("hubConnection", () => { expect(result).toBe(message); await hubConnection.stop(); + await closePromise; }); - it("can stream from client to server with rxjs", async (done) => { + it("can stream from client to server with rxjs", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); @@ -470,10 +490,9 @@ describe("hubConnection", () => { subject.complete(); expect(await resultPromise).toBe("Hello world!"); await hubConnection.stop(); - done(); }); - it("can stream from client to server and close with error with rxjs", async (done) => { + it("can stream from client to server and close with error with rxjs", async () => { const hubConnection = getConnectionBuilder(transportType, undefined, { httpClient }) .withHubProtocol(protocol) .build(); @@ -493,7 +512,6 @@ describe("hubConnection", () => { } finally { await hubConnection.stop(); } - done(); }); }); }); @@ -501,7 +519,7 @@ describe("hubConnection", () => { eachTransport((transportType) => { describe("over " + HttpTransportType[transportType] + " transport", () => { - it("can connect to hub with authorization", async (done) => { + it("can connect to hub with authorization", async () => { const message = "你好,世界!"; try { @@ -511,9 +529,10 @@ describe("hubConnection", () => { accessTokenFactory: () => jwtToken, }).build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBe(undefined); - done(); + closePromise.resolve(); }); await hubConnection.start(); const response = await hubConnection.invoke("Echo", message); @@ -522,14 +541,13 @@ describe("hubConnection", () => { await hubConnection.stop(); - done(); + await closePromise; } catch (err) { fail(err); - done(); } }); - it("can connect to hub with authorization using async token factory", async (done) => { + it("can connect to hub with authorization using async token factory", async () => { const message = "你好,世界!"; try { @@ -537,9 +555,10 @@ describe("hubConnection", () => { accessTokenFactory: () => getJwtToken(ENDPOINT_BASE_URL + "/generateJwtToken"), }).build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toBe(undefined); - done(); + closePromise.resolve(); }); await hubConnection.start(); const response = await hubConnection.invoke("Echo", message); @@ -548,20 +567,18 @@ describe("hubConnection", () => { await hubConnection.stop(); - done(); + await closePromise; } catch (err) { fail(err); - done(); } }); - it("can get error from unauthorized hub connection", async (done) => { + it("can get error from unauthorized hub connection", async () => { try { const hubConnection = getConnectionBuilder(transportType, ENDPOINT_BASE_URL + "/authorizedhub").build(); hubConnection.onclose((error) => { expect(error).toBe(undefined); - done(); }); await hubConnection.start(); @@ -569,17 +586,17 @@ describe("hubConnection", () => { fail("shouldn't reach here"); } catch (err) { expect(err).toEqual(new Error("Failed to complete negotiation with the server: Error: Unauthorized: Status code '401'")); - done(); } }); if (transportType !== HttpTransportType.LongPolling) { - it("terminates if no messages received within timeout interval", async (done) => { + it("terminates if no messages received within timeout interval", async () => { const hubConnection = getConnectionBuilder(transportType).build(); + const closePromise = new PromiseSource(); hubConnection.onclose((error) => { expect(error).toEqual(new Error("Server timeout elapsed without receiving a message from the server.")); - done(); + closePromise.resolve(); }); await hubConnection.start(); @@ -589,30 +606,31 @@ describe("hubConnection", () => { // invoke a method with a response to reset the timeout using the new value await hubConnection.invoke("Echo", ""); + await closePromise; }); } - it("preserves cookies between requests", async (done) => { - const hubConnection = getConnectionBuilder(transportType, HTTPORHTTPS_TESTHUBENDPOINT_URL).build(); - await hubConnection.start(); - const cookieValue = await hubConnection.invoke("GetCookie", "testCookie"); - const cookieValue2 = await hubConnection.invoke("GetCookie", "testCookie2"); - expect(cookieValue).toEqual("testValue"); - expect(cookieValue2).toEqual("testValue2"); - await hubConnection.stop(); - done(); - }); + if (shouldRunHttpsTests) { + it("preserves cookies between requests", async () => { + const hubConnection = getConnectionBuilder(transportType, HTTPORHTTPS_TESTHUBENDPOINT_URL).build(); + await hubConnection.start(); + const cookieValue = await hubConnection.invoke("GetCookie", "testCookie"); + const cookieValue2 = await hubConnection.invoke("GetCookie", "testCookie2"); + expect(cookieValue).toEqual("testValue"); + expect(cookieValue2).toEqual("testValue2"); + await hubConnection.stop(); + }); + } - it("expired cookies are not preserved", async (done) => { + it("expired cookies are not preserved", async () => { const hubConnection = getConnectionBuilder(transportType, HTTPORHTTPS_TESTHUBENDPOINT_URL).build(); await hubConnection.start(); const cookieValue = await hubConnection.invoke("GetCookie", "expiredCookie"); expect(cookieValue).toBeNull(); await hubConnection.stop(); - done(); }); - it("can reconnect", async (done) => { + it("can reconnect", async () => { try { const reconnectingPromise = new PromiseSource(); const reconnectedPromise = new PromiseSource(); @@ -645,16 +663,13 @@ describe("hubConnection", () => { expect(response).toEqual("test"); await hubConnection.stop(); - - done(); } catch (err) { fail(err); - done(); } }); }); - it("can change url in reconnecting state", async (done) => { + it("can change url in reconnecting state", async () => { try { const reconnectingPromise = new PromiseSource(); const hubConnection = getConnectionBuilder(transportType) @@ -676,16 +691,13 @@ describe("hubConnection", () => { expect(hubConnection.baseUrl).toBe("http://example123.com"); await hubConnection.stop(); - - done(); } catch (err) { fail(err); - done(); } }); }); - it("can reconnect after negotiate redirect", async (done) => { + it("can reconnect after negotiate redirect", async () => { try { const reconnectingPromise = new PromiseSource(); const reconnectedPromise = new PromiseSource(); @@ -723,15 +735,12 @@ describe("hubConnection", () => { expect(postReconnectRedirects).toBeGreaterThan(preReconnectRedirects); await hubConnection.stop(); - - done(); } catch (err) { fail(err); - done(); } }); - it("can reconnect after skipping negotiation", async (done) => { + it("can reconnect after skipping negotiation", async () => { try { const reconnectingPromise = new PromiseSource(); const reconnectedPromise = new PromiseSource(); @@ -766,15 +775,12 @@ describe("hubConnection", () => { expect(response).toEqual("test"); await hubConnection.stop(); - - done(); } catch (err) { fail(err); - done(); } }); - it("connection id matches server side connection id", async (done) => { + it("connection id matches server side connection id", async () => { try { const reconnectingPromise = new PromiseSource(); const reconnectedPromise = new PromiseSource(); @@ -813,15 +819,12 @@ describe("hubConnection", () => { await hubConnection.stop(); expect(hubConnection.connectionId).toBeNull(); - - done(); } catch (err) { fail(err); - done(); } }); - it("connection id is alwys null is negotiation is skipped", async (done) => { + it("connection id is alwys null is negotiation is skipped", async () => { try { const hubConnection = getConnectionBuilder( HttpTransportType.WebSockets, @@ -839,16 +842,13 @@ describe("hubConnection", () => { await hubConnection.stop(); expect(hubConnection.connectionId).toBeNull(); - - done(); } catch (err) { fail(err); - done(); } }); if (typeof EventSource !== "undefined") { - it("allows Server-Sent Events when negotiating for JSON protocol", async (done) => { + it("allows Server-Sent Events when negotiating for JSON protocol", async () => { const hubConnection = getConnectionBuilder(undefined, TESTHUB_NOWEBSOCKETS_ENDPOINT_URL) .withHubProtocol(new JsonHubProtocol()) .build(); @@ -860,14 +860,13 @@ describe("hubConnection", () => { expect(await hubConnection.invoke("GetActiveTransportName")).toEqual("ServerSentEvents"); await hubConnection.stop(); - done(); } catch (e) { fail(e); } }); } - it("skips Server-Sent Events when negotiating for MessagePack protocol", async (done) => { + it("skips Server-Sent Events when negotiating for MessagePack protocol", async () => { const hubConnection = getConnectionBuilder(undefined, TESTHUB_NOWEBSOCKETS_ENDPOINT_URL) .withHubProtocol(new MessagePackHubProtocol()) .build(); @@ -879,16 +878,14 @@ describe("hubConnection", () => { expect(await hubConnection.invoke("GetActiveTransportName")).toEqual("LongPolling"); await hubConnection.stop(); - done(); } catch (e) { fail(e); } }); - it("transport falls back from WebSockets to SSE or LongPolling", async (done) => { + it("transport falls back from WebSockets to SSE or LongPolling", async () => { // Skip test on Node as there will always be a WebSockets implementation on Node if (typeof window === "undefined") { - done(); return; } @@ -914,11 +911,10 @@ describe("hubConnection", () => { fail(e); } finally { (window as any).WebSocket = oldWebSocket; - done(); } }); - it("over LongPolling it sends DELETE request and waits for poll to terminate", async (done) => { + it("over LongPolling it sends DELETE request and waits for poll to terminate", async () => { // Create an HTTP client to capture the poll const defaultClient = new DefaultHttpClient(TestLogger.instance); @@ -966,14 +962,12 @@ describe("hubConnection", () => { } catch (e) { fail(e); } finally { - done(); } }); - it("populates the Content-Type header when sending XMLHttpRequest", async (done) => { + it("populates the Content-Type header when sending XMLHttpRequest", async () => { // Skip test on Node as this header isn't set (it was added for React-Native) if (typeof window === "undefined") { - done(); return; } const hubConnection = getConnectionBuilder(HttpTransportType.LongPolling, TESTHUB_NOWEBSOCKETS_ENDPOINT_URL) @@ -989,14 +983,13 @@ describe("hubConnection", () => { expect(await hubConnection.invoke("GetContentTypeHeader")).toEqual("text/plain;charset=UTF-8"); await hubConnection.stop(); - done(); } catch (e) { fail(e); } }); eachTransport((t) => { - it("sets the user agent header", async (done) => { + it("sets the user agent header", async () => { const hubConnection = getConnectionBuilder(t, TESTHUBENDPOINT_URL) .withHubProtocol(new JsonHubProtocol()) .build(); @@ -1015,13 +1008,12 @@ describe("hubConnection", () => { } await hubConnection.stop(); - done(); } catch (e) { fail(e); } }); - it("overwrites library headers with user headers", async (done) => { + it("overwrites library headers with user headers", async () => { const [name] = getUserAgentHeader(); const headers = { [name]: "Custom Agent", "X-HEADER": "VALUE" }; const hubConnection = getConnectionBuilder(t, TESTHUBENDPOINT_URL, { headers }) @@ -1043,7 +1035,6 @@ describe("hubConnection", () => { } await hubConnection.stop(); - done(); } catch (e) { fail(e); } diff --git a/src/SignalR/clients/ts/signalr/src/Utils.ts b/src/SignalR/clients/ts/signalr/src/Utils.ts index 90eb0cc59ced..c5d19bfa9105 100644 --- a/src/SignalR/clients/ts/signalr/src/Utils.ts +++ b/src/SignalR/clients/ts/signalr/src/Utils.ts @@ -288,7 +288,7 @@ export function getErrorString(e: any): string { } /** @private */ -export function getGlobalThis() { +export function getGlobalThis(): unknown { // globalThis is semi-new and not available in Node until v12 if (typeof globalThis !== "undefined") { return globalThis; From 682a67fc848870350381bdb3f7136b976238809e Mon Sep 17 00:00:00 2001 From: Brennan Date: Fri, 21 Jan 2022 10:27:39 -0800 Subject: [PATCH 2/6] fixup --- src/SignalR/clients/ts/FunctionalTests/EchoConnectionHandler.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SignalR/clients/ts/FunctionalTests/EchoConnectionHandler.cs b/src/SignalR/clients/ts/FunctionalTests/EchoConnectionHandler.cs index cfddeaf1a10c..e58bbc9d9339 100644 --- a/src/SignalR/clients/ts/FunctionalTests/EchoConnectionHandler.cs +++ b/src/SignalR/clients/ts/FunctionalTests/EchoConnectionHandler.cs @@ -9,6 +9,8 @@ namespace FunctionalTests { public class EchoConnectionHandler : ConnectionHandler { + public override async Task OnConnectedAsync(ConnectionContext connection) + { while (true) { var result = await connection.Transport.Input.ReadAsync(); From fd5e19523b07fad2319fb78909f60e92b439a454 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 20 Jan 2022 17:56:51 -0800 Subject: [PATCH 3/6] Skip failing cert tests for now --- src/Security/Authentication/test/CertificateTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Security/Authentication/test/CertificateTests.cs b/src/Security/Authentication/test/CertificateTests.cs index e25bbafcd8f3..911063d3a24e 100644 --- a/src/Security/Authentication/test/CertificateTests.cs +++ b/src/Security/Authentication/test/CertificateTests.cs @@ -330,7 +330,7 @@ public async Task VerifyClientCertWithUntrustedRootAndTrustedChainEndsUpInForbid Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); } - [Fact] + [Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/39669")] public async Task VerifyValidClientCertWithTrustedChainAuthenticates() { using var host = await CreateHost( @@ -347,7 +347,7 @@ public async Task VerifyValidClientCertWithTrustedChainAuthenticates() Assert.Equal(HttpStatusCode.OK, response.StatusCode); } - [Fact] + [Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/39669")] public async Task VerifyValidClientCertWithAdditionalCertificatesAuthenticates() { using var host = await CreateHost( From 870222c130727d2d4ed2d930d98266828e8e2e9a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 21 Jan 2022 14:05:37 -0800 Subject: [PATCH 4/6] Fix spacing --- src/Security/Authentication/test/CertificateTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Security/Authentication/test/CertificateTests.cs b/src/Security/Authentication/test/CertificateTests.cs index 911063d3a24e..25c982a7c61f 100644 --- a/src/Security/Authentication/test/CertificateTests.cs +++ b/src/Security/Authentication/test/CertificateTests.cs @@ -330,7 +330,7 @@ public async Task VerifyClientCertWithUntrustedRootAndTrustedChainEndsUpInForbid Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); } - [Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/39669")] + [Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/39669")] public async Task VerifyValidClientCertWithTrustedChainAuthenticates() { using var host = await CreateHost( @@ -347,7 +347,7 @@ public async Task VerifyValidClientCertWithTrustedChainAuthenticates() Assert.Equal(HttpStatusCode.OK, response.StatusCode); } - [Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/39669")] + [Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/39669")] public async Task VerifyValidClientCertWithAdditionalCertificatesAuthenticates() { using var host = await CreateHost( From caccac1287e83770f8ddfb43019bb2657a956dfc Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Sun, 16 Jan 2022 22:55:10 -0800 Subject: [PATCH 5/6] [release/6.0] Always build App.Ref and the targeting packs - remove `$(IsTargetingPackBuilding)` entirely - 6.0.x version of #39568 --- Directory.Build.props | 6 --- Directory.Build.targets | 1 - eng/Versions.props | 2 - eng/targets/ResolveReferences.targets | 6 +-- ...crosoft.AspNetCore.App.Ref.Internal.csproj | 1 - .../src/Microsoft.AspNetCore.App.Ref.csproj | 7 +--- .../Microsoft.AspNetCore.App.UnitTests.csproj | 18 ++------ src/Framework/test/TargetingPackTests.cs | 41 +------------------ src/Installers/Debian/Directory.Build.targets | 2 +- .../Debian.TargetingPack.debproj | 3 -- src/Installers/Rpm/Directory.Build.targets | 2 +- .../TargetingPack/Rpm.TargetingPack.rpmproj | 3 -- .../TargetingPack/TargetingPack.wixproj | 7 +--- src/SiteExtensions/LoggingBranch/LB.csproj | 12 ++---- 14 files changed, 15 insertions(+), 96 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 26dd4d70ad13..8f0ac5942284 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -141,11 +141,6 @@ aspnetcore-runtime aspnetcore-targeting-pack - - false - true - $(VersionPrefix) - - $(AspNetCoreMajorMinorVersion).2 0.3.$(AspNetCorePatchVersion) $([MSBuild]::Add(10, $(AspNetCoreMajorVersion))) diff --git a/eng/targets/ResolveReferences.targets b/eng/targets/ResolveReferences.targets index 895e1c09f5db..fcdb6f6e624d 100644 --- a/eng/targets/ResolveReferences.targets +++ b/eng/targets/ResolveReferences.targets @@ -234,8 +234,7 @@ --> + ($(_CompileTfmUsingReferenceAssemblies) OR '$(MSBuildProjectName)' == 'Microsoft.AspNetCore.App.Ref') "> + ($(_CompileTfmUsingReferenceAssemblies) OR '$(MSBuildProjectName)' == 'Microsoft.AspNetCore.App.Ref') "> false $(TargetingPackName).Internal $(TargetingPackVersionPrefix) false diff --git a/src/Framework/App.Ref/src/Microsoft.AspNetCore.App.Ref.csproj b/src/Framework/App.Ref/src/Microsoft.AspNetCore.App.Ref.csproj index 8fcf855cba4e..07d568ff72e3 100644 --- a/src/Framework/App.Ref/src/Microsoft.AspNetCore.App.Ref.csproj +++ b/src/Framework/App.Ref/src/Microsoft.AspNetCore.App.Ref.csproj @@ -4,7 +4,6 @@ $(DefaultNetCoreTargetFramework) true - false $(TargetingPackName) $(TargetingPackVersionPrefix) @@ -92,8 +91,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant - - + $(BuildDependsOn); _ResolveTargetingPackContent; GeneratePackageOverrides; @@ -102,9 +100,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant _InstallTargetingPackIntoLocalDotNet; _CreateTargetingPackArchive; - - - diff --git a/src/Framework/test/Microsoft.AspNetCore.App.UnitTests.csproj b/src/Framework/test/Microsoft.AspNetCore.App.UnitTests.csproj index 08d31fb48197..e07093d1837f 100644 --- a/src/Framework/test/Microsoft.AspNetCore.App.UnitTests.csproj +++ b/src/Framework/test/Microsoft.AspNetCore.App.UnitTests.csproj @@ -55,10 +55,6 @@ <_Parameter1>TargetingPackLayoutRoot <_Parameter2>$(TargetingPackLayoutRoot) - - <_Parameter1>IsTargetingPackBuilding - <_Parameter2>$(IsTargetingPackBuilding) - <_Parameter1>VerifyAncmBinary <_Parameter2>$(VerifyAncmBinary) @@ -71,16 +67,10 @@ - - false - true - - - false - true - + diff --git a/src/Framework/test/TargetingPackTests.cs b/src/Framework/test/TargetingPackTests.cs index 4d61b765af67..9b0cc9a744a0 100644 --- a/src/Framework/test/TargetingPackTests.cs +++ b/src/Framework/test/TargetingPackTests.cs @@ -23,7 +23,6 @@ public class TargetingPackTests private readonly string _targetingPackTfm; private readonly string _targetingPackRoot; private readonly ITestOutputHelper _output; - private readonly bool _isTargetingPackBuilding; public TargetingPackTests(ITestOutputHelper output) { @@ -38,17 +37,11 @@ public TargetingPackTests(ITestOutputHelper output) "packs", "Microsoft.AspNetCore.App.Ref", TestData.GetTestDataValue("TargetingPackVersion")); - _isTargetingPackBuilding = bool.Parse(TestData.GetTestDataValue("IsTargetingPackBuilding")); } [Fact] public void TargetingPackContainsListedAssemblies() { - if (!_isTargetingPackBuilding) - { - return; - } - var actualAssemblies = Directory.GetFiles(Path.Combine(_targetingPackRoot, "ref", _targetingPackTfm), "*.dll") .Select(Path.GetFileNameWithoutExtension) .ToHashSet(); @@ -74,11 +67,6 @@ public void TargetingPackContainsListedAssemblies() [Fact] public void RefAssembliesHaveExpectedAssemblyVersions() { - if (!_isTargetingPackBuilding) - { - return; - } - IEnumerable dlls = Directory.GetFiles(Path.Combine(_targetingPackRoot, "ref", _targetingPackTfm), "*.dll", SearchOption.AllDirectories); Assert.NotEmpty(dlls); @@ -99,11 +87,6 @@ public void RefAssembliesHaveExpectedAssemblyVersions() [Fact] public void RefAssemblyReferencesHaveExpectedAssemblyVersions() { - if (!_isTargetingPackBuilding) - { - return; - } - IEnumerable dlls = Directory.GetFiles(Path.Combine(_targetingPackRoot, "ref", _targetingPackTfm), "*.dll", SearchOption.AllDirectories); Assert.NotEmpty(dlls); @@ -126,11 +109,6 @@ public void RefAssemblyReferencesHaveExpectedAssemblyVersions() [Fact] public void PackageOverridesContainsCorrectEntries() { - if (!_isTargetingPackBuilding) - { - return; - } - var packageOverridePath = Path.Combine(_targetingPackRoot, "data", "PackageOverrides.txt"); AssertEx.FileExists(packageOverridePath); @@ -190,11 +168,6 @@ public void PackageOverridesContainsCorrectEntries() [Fact] public void AssembliesAreReferenceAssemblies() { - if (!_isTargetingPackBuilding) - { - return; - } - IEnumerable dlls = Directory.GetFiles(Path.Combine(_targetingPackRoot, "ref"), "*.dll", SearchOption.AllDirectories); Assert.NotEmpty(dlls); @@ -222,11 +195,6 @@ public void AssembliesAreReferenceAssemblies() [Fact] public void PlatformManifestListsAllFiles() { - if (!_isTargetingPackBuilding) - { - return; - } - var platformManifestPath = Path.Combine(_targetingPackRoot, "data", "PlatformManifest.txt"); var expectedAssemblies = TestData.GetSharedFxDependencies() .Split(';', StringSplitOptions.RemoveEmptyEntries) @@ -292,11 +260,6 @@ public void PlatformManifestListsAllFiles() [Fact] public void FrameworkListListsContainsCorrectEntries() { - if (!_isTargetingPackBuilding) - { - return; - } - var frameworkListPath = Path.Combine(_targetingPackRoot, "data", "FrameworkList.xml"); var expectedAssemblies = TestData.GetTargetingPackDependencies() .Split(';', StringSplitOptions.RemoveEmptyEntries) @@ -364,7 +327,7 @@ void CompareFrameworkElements(HashSet expectedAssemblyNames, IEnumerable [Fact] public void FrameworkListListsContainsCorrectPaths() { - if (!_isTargetingPackBuilding || string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix"))) + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix"))) { return; } @@ -406,7 +369,7 @@ public void FrameworkListListsContainsCorrectPaths() [Fact] public void FrameworkListListsContainsAnalyzerLanguage() { - if (!_isTargetingPackBuilding || string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix"))) + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix"))) { return; } diff --git a/src/Installers/Debian/Directory.Build.targets b/src/Installers/Debian/Directory.Build.targets index 84554cd0c383..6b46efd25844 100644 --- a/src/Installers/Debian/Directory.Build.targets +++ b/src/Installers/Debian/Directory.Build.targets @@ -28,7 +28,7 @@ + Condition=" '$(MSBuildProjectName)' != 'Debian.TargetingPack' "> diff --git a/src/Installers/Debian/TargetingPack/Debian.TargetingPack.debproj b/src/Installers/Debian/TargetingPack/Debian.TargetingPack.debproj index a8da4cc11c54..6966845de3a6 100644 --- a/src/Installers/Debian/TargetingPack/Debian.TargetingPack.debproj +++ b/src/Installers/Debian/TargetingPack/Debian.TargetingPack.debproj @@ -44,9 +44,6 @@ $(DebPackageVersion)~$(VersionSuffix) 1 - - - diff --git a/src/Installers/Rpm/Directory.Build.targets b/src/Installers/Rpm/Directory.Build.targets index cc13e2801dd9..906b2cd30dea 100644 --- a/src/Installers/Rpm/Directory.Build.targets +++ b/src/Installers/Rpm/Directory.Build.targets @@ -37,7 +37,7 @@ + Condition=" '$(MSBuildProjectName)' != 'Rpm.TargetingPack' "> DATE=$([System.DateTime]::UtcNow.ToString(ddd MMM dd yyyy)) diff --git a/src/Installers/Rpm/TargetingPack/Rpm.TargetingPack.rpmproj b/src/Installers/Rpm/TargetingPack/Rpm.TargetingPack.rpmproj index bca9ffc763bb..190fc8ccf5c1 100644 --- a/src/Installers/Rpm/TargetingPack/Rpm.TargetingPack.rpmproj +++ b/src/Installers/Rpm/TargetingPack/Rpm.TargetingPack.rpmproj @@ -39,8 +39,5 @@ 1 0.1.$(VersionSuffix.Replace('-', '_')) - - - diff --git a/src/Installers/Windows/TargetingPack/TargetingPack.wixproj b/src/Installers/Windows/TargetingPack/TargetingPack.wixproj index 610d68da3d43..27894df71808 100644 --- a/src/Installers/Windows/TargetingPack/TargetingPack.wixproj +++ b/src/Installers/Windows/TargetingPack/TargetingPack.wixproj @@ -10,7 +10,6 @@ Package targeting_pack_$(Platform).cab true - true 0AC34F1B-8056-4FFB-A398-E6BB7D67B48D true 5150;5151 @@ -79,13 +78,9 @@ Microsoft ASP.NET Core $(PackageBrandingVersion) Targeting Pack ($(Platform)) $(OutputName)$(TargetExt) $(DefineConstants);ProductName=$(ProductName) - - - - + $(InstallersOutputPath)$(PackageFileName) diff --git a/src/SiteExtensions/LoggingBranch/LB.csproj b/src/SiteExtensions/LoggingBranch/LB.csproj index fb4097ceab60..2cffb0864a7c 100644 --- a/src/SiteExtensions/LoggingBranch/LB.csproj +++ b/src/SiteExtensions/LoggingBranch/LB.csproj @@ -25,15 +25,9 @@ - false - true - - - false - true - + Private="false" + ReferenceOutputAssembly="false" + SkipGetTargetFrameworkProperties="true" /> From f1cb9ec5f3e823eacaa4c9d86b6f07f8c2fdd1cb Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Wed, 19 Jan 2022 21:21:15 -0800 Subject: [PATCH 6/6] Unconditionally enable `DebBuild` and `RpmBuild` - address a build issue mentioned in dotnet/aspnetcore-internal#3988 - I accidentally disabled these targets for targeting packs in 08968dd0d6ab --- src/Installers/Debian/Directory.Build.targets | 3 +-- src/Installers/Rpm/Directory.Build.targets | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Installers/Debian/Directory.Build.targets b/src/Installers/Debian/Directory.Build.targets index 6b46efd25844..2d854470f156 100644 --- a/src/Installers/Debian/Directory.Build.targets +++ b/src/Installers/Debian/Directory.Build.targets @@ -27,8 +27,7 @@ - + diff --git a/src/Installers/Rpm/Directory.Build.targets b/src/Installers/Rpm/Directory.Build.targets index 906b2cd30dea..4bd792c1848f 100644 --- a/src/Installers/Rpm/Directory.Build.targets +++ b/src/Installers/Rpm/Directory.Build.targets @@ -36,8 +36,7 @@ - + DATE=$([System.DateTime]::UtcNow.ToString(ddd MMM dd yyyy))