mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-31 03:50:08 -07:00
Fixed #22
With the understanding that most people will not have a valid cert or self signed cert I have disabled the SSL warnings. Added a SSL option to the Plex settings and added unit test to cover this.
This commit is contained in:
parent
07b42ffd50
commit
e6d67c7320
6 changed files with 41 additions and 8 deletions
|
@ -26,6 +26,7 @@
|
||||||
#endregion
|
#endregion
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
|
@ -35,13 +35,14 @@ namespace PlexRequests.Core.SettingModels
|
||||||
{
|
{
|
||||||
public string Ip { get; set; }
|
public string Ip { get; set; }
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
|
public bool Ssl { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Uri FullUri
|
public Uri FullUri
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var formatted = Ip.ReturnUri(Port);
|
var formatted = Ip.ReturnUri(Port, Ssl);
|
||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,24 @@ namespace PlexRequests.Helpers.Tests
|
||||||
public class UriHelperTests
|
public class UriHelperTests
|
||||||
{
|
{
|
||||||
[TestCaseSource(nameof(UriData))]
|
[TestCaseSource(nameof(UriData))]
|
||||||
public void CreateUri(string uri, Uri expected)
|
public void CreateUri1(string uri, Uri expected)
|
||||||
{
|
{
|
||||||
var result = uri.ReturnUri();
|
var result = uri.ReturnUri();
|
||||||
|
|
||||||
Assert.That(result, Is.EqualTo(expected));
|
Assert.That(result, Is.EqualTo(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CreateUriWithSsl()
|
||||||
|
{
|
||||||
|
var uri = "192.168.1.69";
|
||||||
|
var result = uri.ReturnUri(8080, true);
|
||||||
|
|
||||||
|
Assert.That(result, Is.EqualTo(new Uri("https://192.168.1.69:8080")));
|
||||||
|
}
|
||||||
|
|
||||||
[TestCaseSource(nameof(UriDataWithPort))]
|
[TestCaseSource(nameof(UriDataWithPort))]
|
||||||
public void CreateUri(string uri, int port, Uri expected)
|
public void CreateUri2(string uri, int port, Uri expected)
|
||||||
{
|
{
|
||||||
var result = uri.ReturnUri(port);
|
var result = uri.ReturnUri(port);
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,6 @@ namespace PlexRequests.Helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the URI.
|
/// Returns the URI.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -57,7 +55,7 @@ namespace PlexRequests.Helpers
|
||||||
/// <param name="port">The port.</param>
|
/// <param name="port">The port.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="System.Exception"></exception>
|
/// <exception cref="System.Exception"></exception>
|
||||||
public static Uri ReturnUri(this string val, int port)
|
public static Uri ReturnUri(this string val, int port, bool ssl = default(bool))
|
||||||
{
|
{
|
||||||
if (val == null)
|
if (val == null)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +73,13 @@ namespace PlexRequests.Helpers
|
||||||
else if (val.StartsWith("https://", StringComparison.Ordinal))
|
else if (val.StartsWith("https://", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
var split = val.Split('/');
|
var split = val.Split('/');
|
||||||
uri = split.Length >= 4 ? new UriBuilder(Uri.UriSchemeHttps, split[2], port, "/" + split[3]) : new UriBuilder(Uri.UriSchemeHttps, split[2], port);
|
uri = split.Length >= 4
|
||||||
|
? new UriBuilder(Uri.UriSchemeHttps, split[2], port, "/" + split[3])
|
||||||
|
: new UriBuilder(Uri.UriSchemeHttps, split[2], port);
|
||||||
|
}
|
||||||
|
else if(ssl)
|
||||||
|
{
|
||||||
|
uri = new UriBuilder(Uri.UriSchemeHttps, val, port);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Net;
|
||||||
using FluentScheduler;
|
using FluentScheduler;
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
|
|
||||||
|
@ -114,6 +115,9 @@ namespace PlexRequests.UI
|
||||||
|
|
||||||
FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
|
FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
|
||||||
|
|
||||||
|
ServicePointManager.ServerCertificateValidationCallback +=
|
||||||
|
(sender, certificate, chain, sslPolicyErrors) => true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,20 @@
|
||||||
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
|
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
@if (Model.Ssl)
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="Ssl" name="Ssl" checked="checked"><text>SSL</text>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="Ssl" name="Ssl"><text>SSL</text>
|
||||||
|
}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button id="testPlex" type="submit" class="btn btn-primary-outline">Test Connectivity</button>
|
<button id="testPlex" type="submit" class="btn btn-primary-outline">Test Connectivity</button>
|
||||||
|
@ -46,7 +60,7 @@
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function () {
|
||||||
|
|
||||||
$('#testPlex').click(function (e) {
|
$('#testPlex').click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue