* Fixed firewall rules check and improved the script the check shall be like ~ Get-NetFirewallRule -DisplayName eShopOnContainers-* -ErrorAction Stop * #1397: Replaced deprecated docker.for.win.localhost by host.docker.internal in src/.env (#1400) * Updated Readme (#1402) Fixed sentence structure in Readme. Changed "and a several" to "with several." * CatalogService: Fix issue with Status set when items list is empty (#1304) * Fix issue with Status set when items list is empty * Change method Count() call to Count property Co-authored-by: Dmytro Hridin <v-dmytro.hridin@lionbridge.com> * refactored Equals() method on ValueObject (#1316) * Fix/1403and1404 removed duplicate Key SubscriptionClientName and added app.UseAuthorization() call (#1406) * #1403 removed duplicate Key SubscriptionClientName Removed duplicate key SubscriptionClientName from Tests/Services/Application.FunctionalTests/Services/Marketing/appsettings.json and sorted its content in asc order. * #1404 Added app.UseAuthorization() call Added app.UseAuthorization() call to BasketTestsStartup, LocationsTestsStartup, and MarketingTestsStartup to fix failed unit tests IntegrationEventsScenarios.Post_update_product_price_and_catalog_and_basket_list_modified and MarketingScenarios.Set_new_user_location_and_get_location_campaign_by_user_id (see #1404) * Fix for Campaigns exception and SignalR 401 Unauthorized (#1374) * update API Gateway - /locations-api/ @ webmarketing/envoy.yaml * updated signalr services - envoy: webmarketingapigw - latest client: webmvc - service hub: ordering-signalrhub Co-authored-by: hfz-r <hafiz.roslan@hartalega.com.my> * Mis-Spelled 'client' (#1411) * fix parameter error in multiarch job (#1413) * Private readonly string changed to private const string (#1288) * fix disposing of direct instantiated objects in calalog service #1392 (#1395) * Updated version of different packages. (#1420) * for issue #1423: changed literal string "OpenIdConnect" to constant string (#1424) Co-authored-by: Jeremiah Flaga <j.flaga@arcanys.com> * Updated node-fetch package version. (#1426) * Updated node-fetch package version. * Updated node-forge version. * Fixes #1474: webspa container does not build when running docker-compose up.Updated sha hashes in packages-lock.json (#1475) * Change ReadAllBytes to ReadAllBytesAsync in PicController (#1425) Co-authored-by: edmondshtogu <edmondshtogu@gmail.com> Co-authored-by: InstanceFactory <InstanceFactory@users.noreply.github.com> Co-authored-by: Sumit Ghosh <sumit.ghosh@neudesic.com> Co-authored-by: Yosef Herskovitz <34112131+H3RSKO@users.noreply.github.com> Co-authored-by: Dmytro Hridin <dmytro.hridin@gmail.com> Co-authored-by: Dmytro Hridin <v-dmytro.hridin@lionbridge.com> Co-authored-by: André Silva <andrefilipegsilva@outlook.com> Co-authored-by: hfz-r <39443205+hfz-r@users.noreply.github.com> Co-authored-by: hfz-r <hafiz.roslan@hartalega.com.my> Co-authored-by: Majid Ali Khan Quaid <contactmakq@gmail.com> Co-authored-by: Javier Vela <fjvela@gmail.com> Co-authored-by: Facundo La Rocca <facundo_larocca@yahoo.com.ar> Co-authored-by: Nabil Sedoud <nsedoud@gmail.com> Co-authored-by: jeremiahflaga <flaga.jeremiah@gmail.com> Co-authored-by: Jeremiah Flaga <j.flaga@arcanys.com> Co-authored-by: Wojciech Rak <wojciechrak@users.noreply.github.com> Co-authored-by: Zakaria <23211915+zakaria-c@users.noreply.github.com>feature/enable-tye^2
@ -1,26 +1,53 @@ | |||||
param([switch]$Elevated) | |||||
param( | |||||
[string]$Name = "eShopOnContainers", | |||||
[string]$InboundDisplayName = "eShopOnContainers-Inbound", | |||||
[string]$OutboundDisplayName = "eShopOnContainers-Outbound", | |||||
[switch]$Elevated | |||||
) | |||||
function Check-Admin { | function Check-Admin { | ||||
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent()) | |||||
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |||||
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent()) | |||||
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |||||
} | } | ||||
if ((Check-Admin) -eq $false) { | |||||
if ($elevated) | |||||
{ | |||||
# could not elevate, quit | |||||
function Add-InboundRule { | |||||
New-NetFirewallRule -DisplayName $InboundDisplayName -Confirm -Description "$Name Inbound Rule for port range 5100-5150" -LocalAddress Any -LocalPort 5100-5150 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Inbound | |||||
} | } | ||||
else { | |||||
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition)) | |||||
function Add-OutboundRule { | |||||
New-NetFirewallRule -DisplayName $OutboundDisplayName -Confirm -Description "$Name Outbound Rule for port range 5100-5150" -LocalAddress Any -LocalPort 5100-5150 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Outbound | |||||
} | } | ||||
exit | |||||
if ((Check-Admin) -eq $false) { | |||||
if ($elevated) | |||||
{ | |||||
# could not elevate, quit | |||||
} | |||||
else { | |||||
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition)) | |||||
} | |||||
exit | |||||
} | } | ||||
try { | try { | ||||
Get-NetFirewallRule -DisplayName EshopDocker -ErrorAction Stop | |||||
Write-Host "Rule found" | |||||
$rules = $(Get-NetFirewallRule -DisplayName $Name-* -ErrorAction Stop | Out-String) | |||||
if (!$rules.Contains($InboundDisplayName) -and !$rules.Contains($OutboundDisplayName)) | |||||
{ | |||||
Add-InboundRule | |||||
Add-OutboundRule | |||||
} | |||||
elseif (!$rules.Contains($InboundDisplayName)) | |||||
{ | |||||
Add-InboundRule | |||||
} | |||||
elseif (!$rules.Contains($OutboundDisplayName)) | |||||
{ | |||||
Add-OutboundRule | |||||
} | |||||
else{ | |||||
Write-Host "Rules found!" | |||||
} | |||||
} | |||||
catch [Exception] { | |||||
Add-InboundRule | |||||
Add-OutboundRule | |||||
} | } | ||||
catch [Exception] { | |||||
New-NetFirewallRule -DisplayName eShopOnContainers-Inbound -Confirm -Description "eShopOnContainers Inbound Rule for port range 5100-5150" -LocalAddress Any -LocalPort 5100-5150 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Inbound | |||||
New-NetFirewallRule -DisplayName eShopOnContainers-Outbound -Confirm -Description "eShopOnContainers Outbound Rule for port range 5100-5150" -LocalAddress Any -LocalPort 5100-5150 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Outbound | |||||
} |
@ -0,0 +1,190 @@ | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace Ordering.UnitTests.Domain.SeedWork | |||||
{ | |||||
public class ValueObjectTests | |||||
{ | |||||
public ValueObjectTests() | |||||
{ } | |||||
[Theory] | |||||
[MemberData(nameof(EqualValueObjects))] | |||||
public void Equals_EqualValueObjects_ReturnsTrue(ValueObject instanceA, ValueObject instanceB, string reason) | |||||
{ | |||||
// Act | |||||
var result = EqualityComparer<ValueObject>.Default.Equals(instanceA, instanceB); | |||||
// Assert | |||||
Assert.True(result, reason); | |||||
} | |||||
[Theory] | |||||
[MemberData(nameof(NonEqualValueObjects))] | |||||
public void Equals_NonEqualValueObjects_ReturnsFalse(ValueObject instanceA, ValueObject instanceB, string reason) | |||||
{ | |||||
// Act | |||||
var result = EqualityComparer<ValueObject>.Default.Equals(instanceA, instanceB); | |||||
// Assert | |||||
Assert.False(result, reason); | |||||
} | |||||
private static readonly ValueObject APrettyValueObject = new ValueObjectA(1, "2", Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), new ComplexObject(2, "3")); | |||||
public static readonly TheoryData<ValueObject, ValueObject, string> EqualValueObjects = new TheoryData<ValueObject, ValueObject, string> | |||||
{ | |||||
{ | |||||
null, | |||||
null, | |||||
"they should be equal because they are both null" | |||||
}, | |||||
{ | |||||
APrettyValueObject, | |||||
APrettyValueObject, | |||||
"they should be equal because they are the same object" | |||||
}, | |||||
{ | |||||
new ValueObjectA(1, "2", Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), new ComplexObject(2, "3")), | |||||
new ValueObjectA(1, "2", Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), new ComplexObject(2, "3")), | |||||
"they should be equal because they have equal members" | |||||
}, | |||||
{ | |||||
new ValueObjectA(1, "2", Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), new ComplexObject(2, "3"), notAnEqualityComponent: "xpto"), | |||||
new ValueObjectA(1, "2", Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), new ComplexObject(2, "3"), notAnEqualityComponent: "xpto2"), | |||||
"they should be equal because all equality components are equal, even though an additional member was set" | |||||
}, | |||||
{ | |||||
new ValueObjectB(1, "2", 1, 2, 3 ), | |||||
new ValueObjectB(1, "2", 1, 2, 3 ), | |||||
"they should be equal because all equality components are equal, including the 'C' list" | |||||
} | |||||
}; | |||||
public static readonly TheoryData<ValueObject, ValueObject, string> NonEqualValueObjects = new TheoryData<ValueObject, ValueObject, string> | |||||
{ | |||||
{ | |||||
new ValueObjectA(a: 1, b: "2", c: Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), d: new ComplexObject(2, "3")), | |||||
new ValueObjectA(a: 2, b: "2", c: Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), d: new ComplexObject(2, "3")), | |||||
"they should not be equal because the 'A' member on ValueObjectA is different among them" | |||||
}, | |||||
{ | |||||
new ValueObjectA(a: 1, b: "2", c: Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), d: new ComplexObject(2, "3")), | |||||
new ValueObjectA(a: 1, b: null, c: Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), d: new ComplexObject(2, "3")), | |||||
"they should not be equal because the 'B' member on ValueObjectA is different among them" | |||||
}, | |||||
{ | |||||
new ValueObjectA(a: 1, b: "2", c: Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), d: new ComplexObject(a: 2, b: "3")), | |||||
new ValueObjectA(a: 1, b: "2", c: Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), d: new ComplexObject(a: 3, b: "3")), | |||||
"they should not be equal because the 'A' member on ValueObjectA's 'D' member is different among them" | |||||
}, | |||||
{ | |||||
new ValueObjectA(a: 1, b: "2", c: Guid.Parse("97ea43f0-6fef-4fb7-8c67-9114a7ff6ec0"), d: new ComplexObject(a: 2, b: "3")), | |||||
new ValueObjectB(a: 1, b: "2"), | |||||
"they should not be equal because they are not of the same type" | |||||
}, | |||||
{ | |||||
new ValueObjectB(1, "2", 1, 2, 3 ), | |||||
new ValueObjectB(1, "2", 1, 2, 3, 4 ), | |||||
"they should be not be equal because the 'C' list contains one additional value" | |||||
}, | |||||
{ | |||||
new ValueObjectB(1, "2", 1, 2, 3, 5 ), | |||||
new ValueObjectB(1, "2", 1, 2, 3 ), | |||||
"they should be not be equal because the 'C' list contains one additional value" | |||||
}, | |||||
{ | |||||
new ValueObjectB(1, "2", 1, 2, 3, 5 ), | |||||
new ValueObjectB(1, "2", 1, 2, 3, 4 ), | |||||
"they should be not be equal because the 'C' lists are not equal" | |||||
} | |||||
}; | |||||
private class ValueObjectA : ValueObject | |||||
{ | |||||
public ValueObjectA(int a, string b, Guid c, ComplexObject d, string notAnEqualityComponent = null) | |||||
{ | |||||
A = a; | |||||
B = b; | |||||
C = c; | |||||
D = d; | |||||
NotAnEqualityComponent = notAnEqualityComponent; | |||||
} | |||||
public int A { get; } | |||||
public string B { get; } | |||||
public Guid C { get; } | |||||
public ComplexObject D { get; } | |||||
public string NotAnEqualityComponent { get; } | |||||
protected override IEnumerable<object> GetEqualityComponents() | |||||
{ | |||||
yield return A; | |||||
yield return B; | |||||
yield return C; | |||||
yield return D; | |||||
} | |||||
} | |||||
private class ValueObjectB : ValueObject | |||||
{ | |||||
public ValueObjectB(int a, string b, params int[] c) | |||||
{ | |||||
A = a; | |||||
B = b; | |||||
C = c.ToList(); | |||||
} | |||||
public int A { get; } | |||||
public string B { get; } | |||||
public List<int> C { get; } | |||||
protected override IEnumerable<object> GetEqualityComponents() | |||||
{ | |||||
yield return A; | |||||
yield return B; | |||||
foreach (var c in C) | |||||
{ | |||||
yield return c; | |||||
} | |||||
} | |||||
} | |||||
private class ComplexObject : IEquatable<ComplexObject> | |||||
{ | |||||
public ComplexObject(int a, string b) | |||||
{ | |||||
A = a; | |||||
B = b; | |||||
} | |||||
public int A { get; set; } | |||||
public string B { get; set; } | |||||
public override bool Equals(object obj) | |||||
{ | |||||
return Equals(obj as ComplexObject); | |||||
} | |||||
public bool Equals(ComplexObject other) | |||||
{ | |||||
return other != null && | |||||
A == other.A && | |||||
B == other.B; | |||||
} | |||||
public override int GetHashCode() | |||||
{ | |||||
return HashCode.Combine(A, B); | |||||
} | |||||
} | |||||
} | |||||
} |
@ -1,12 +1,11 @@ | |||||
{ | { | ||||
"AzureServiceBusEnabled": false, | |||||
"ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word", | "ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word", | ||||
"MongoConnectionString": "mongodb://localhost:27017", | |||||
"MongoDatabase": "MarketingDb", | |||||
"EventBusConnection": "localhost", | |||||
"IdentityUrl": "http://localhost:5105", | "IdentityUrl": "http://localhost:5105", | ||||
"isTest": "true", | "isTest": "true", | ||||
"EventBusConnection": "localhost", | |||||
"AzureServiceBusEnabled": false, | |||||
"SubscriptionClientName": "Marketing", | |||||
"MongoConnectionString": "mongodb://localhost:27017", | |||||
"MongoDatabase": "MarketingDb", | |||||
"PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/", | "PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/", | ||||
"SubscriptionClientName": "Marketing" | "SubscriptionClientName": "Marketing" | ||||
} | } |