Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Proxying when StartAdminInterface=true #778

Merged
merged 4 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions WireMock.Net Solution.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SSL/@EntryIndexedValue">SSL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TE/@EntryIndexedValue">TE</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TSV/@EntryIndexedValue">TSV</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TTL/@EntryIndexedValue">TTL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WWW/@EntryIndexedValue">WWW</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XMS/@EntryIndexedValue">XMS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XUA/@EntryIndexedValue">XUA</s:String>
Expand Down
8 changes: 4 additions & 4 deletions src/WireMock.Net.Abstractions/Admin/Requests/LogEntryModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class LogEntryModel
/// <summary>
/// The mapping unique title.
/// </summary>
public string MappingTitle { get; set; }
public string? MappingTitle { get; set; }

/// <summary>
/// The request match result.
/// </summary>
public LogRequestMatchModel RequestMatchResult { get; set; }
public LogRequestMatchModel? RequestMatchResult { get; set; }

/// <summary>
/// The partial mapping unique identifier.
Expand All @@ -45,10 +45,10 @@ public class LogEntryModel
/// <summary>
/// The partial mapping unique title.
/// </summary>
public string PartialMappingTitle { get; set; }
public string? PartialMappingTitle { get; set; }

/// <summary>
/// The partial request match result.
/// </summary>
public LogRequestMatchModel PartialRequestMatchResult { get; set; }
public LogRequestMatchModel? PartialRequestMatchResult { get; set; }
}
4 changes: 2 additions & 2 deletions src/WireMock.Net.Abstractions/IRequestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public interface IRequestMessage
/// <summary>
/// Gets the headers.
/// </summary>
IDictionary<string, WireMockList<string>>? Headers { get; }
IDictionary<string, WireMockList<string>> Headers { get; }

/// <summary>
/// Gets the cookies.
/// </summary>
IDictionary<string, string>? Cookies { get; }
IDictionary<string, string> Cookies { get; }

/// <summary>
/// Gets the query.
Expand Down
33 changes: 16 additions & 17 deletions src/WireMock.Net.Abstractions/Models/ITimeSettings.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
using System;

namespace WireMock.Models
namespace WireMock.Models;

/// <summary>
/// TimeSettings: Start, End and TTL
/// </summary>
public interface ITimeSettings
{
/// <summary>
/// TimeSettings: Start, End and TTL
/// Gets or sets the DateTime from which this mapping should be used. In case this is not defined, it's used (default behavior).
/// </summary>
public interface ITimeSettings
{
/// <summary>
/// Gets or sets the DateTime from which this mapping should be used. In case this is not defined, it's used (default behavior).
/// </summary>
DateTime? Start { get; set; }
DateTime? Start { get; set; }

/// <summary>
/// Gets or sets the DateTime from until this mapping should be used. In case this is not defined, it's used forever (default behavior).
/// </summary>
DateTime? End { get; set; }
/// <summary>
/// Gets or sets the DateTime from until this mapping should be used. In case this is not defined, it's used forever (default behavior).
/// </summary>
DateTime? End { get; set; }

/// <summary>
/// Gets or sets the TTL (Time To Live) in seconds for this mapping. In case this is not defined, it's used (default behavior).
/// </summary>
int? TTL { get; set; }
}
/// <summary>
/// Gets or sets the TTL (Time To Live) in seconds for this mapping. In case this is not defined, it's used (default behavior).
/// </summary>
int? TTL { get; set; }
}
47 changes: 23 additions & 24 deletions src/WireMock.Net/Extensions/TimeSettingsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
using System;
using JetBrains.Annotations;
using WireMock.Models;

namespace WireMock.Extensions
namespace WireMock.Extensions;

internal static class TimeSettingsExtensions
{
internal static class TimeSettingsExtensions
public static bool IsValid(this ITimeSettings? settings)
{
public static bool IsValid([CanBeNull] this ITimeSettings settings)
if (settings == null)
{
if (settings == null)
{
return true;
}
return true;
}

var now = DateTime.Now;
var start = settings.Start != null ? settings.Start.Value : now;
DateTime end;
if (settings.End != null)
{
end = settings.End.Value;
}
else if (settings.TTL != null)
{
end = start.AddSeconds(settings.TTL.Value);
}
else
{
end = DateTime.MaxValue;
}
var now = DateTime.Now;
var start = settings.Start ?? now;
DateTime end;

return now >= start && now <= end;
if (settings.End != null)
{
end = settings.End.Value;
}
else if (settings.TTL != null)
{
end = start.AddSeconds(settings.TTL.Value);
}
else
{
end = DateTime.MaxValue;
}

return now >= start && now <= end;
}
}
8 changes: 4 additions & 4 deletions src/WireMock.Net/IMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ public interface IMapping
/// <summary>
/// Gets the TimeSettings (Start, End and TTL).
/// </summary>
ITimeSettings TimeSettings { get; }
ITimeSettings? TimeSettings { get; }

/// <summary>
/// Gets the unique title.
/// </summary>
string Title { get; }
string? Title { get; }

/// <summary>
/// Gets the description.
/// </summary>
string Description { get; }
string? Description { get; }

/// <summary>
/// The full filename path for this mapping (only defined for static mappings).
/// </summary>
string Path { get; set; }
string? Path { get; set; }

/// <summary>
/// Gets the priority. (A low value means higher priority.)
Expand Down
Loading