Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Request Passthrough to continuous webjobs
- Loading branch information
1 parent
cab4bfd
commit 3e9c208
Showing
10 changed files
with
127 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
namespace Kudu.Contracts.Jobs | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace Kudu.Contracts.Jobs | ||
{ | ||
public interface IContinuousJobsManager : IJobsManager<ContinuousJob> | ||
{ | ||
void DisableJob(string jobName); | ||
|
||
void EnableJob(string jobName); | ||
|
||
Task<HttpResponseMessage> HandleRequest(string jobName, string path, HttpRequestMessage request); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Kudu.Core.Jobs; | ||
using Kudu.Core.Tracing; | ||
using Kudu.TestHarness; | ||
using Moq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Kudu.Core.Test.Jobs | ||
{ | ||
public class ContinuousJobsManagerFacts | ||
{ | ||
[Theory] | ||
[InlineData(4567, "path/to/webjob/function", @"{""key"": ""value""}")] | ||
public void CloneRequestTestCase(int port, string path, string content) | ||
{ | ||
// Arrange | ||
var headers = new Dictionary<string, string> { { "key", "value" }, { "HOST", "example.com" } }; | ||
var request = new HttpRequestMessage(HttpMethod.Put, new Uri("https://kudu.com/" + path)); | ||
request.Content = new StringContent(content); | ||
foreach (var pair in headers) | ||
request.Headers.Add(pair.Key, pair.Value); | ||
|
||
// Act | ||
var clone = ContinuousJobsManager.GetForwardRequest(port, path, request); | ||
|
||
// Assert | ||
Assert.Equal(request.Method, clone.Method); | ||
Assert.Equal(string.Format("http://127.0.0.1:{0}/{1}", port, path), clone.RequestUri.AbsoluteUri); | ||
Assert.Equal(content, clone.Content.ReadAsStringAsync().Result); | ||
Assert.Equal(1, clone.Headers.Count()); | ||
Assert.Equal("value", clone.Headers.First().Value.First()); | ||
} | ||
} | ||
} |
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
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