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.
pull/23/head
Jamie Rees 8 years ago
parent 07b42ffd50
commit e6d67c7320

@ -26,6 +26,7 @@
#endregion
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

@ -35,13 +35,14 @@ namespace PlexRequests.Core.SettingModels
{
public string Ip { get; set; }
public int Port { get; set; }
public bool Ssl { get; set; }
[JsonIgnore]
public Uri FullUri
{
get
{
var formatted = Ip.ReturnUri(Port);
var formatted = Ip.ReturnUri(Port, Ssl);
return formatted;
}
}

@ -34,15 +34,24 @@ namespace PlexRequests.Helpers.Tests
public class UriHelperTests
{
[TestCaseSource(nameof(UriData))]
public void CreateUri(string uri, Uri expected)
public void CreateUri1(string uri, Uri expected)
{
var result = uri.ReturnUri();
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))]
public void CreateUri(string uri, int port, Uri expected)
public void CreateUri2(string uri, int port, Uri expected)
{
var result = uri.ReturnUri(port);

@ -48,8 +48,6 @@ namespace PlexRequests.Helpers
}
}
/// <summary>
/// Returns the URI.
/// </summary>
@ -57,7 +55,7 @@ namespace PlexRequests.Helpers
/// <param name="port">The port.</param>
/// <returns></returns>
/// <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)
{
@ -75,7 +73,13 @@ namespace PlexRequests.Helpers
else if (val.StartsWith("https://", StringComparison.Ordinal))
{
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
{

@ -25,6 +25,7 @@
// ************************************************************************/
#endregion
using System.Net;
using FluentScheduler;
using Mono.Data.Sqlite;
@ -114,6 +115,9 @@ namespace PlexRequests.UI
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">
</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>
<button id="testPlex" type="submit" class="btn btn-primary-outline">Test Connectivity</button>
@ -46,7 +60,7 @@
<script>
$(function() {
$(function () {
$('#testPlex').click(function (e) {
e.preventDefault();

Loading…
Cancel
Save