-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests to verify response redirection handling in addition to ve…
…rifying parse responses is handled correctly when it throws. - Also added the wrapStart functionality to the JS test utilities #2506
- Loading branch information
1 parent
1aa9dcc
commit 5c609df
Showing
9 changed files
with
227 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...t.AspNet.SignalR.Client.JS.Tests/Tests/FunctionalTests/Common/ResponseRedirectionFacts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
var buildRedirectConnection = function (redirectWhen, end, assert, testName, wrapStart) { | ||
var connection = testUtilities.createConnection("redirectionConnection", end, assert, testName, wrapStart); | ||
|
||
connection.qs = { | ||
redirectWhen: redirectWhen | ||
}; | ||
|
||
return connection; | ||
}; | ||
|
||
QUnit.module("Response redirection facts"); | ||
|
||
testUtilities.runWithAllTransports(function (transport) { | ||
QUnit.asyncTimeoutTest(transport + ": Negotiate fails on response redirection.", testUtilities.defaultTestTimeout, function (end, assert, testName) { | ||
var connection = buildRedirectConnection("negotiate", end, assert, testName, false); | ||
|
||
connection.start({ transport: transport }).done(function () { | ||
assert.fail("Connection was started successfully."); | ||
end(); | ||
}).fail(function () { | ||
assert.comment("Connection start deferred failure was triggered."); | ||
end(); | ||
}); | ||
|
||
// Cleanup | ||
return function () { | ||
connection.stop(); | ||
}; | ||
}); | ||
|
||
// Canont do this for long polling because it utilizes the pingServer in its connect process | ||
if (transport !== "longPolling") { | ||
QUnit.asyncTimeoutTest(transport + " - Ping server fails on response redirection.", testUtilities.defaultTestTimeout, function (end, assert, testName) { | ||
var connection = buildRedirectConnection("ping", end, assert, testName), | ||
testPingServer = function () { | ||
$.signalR.transports._logic.pingServer(connection).done(function () { | ||
// Successful ping | ||
assert.fail("Successful ping with " + transport); | ||
end(); | ||
}).fail(function (error) { | ||
assert.comment("Failed to ping server with " + transport); | ||
end(); | ||
}); | ||
}; | ||
|
||
// Starting/Stopping a connection to have it instantiated with all the appropriate variables | ||
connection.start({ transport: transport }).done(function () { | ||
assert.comment("Connected"); | ||
testPingServer(); | ||
}); | ||
|
||
// Cleanup | ||
return function () { | ||
connection.stop(); | ||
}; | ||
}); | ||
} | ||
}); | ||
|
||
testUtilities.runWithTransports(["longPolling", "foreverFrame", "serverSentEvents"], function (transport) { | ||
|
||
QUnit.asyncTimeoutTest(transport + ": Send fails on response redirection.", testUtilities.defaultTestTimeout, function (end, assert, testName) { | ||
var connection = buildRedirectConnection("send", end, assert, testName, true); | ||
|
||
connection.start({ transport: transport }).done(function () { | ||
assert.comment("Connection was started successfully."); | ||
|
||
connection.send(""); | ||
|
||
connection.error(function () { | ||
assert.comment("Connection triggered error function on bad send response."); | ||
end(); | ||
}); | ||
}); | ||
|
||
// Cleanup | ||
return function () { | ||
connection.stop(); | ||
}; | ||
}); | ||
|
||
}); | ||
|
||
QUnit.asyncTimeoutTest("LongPolling poll fails on response redirection.", testUtilities.defaultTestTimeout, function (end, assert, testName) { | ||
var connection = buildRedirectConnection("poll", end, assert, testName); | ||
|
||
connection.start({ transport: "longPolling" }).done(function () { | ||
assert.comment("Connection was started successfully."); | ||
|
||
connection.error(function () { | ||
assert.comment("Connection triggered error function on bad poll response."); | ||
end(); | ||
}); | ||
}); | ||
|
||
// Cleanup | ||
return function () { | ||
connection.stop(); | ||
}; | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/Microsoft.AspNet.SignalR.Tests.Common/Connections/RedirectionConnection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNet.SignalR.Hosting; | ||
using Microsoft.AspNet.SignalR.Owin; | ||
using Microsoft.Owin; | ||
|
||
namespace Microsoft.AspNet.SignalR.Tests.Common.Connections | ||
{ | ||
// Awesome name, it rhymes | ||
public class RedirectionConnection : PersistentConnection | ||
{ | ||
protected override Task OnConnected(IRequest request, string connectionId) | ||
{ | ||
Connection.Send(connectionId, "Hi"); | ||
|
||
return base.OnConnected(request, connectionId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters