Merge pull request #2850 from dotnet-maestro-bot/merge/release/2.2-to-master
[automated] Merge branch 'release/2.2' => 'master'
This commit is contained in:
commit
9d4c76c173
File diff suppressed because it is too large
Load Diff
|
|
@ -11,19 +11,20 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/debug": "0.0.30",
|
"@types/debug": "0.0.30",
|
||||||
"@types/jasmine": "^2.8.6",
|
"@types/jasmine": "^2.8.8",
|
||||||
"@types/karma": "^1.7.3",
|
"@types/karma": "^1.7.5",
|
||||||
"@types/node": "^9.4.6",
|
"@types/node": "^9.6.28",
|
||||||
"debug": "^3.1.0",
|
"debug": "^3.1.0",
|
||||||
"es6-promise": "^4.2.2",
|
"es6-promise": "^4.2.4",
|
||||||
"jasmine": "^3.1.0",
|
"jasmine": "^3.2.0",
|
||||||
"jasmine-core": "^3.1.0",
|
"jasmine-core": "^3.2.1",
|
||||||
"karma": "^2.0.4",
|
"karma": "^3.0.0",
|
||||||
"karma-chrome-launcher": "^2.2.0",
|
"karma-chrome-launcher": "^2.2.0",
|
||||||
"karma-edge-launcher": "^0.4.2",
|
"karma-edge-launcher": "^0.4.2",
|
||||||
"karma-firefox-launcher": "^1.1.0",
|
"karma-firefox-launcher": "^1.1.0",
|
||||||
"karma-ie-launcher": "^1.0.0",
|
"karma-ie-launcher": "^1.0.0",
|
||||||
"karma-jasmine": "^1.1.2",
|
"karma-jasmine": "^1.1.2",
|
||||||
|
"karma-junit-reporter": "^1.2.0",
|
||||||
"karma-mocha-reporter": "^2.2.5",
|
"karma-mocha-reporter": "^2.2.5",
|
||||||
"karma-safari-launcher": "^1.0.0",
|
"karma-safari-launcher": "^1.0.0",
|
||||||
"karma-sauce-launcher": "^1.2.0",
|
"karma-sauce-launcher": "^1.2.0",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
try {
|
try {
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
let defaultReporters = ["progress", "summary"];
|
let defaultReporters = ["progress", "summary", "junit"];
|
||||||
|
|
||||||
/** Creates the Karma config function based on the provided options
|
/** Creates the Karma config function based on the provided options
|
||||||
*
|
*
|
||||||
|
|
@ -45,6 +45,11 @@ try {
|
||||||
|
|
||||||
// Apply the default reporters along with whatever was passed in
|
// Apply the default reporters along with whatever was passed in
|
||||||
reporters: [...defaultReporters, ...(config.reporters || [])],
|
reporters: [...defaultReporters, ...(config.reporters || [])],
|
||||||
|
|
||||||
|
junitReporter: {
|
||||||
|
outputDir: "../../../artifacts/logs",
|
||||||
|
outputFile: `${process.platform}` + ".functionaltest.junit.xml",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ try {
|
||||||
base: 'ChromeHeadless',
|
base: 'ChromeHeadless',
|
||||||
flags: ['--no-sandbox']
|
flags: ['--no-sandbox']
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
|
||||||
|
|
@ -4144,6 +4144,48 @@
|
||||||
"source-map-support": "^0.5.0"
|
"source-map-support": "^0.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"jest-junit": {
|
||||||
|
"version": "5.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-5.1.0.tgz",
|
||||||
|
"integrity": "sha512-3EVf1puv2ox5wybQDfLX3AEn3IKOgDV4E76y4pO2hBu46DEtAFZZAm//X1pzPQpqKji0zqgMIzqzF/K+uGAX9A==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"jest-validate": "^23.0.1",
|
||||||
|
"mkdirp": "^0.5.1",
|
||||||
|
"strip-ansi": "^4.0.0",
|
||||||
|
"xml": "^1.0.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-regex": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"jest-validate": {
|
||||||
|
"version": "23.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-23.5.0.tgz",
|
||||||
|
"integrity": "sha512-XmStdYhfdiDKacXX5sNqEE61Zz4/yXaPcDsKvVA0429RBu2pkQyIltCVG7UitJIEAzSs3ociQTdyseAW8VGPiA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"chalk": "^2.0.1",
|
||||||
|
"jest-get-type": "^22.1.0",
|
||||||
|
"leven": "^2.1.0",
|
||||||
|
"pretty-format": "^23.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pretty-format": {
|
||||||
|
"version": "23.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-23.5.0.tgz",
|
||||||
|
"integrity": "sha512-iFLvYTXOn+C/s7eV+pr4E8DD7lYa2/klXMEz+lvH14qSDWAJ7S+kFmMe1SIWesATHQxopHTxRcB2nrpExhzaBA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ansi-regex": "^3.0.0",
|
||||||
|
"ansi-styles": "^3.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"jest-leak-detector": {
|
"jest-leak-detector": {
|
||||||
"version": "22.4.3",
|
"version": "22.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-22.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-22.4.3.tgz",
|
||||||
|
|
@ -8639,6 +8681,12 @@
|
||||||
"async-limiter": "~1.0.0"
|
"async-limiter": "~1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"xml": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz",
|
||||||
|
"integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"xml-name-validator": {
|
"xml-name-validator": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
"@types/node": "^8.5.2",
|
"@types/node": "^8.5.2",
|
||||||
"@types/webpack": "^4.4.0",
|
"@types/webpack": "^4.4.0",
|
||||||
"jest": "^22.4.3",
|
"jest": "^22.4.3",
|
||||||
|
"jest-junit": "^5.1.0",
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"ts-jest": "^22.4.6",
|
"ts-jest": "^22.4.6",
|
||||||
"ts-loader": "^4.4.1",
|
"ts-loader": "^4.4.1",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
globals: {
|
||||||
|
"ts-jest": {
|
||||||
|
"tsConfigFile": "./tsconfig.jest.json",
|
||||||
|
"skipBabel": true,
|
||||||
|
"enableTsDiagnostics": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
reporters: [
|
||||||
|
"default",
|
||||||
|
["./common/node_modules/jest-junit/index.js", { "output": "../../artifacts/logs/" + `${process.platform}` + ".signalr.junit.xml" }]
|
||||||
|
],
|
||||||
|
transform: {
|
||||||
|
"^.+\\.tsx?$": "./common/node_modules/ts-jest"
|
||||||
|
},
|
||||||
|
testEnvironment: "node",
|
||||||
|
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
||||||
|
moduleNameMapper: {
|
||||||
|
"^ts-jest$": "<rootDir>/common/node_modules/ts-jest",
|
||||||
|
"^@aspnet/signalr$": "<rootDir>/signalr/dist/cjs/index.js"
|
||||||
|
},
|
||||||
|
moduleFileExtensions: [
|
||||||
|
"ts",
|
||||||
|
"tsx",
|
||||||
|
"js",
|
||||||
|
"jsx",
|
||||||
|
"json",
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
@ -6,35 +6,9 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cd ./signalr && npm run build && cd ../signalr-protocol-msgpack && npm run build",
|
"build": "cd ./signalr && npm run build && cd ../signalr-protocol-msgpack && npm run build",
|
||||||
"pretest": "node ./common/node_modules/tslint/bin/tslint -c ./tslint.json -p ./signalr/tests/tsconfig.json && node ./common/node_modules/tslint/bin/tslint -c ./tslint.json -p ./signalr-protocol-msgpack/tests/tsconfig.json",
|
"pretest": "node ./common/node_modules/tslint/bin/tslint -c ./tslint.json -p ./signalr/tests/tsconfig.json && node ./common/node_modules/tslint/bin/tslint -c ./tslint.json -p ./signalr-protocol-msgpack/tests/tsconfig.json",
|
||||||
"test": "node ./common/node_modules/jest/bin/jest.js",
|
"test": "node ./common/node_modules/jest/bin/jest.js --config ./jest.config.js",
|
||||||
"coverage": "node ./common/node_modules/jest/bin/jest.js --coverage"
|
"coverage": "node ./common/node_modules/jest/bin/jest.js --config ./jest.config.js --coverage"
|
||||||
},
|
},
|
||||||
"author": "Microsoft",
|
"author": "Microsoft",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0"
|
||||||
"jest": {
|
|
||||||
"globals": {
|
|
||||||
"ts-jest": {
|
|
||||||
"tsConfigFile": "./tsconfig.jest.json",
|
|
||||||
"skipBabel": true,
|
|
||||||
"enableTsDiagnostics": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.tsx?$": "./common/node_modules/ts-jest"
|
|
||||||
},
|
|
||||||
"testEnvironment": "node",
|
|
||||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
|
||||||
"moduleNameMapper": {
|
|
||||||
"^ts-jest$": "<rootDir>/common/node_modules/ts-jest",
|
|
||||||
"^@aspnet/signalr$": "<rootDir>/signalr/dist/cjs/index.js"
|
|
||||||
},
|
|
||||||
"moduleFileExtensions": [
|
|
||||||
"ts",
|
|
||||||
"tsx",
|
|
||||||
"js",
|
|
||||||
"jsx",
|
|
||||||
"json",
|
|
||||||
"node"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ import { BinaryMessageFormat } from "./BinaryMessageFormat";
|
||||||
|
|
||||||
// constant encoding of the ping message
|
// constant encoding of the ping message
|
||||||
// see: https://github.com/aspnet/SignalR/blob/dev/specs/HubProtocol.md#ping-message-encoding-1
|
// see: https://github.com/aspnet/SignalR/blob/dev/specs/HubProtocol.md#ping-message-encoding-1
|
||||||
const SERIALIZED_PING_MESSAGE: ArrayBuffer = Uint8Array.from([0x91, MessageType.Ping]).buffer;
|
// Don't use Uint8Array.from as IE does not support it
|
||||||
|
const SERIALIZED_PING_MESSAGE: Uint8Array = new Uint8Array([0x91, MessageType.Ping]);
|
||||||
|
|
||||||
/** Implements the MessagePack Hub Protocol */
|
/** Implements the MessagePack Hub Protocol */
|
||||||
export class MessagePackHubProtocol implements IHubProtocol {
|
export class MessagePackHubProtocol implements IHubProtocol {
|
||||||
|
|
@ -67,7 +68,7 @@ export class MessagePackHubProtocol implements IHubProtocol {
|
||||||
case MessageType.Completion:
|
case MessageType.Completion:
|
||||||
throw new Error(`Writing messages of type '${message.type}' is not supported.`);
|
throw new Error(`Writing messages of type '${message.type}' is not supported.`);
|
||||||
case MessageType.Ping:
|
case MessageType.Ping:
|
||||||
return SERIALIZED_PING_MESSAGE;
|
return BinaryMessageFormat.write(SERIALIZED_PING_MESSAGE);
|
||||||
default:
|
default:
|
||||||
throw new Error("Invalid message type.");
|
throw new Error("Invalid message type.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
import { CompletionMessage, InvocationMessage, MessageType, NullLogger, StreamItemMessage } from "@aspnet/signalr";
|
import { CompletionMessage, InvocationMessage, MessageType, NullLogger, StreamItemMessage } from "@aspnet/signalr";
|
||||||
import { MessagePackHubProtocol } from "../src/MessagePackHubProtocol";
|
import { MessagePackHubProtocol } from "../src/MessagePackHubProtocol";
|
||||||
|
|
||||||
describe("MessageHubProtocol", () => {
|
describe("MessagePackHubProtocol", () => {
|
||||||
it("can write/read non-blocking Invocation message", () => {
|
it("can write/read non-blocking Invocation message", () => {
|
||||||
const invocation = {
|
const invocation = {
|
||||||
arguments: [42, true, "test", ["x1", "y2"], null],
|
arguments: [42, true, "test", ["x1", "y2"], null],
|
||||||
|
|
@ -188,4 +188,14 @@ describe("MessageHubProtocol", () => {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("can write ping message", () => {
|
||||||
|
const payload = new Uint8Array([
|
||||||
|
0x02, // length prefix
|
||||||
|
0x91, // message array length = 1 (fixarray)
|
||||||
|
0x06, // type = 6 = Ping (fixnum)
|
||||||
|
]);
|
||||||
|
const buffer = new MessagePackHubProtocol().writeMessage({ type: MessageType.Ping });
|
||||||
|
expect(new Uint8Array(buffer)).toEqual(payload);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,10 @@ export class HttpConnection implements IConnection {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((negotiateResponse as any).ProtocolVersion) {
|
||||||
|
throw Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");
|
||||||
|
}
|
||||||
|
|
||||||
if (negotiateResponse.url) {
|
if (negotiateResponse.url) {
|
||||||
url = negotiateResponse.url;
|
url = negotiateResponse.url;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -408,7 +408,13 @@ export class HubConnection {
|
||||||
this.cleanupPingTimer();
|
this.cleanupPingTimer();
|
||||||
this.pingServerHandle = setTimeout(async () => {
|
this.pingServerHandle = setTimeout(async () => {
|
||||||
if (this.connectionState === HubConnectionState.Connected) {
|
if (this.connectionState === HubConnectionState.Connected) {
|
||||||
await this.sendMessage(this.cachedPingMessage);
|
try {
|
||||||
|
await this.sendMessage(this.cachedPingMessage);
|
||||||
|
} catch {
|
||||||
|
// We don't care about the error. It should be seen elsewhere in the client.
|
||||||
|
// The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering
|
||||||
|
this.cleanupPingTimer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, this.keepAliveIntervalInMilliseconds);
|
}, this.keepAliveIntervalInMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -794,5 +794,38 @@ describe("HttpConnection", () => {
|
||||||
expect(() => connection.start(42)).toThrowError("Unknown transferFormat value: 42.");
|
expect(() => connection.start(42)).toThrowError("Unknown transferFormat value: 42.");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("throws if trying to connect to an ASP.NET SignalR Server", async () => {
|
||||||
|
await VerifyLogger.run(async (logger) => {
|
||||||
|
const options: IHttpConnectionOptions = {
|
||||||
|
...commonOptions,
|
||||||
|
httpClient: new TestHttpClient()
|
||||||
|
.on("POST", () => "{\"Url\":\"/signalr\"," +
|
||||||
|
"\"ConnectionToken\":\"X97dw3uxW4NPPggQsYVcNcyQcuz4w2\"," +
|
||||||
|
"\"ConnectionId\":\"05265228-1e2c-46c5-82a1-6a5bcc3f0143\"," +
|
||||||
|
"\"KeepAliveTimeout\":10.0," +
|
||||||
|
"\"DisconnectTimeout\":5.0," +
|
||||||
|
"\"TryWebSockets\":true," +
|
||||||
|
"\"ProtocolVersion\":\"1.5\"," +
|
||||||
|
"\"TransportConnectTimeout\":30.0," +
|
||||||
|
"\"LongPollDelay\":0.0}")
|
||||||
|
.on("GET", () => ""),
|
||||||
|
logger,
|
||||||
|
} as IHttpConnectionOptions;
|
||||||
|
|
||||||
|
const connection = new HttpConnection("http://tempuri.org", options);
|
||||||
|
let receivedError = false;
|
||||||
|
try {
|
||||||
|
await connection.start(TransferFormat.Text);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toEqual(new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details."));
|
||||||
|
receivedError = true;
|
||||||
|
} finally {
|
||||||
|
await connection.stop();
|
||||||
|
}
|
||||||
|
expect(receivedError).toBe(true);
|
||||||
|
},
|
||||||
|
"Failed to start the connection: Error: Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ describe("TextMessageFormat", () => {
|
||||||
["Hello\u001e", ["Hello"]],
|
["Hello\u001e", ["Hello"]],
|
||||||
["Hello,\u001eWorld!\u001e", ["Hello,", "World!"]],
|
["Hello,\u001eWorld!\u001e", ["Hello,", "World!"]],
|
||||||
] as Array<[string, string[]]>).forEach(([payload, expectedMessages]) => {
|
] as Array<[string, string[]]>).forEach(([payload, expectedMessages]) => {
|
||||||
it(`should parse '${payload}' correctly`, () => {
|
it(`should parse '${encodeURI(payload)}' correctly`, () => {
|
||||||
const messages = TextMessageFormat.parse(payload);
|
const messages = TextMessageFormat.parse(payload);
|
||||||
expect(messages).toEqual(expectedMessages);
|
expect(messages).toEqual(expectedMessages);
|
||||||
});
|
});
|
||||||
|
|
@ -24,7 +24,7 @@ describe("TextMessageFormat", () => {
|
||||||
["ABC", "Message is incomplete."],
|
["ABC", "Message is incomplete."],
|
||||||
["ABC\u001eXYZ", "Message is incomplete."],
|
["ABC\u001eXYZ", "Message is incomplete."],
|
||||||
] as Array<[string, string]>).forEach(([payload, expectedError]) => {
|
] as Array<[string, string]>).forEach(([payload, expectedError]) => {
|
||||||
it(`should fail to parse '${payload}'`, () => {
|
it(`should fail to parse '${encodeURI(payload)}'`, () => {
|
||||||
expect(() => TextMessageFormat.parse(payload)).toThrow(expectedError);
|
expect(() => TextMessageFormat.parse(payload)).toThrow(expectedError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -18,6 +18,8 @@ namespace Microsoft.AspNetCore.Http.Connections
|
||||||
private const string AvailableTransportsPropertyName = "availableTransports";
|
private const string AvailableTransportsPropertyName = "availableTransports";
|
||||||
private const string TransportPropertyName = "transport";
|
private const string TransportPropertyName = "transport";
|
||||||
private const string TransferFormatsPropertyName = "transferFormats";
|
private const string TransferFormatsPropertyName = "transferFormats";
|
||||||
|
// Used to detect ASP.NET SignalR Server connection attempt
|
||||||
|
private const string ProtocolVersionPropertyName = "ProtocolVersion";
|
||||||
|
|
||||||
public static void WriteResponse(NegotiationResponse response, IBufferWriter<byte> output)
|
public static void WriteResponse(NegotiationResponse response, IBufferWriter<byte> output)
|
||||||
{
|
{
|
||||||
|
|
@ -134,6 +136,8 @@ namespace Microsoft.AspNetCore.Http.Connections
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ProtocolVersionPropertyName:
|
||||||
|
throw new InvalidOperationException("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");
|
||||||
default:
|
default:
|
||||||
reader.Skip();
|
reader.Skip();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,13 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Internal
|
||||||
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(6, "Unsubscribe"), "Unsubscribing from channel: {Channel}.");
|
LoggerMessage.Define<string>(LogLevel.Trace, new EventId(6, "Unsubscribe"), "Unsubscribing from channel: {Channel}.");
|
||||||
|
|
||||||
private static readonly Action<ILogger, Exception> _notConnected =
|
private static readonly Action<ILogger, Exception> _notConnected =
|
||||||
LoggerMessage.Define(LogLevel.Warning, new EventId(7, "Connected"), "Not connected to Redis.");
|
LoggerMessage.Define(LogLevel.Error, new EventId(7, "Connected"), "Not connected to Redis.");
|
||||||
|
|
||||||
private static readonly Action<ILogger, Exception> _connectionRestored =
|
private static readonly Action<ILogger, Exception> _connectionRestored =
|
||||||
LoggerMessage.Define(LogLevel.Information, new EventId(8, "ConnectionRestored"), "Connection to Redis restored.");
|
LoggerMessage.Define(LogLevel.Information, new EventId(8, "ConnectionRestored"), "Connection to Redis restored.");
|
||||||
|
|
||||||
private static readonly Action<ILogger, Exception> _connectionFailed =
|
private static readonly Action<ILogger, Exception> _connectionFailed =
|
||||||
LoggerMessage.Define(LogLevel.Warning, new EventId(9, "ConnectionFailed"), "Connection to Redis failed.");
|
LoggerMessage.Define(LogLevel.Error, new EventId(9, "ConnectionFailed"), "Connection to Redis failed.");
|
||||||
|
|
||||||
private static readonly Action<ILogger, Exception> _failedWritingMessage =
|
private static readonly Action<ILogger, Exception> _failedWritingMessage =
|
||||||
LoggerMessage.Define(LogLevel.Warning, new EventId(10, "FailedWritingMessage"), "Failed writing message.");
|
LoggerMessage.Define(LogLevel.Warning, new EventId(10, "FailedWritingMessage"), "Failed writing message.");
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,27 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
||||||
Assert.Equal(expectedMessage, exception.InnerException.Message);
|
Assert.Equal(expectedMessage, exception.InnerException.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ParsingAspNetSignalRResponseThrowsError()
|
||||||
|
{
|
||||||
|
var payload = "{\"Url\":\"/signalr\"," +
|
||||||
|
"\"ConnectionToken\":\"X97dw3uxW4NPPggQsYVcNcyQcuz4w2\"," +
|
||||||
|
"\"ConnectionId\":\"05265228-1e2c-46c5-82a1-6a5bcc3f0143\"," +
|
||||||
|
"\"KeepAliveTimeout\":10.0," +
|
||||||
|
"\"DisconnectTimeout\":5.0," +
|
||||||
|
"\"TryWebSockets\":true," +
|
||||||
|
"\"ProtocolVersion\":\"1.5\"," +
|
||||||
|
"\"TransportConnectTimeout\":30.0," +
|
||||||
|
"\"LongPollDelay\":0.0}";
|
||||||
|
|
||||||
|
var responseData = Encoding.UTF8.GetBytes(payload);
|
||||||
|
var ms = new MemoryStream(responseData);
|
||||||
|
|
||||||
|
var exception = Assert.Throws<InvalidDataException>(() => NegotiateProtocol.ParseResponse(ms));
|
||||||
|
|
||||||
|
Assert.Equal("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.", exception.InnerException.Message);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void WriteNegotiateResponseWithNullAvailableTransports()
|
public void WriteNegotiateResponseWithNullAvailableTransports()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task NegotiateReturnedConenctionIdIsSetOnConnection()
|
public async Task NegotiateReturnedConnectionIdIsSetOnConnection()
|
||||||
{
|
{
|
||||||
string connectionId = null;
|
string connectionId = null;
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
||||||
testHttpHandler.OnLongPoll((token) =>
|
testHttpHandler.OnLongPoll((token) =>
|
||||||
{
|
{
|
||||||
var tcs = new TaskCompletionSource<HttpResponseMessage>(TaskCreationOptions.RunContinuationsAsynchronously);
|
var tcs = new TaskCompletionSource<HttpResponseMessage>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
|
||||||
token.Register(() => tcs.TrySetResult(ResponseUtils.CreateResponse(HttpStatusCode.NoContent)));
|
token.Register(() => tcs.TrySetResult(ResponseUtils.CreateResponse(HttpStatusCode.NoContent)));
|
||||||
|
|
||||||
return tcs.Task;
|
return tcs.Task;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue