Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 6590992

Browse files
authored
fix #1155 by renaming signalRTokenHeader to access_token (#1343)
1 parent 96a3a03 commit 6590992

File tree

8 files changed

+90
-76
lines changed

8 files changed

+90
-76
lines changed

client-ts/FunctionalTests/Startup.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public void ConfigureServices(IServiceCollection services)
5858
{
5959
OnMessageReceived = context =>
6060
{
61-
var signalRTokenHeader = context.Request.Query["signalRTokenHeader"];
61+
var signalRTokenHeader = context.Request.Query["access_token"];
6262

6363
if (!string.IsNullOrEmpty(signalRTokenHeader) &&
6464
(context.HttpContext.WebSockets.IsWebSocketRequest || context.Request.Headers["Accept"] == "text/event-stream"))
6565
{
66-
context.Token = context.Request.Query["signalRTokenHeader"];
66+
context.Token = context.Request.Query["access_token"];
6767
}
6868
return Task.CompletedTask;
6969
}

client-ts/FunctionalTests/ts/HubConnectionTests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ describe('hubConnection', function () {
476476
hubConnection = new HubConnection('/authorizedhub', {
477477
transport: transportType,
478478
logger: LogLevel.Trace,
479-
accessToken: () => jwtToken
479+
accessTokenFactory: () => jwtToken
480480
});
481481
hubConnection.onclose(function (error) {
482482
expect(error).toBe(undefined);

client-ts/signalr/spec/HttpConnection.spec.ts

+17-13
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,29 @@ import { ITransport, TransportType, TransferMode } from "../src/Transports"
99
import { eachTransport, eachEndpointUrl } from "./Common";
1010
import { HttpResponse } from "../src/index";
1111

12+
const commonOptions: IHttpConnectionOptions = {
13+
logger: null
14+
};
15+
1216
describe("HttpConnection", () => {
1317
it("cannot be created with relative url if document object is not present", () => {
14-
expect(() => new HttpConnection("/test"))
18+
expect(() => new HttpConnection("/test", commonOptions))
1519
.toThrow(new Error("Cannot resolve '/test'."));
1620
});
1721

1822
it("cannot be created with relative url if window object is not present", () => {
1923
(<any>global).window = {};
20-
expect(() => new HttpConnection("/test"))
24+
expect(() => new HttpConnection("/test", commonOptions))
2125
.toThrow(new Error("Cannot resolve '/test'."));
2226
delete (<any>global).window;
2327
});
2428

2529
it("starting connection fails if getting id fails", async (done) => {
2630
let options: IHttpConnectionOptions = {
31+
...commonOptions,
2732
httpClient: new TestHttpClient()
2833
.on("POST", r => Promise.reject("error"))
2934
.on("GET", r => ""),
30-
logger: null
3135
} as IHttpConnectionOptions;
3236

3337
let connection = new HttpConnection("http://tempuri.org", options);
@@ -45,6 +49,7 @@ describe("HttpConnection", () => {
4549

4650
it("cannot start a running connection", async (done) => {
4751
let options: IHttpConnectionOptions = {
52+
...commonOptions,
4853
httpClient: new TestHttpClient()
4954
.on("POST", r => {
5055
connection.start()
@@ -58,7 +63,6 @@ describe("HttpConnection", () => {
5863
});
5964
return Promise.reject("error");
6065
}),
61-
logger: null
6266
} as IHttpConnectionOptions;
6367

6468
let connection = new HttpConnection("http://tempuri.org", options);
@@ -75,13 +79,13 @@ describe("HttpConnection", () => {
7579
it("can start a stopped connection", async (done) => {
7680
let negotiateCalls = 0;
7781
let options: IHttpConnectionOptions = {
82+
...commonOptions,
7883
httpClient: new TestHttpClient()
7984
.on("POST", r => {
8085
negotiateCalls += 1;
8186
return Promise.reject("reached negotiate");
8287
})
8388
.on("GET", r => ""),
84-
logger: null
8589
} as IHttpConnectionOptions;
8690

8791
let connection = new HttpConnection("http://tempuri.org", options);
@@ -103,6 +107,7 @@ describe("HttpConnection", () => {
103107

104108
it("can stop a starting connection", async (done) => {
105109
let options: IHttpConnectionOptions = {
110+
...commonOptions,
106111
httpClient: new TestHttpClient()
107112
.on("POST", r => {
108113
connection.stop();
@@ -112,7 +117,6 @@ describe("HttpConnection", () => {
112117
connection.stop();
113118
return "";
114119
}),
115-
logger: null
116120
} as IHttpConnectionOptions;
117121

118122
let connection = new HttpConnection("http://tempuri.org", options);
@@ -128,7 +132,7 @@ describe("HttpConnection", () => {
128132
});
129133

130134
it("can stop a non-started connection", async (done) => {
131-
let connection = new HttpConnection("http://tempuri.org");
135+
let connection = new HttpConnection("http://tempuri.org", commonOptions);
132136
await connection.stop();
133137
done();
134138
});
@@ -151,11 +155,11 @@ describe("HttpConnection", () => {
151155
}
152156

153157
let options: IHttpConnectionOptions = {
158+
...commonOptions,
154159
httpClient: new TestHttpClient()
155160
.on("POST", r => "{ \"connectionId\": \"42\" }")
156161
.on("GET", r => ""),
157162
transport: fakeTransport,
158-
logger: null,
159163
} as IHttpConnectionOptions;
160164

161165

@@ -178,6 +182,7 @@ describe("HttpConnection", () => {
178182
let negotiateUrl: string;
179183
let connection: HttpConnection;
180184
let options: IHttpConnectionOptions = {
185+
...commonOptions,
181186
httpClient: new TestHttpClient()
182187
.on("POST", r => {
183188
negotiateUrl = r.url;
@@ -188,7 +193,6 @@ describe("HttpConnection", () => {
188193
connection.stop();
189194
return "";
190195
}),
191-
logger: null
192196
} as IHttpConnectionOptions;
193197

194198
connection = new HttpConnection(givenUrl, options);
@@ -212,11 +216,11 @@ describe("HttpConnection", () => {
212216
}
213217
it(`cannot be started if requested ${TransportType[requestedTransport]} transport not available on server`, async done => {
214218
let options: IHttpConnectionOptions = {
219+
...commonOptions,
215220
httpClient: new TestHttpClient()
216221
.on("POST", r => "{ \"connectionId\": \"42\", \"availableTransports\": [] }")
217222
.on("GET", r => ""),
218223
transport: requestedTransport,
219-
logger: null
220224
} as IHttpConnectionOptions;
221225

222226
let connection = new HttpConnection("http://tempuri.org", options);
@@ -234,10 +238,10 @@ describe("HttpConnection", () => {
234238

235239
it("cannot be started if no transport available on server and no transport requested", async done => {
236240
let options: IHttpConnectionOptions = {
241+
...commonOptions,
237242
httpClient: new TestHttpClient()
238243
.on("POST", r => "{ \"connectionId\": \"42\", \"availableTransports\": [] }")
239244
.on("GET", r => ""),
240-
logger: null
241245
} as IHttpConnectionOptions;
242246

243247
let connection = new HttpConnection("http://tempuri.org", options);
@@ -254,9 +258,9 @@ describe("HttpConnection", () => {
254258

255259
it('does not send negotiate request if WebSockets transport requested explicitly', async done => {
256260
let options: IHttpConnectionOptions = {
261+
...commonOptions,
257262
httpClient: new TestHttpClient(),
258263
transport: TransportType.WebSockets,
259-
logger: null
260264
} as IHttpConnectionOptions;
261265

262266
let connection = new HttpConnection("http://tempuri.org", options);
@@ -291,11 +295,11 @@ describe("HttpConnection", () => {
291295
} as ITransport;
292296

293297
let options: IHttpConnectionOptions = {
298+
...commonOptions,
294299
httpClient: new TestHttpClient()
295300
.on("POST", r => "{ \"connectionId\": \"42\", \"availableTransports\": [] }")
296301
.on("GET", r => ""),
297302
transport: fakeTransport,
298-
logger: null
299303
} as IHttpConnectionOptions;
300304

301305
let connection = new HttpConnection("https://tempuri.org", options);

0 commit comments

Comments
 (0)