QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
140 lines
5.9 KiB
C#
140 lines
5.9 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.Administration.Rights;
|
|
using Centron.BusinessLogic.WebServices.Accounts;
|
|
using Centron.Interfaces.Accounts;
|
|
using Centron.Interfaces.BL;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using CentronSoftware.Centron.WebServices.Entities.Accounts;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.Account.AccountAddresses
|
|
{
|
|
public class AccountAddressTests : EndToEndTest
|
|
{
|
|
public AccountAddressTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
|
|
{
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressDTO>(f => f.CreatedVersion);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressDTO>(f => f.ChangedVersion);
|
|
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressContactDTO>(f => f.CreatedVersion);
|
|
this.Verifier.Settings.IgnoreProperty<AccountAddressContactDTO>(f => f.ChangedVersion);
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
TestLoadWithContacts();
|
|
|
|
GetSingleAccountAddressWithContacts();
|
|
GetDefaultAddressForAccount();
|
|
TestUserHasNoShowRightsForAccounts();
|
|
|
|
PrepareUserWithSpecialRights();
|
|
TestUserHasRightOnlyToSeeOwnAccountsSuccessful();
|
|
TestUserHasRightOnlyToSeeOwnAccountsFailed();
|
|
}
|
|
|
|
private void TestUserHasRightOnlyToSeeOwnAccountsFailed()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var result = session.GetBL<AccountAddressWebServiceBL>().GetAccountAddresses(GetLoggedInUser(16),
|
|
new GetAccountAddressesFilter()
|
|
{
|
|
IsDefault = true,
|
|
AccountI3Ds = new List<int>() { 5, 11 }
|
|
});
|
|
Assert.True(result.Status == ResultStatus.Error, "Expected error, because user should have no show rights");
|
|
Assert.True(result.MessageCode == DefaultMessageCodes.RightCheckFailed, "Expected right check failed message code");
|
|
Assert.True(result.Data == null || !result.Data.Any(), "Expected empty result list");
|
|
}
|
|
|
|
private void TestUserHasRightOnlyToSeeOwnAccountsSuccessful()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var result = session.GetBL<AccountAddressWebServiceBL>().GetAccountAddresses(GetLoggedInUser(16),
|
|
new GetAccountAddressesFilter()
|
|
{
|
|
IsDefault = true,
|
|
AccountI3Ds = new List<int>() { 5 }
|
|
});
|
|
Assert.True(result.Status == ResultStatus.Success, result.Message);
|
|
Assert.True(result.Data.Count == 1, "Expected 1 address");
|
|
}
|
|
|
|
private void PrepareUserWithSpecialRights()
|
|
{
|
|
using var session = new BLSession();
|
|
session.GetBL<AppRightsBL>().AddRightToRightGroup(
|
|
UserRightsConst.Sales.Customer.CustomerCommon.SHOW_ONLY_OWN_CUSTOMER, 40, GetLoggedInUser().User);
|
|
}
|
|
|
|
private void TestUserHasNoShowRightsForAccounts()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var result = session.GetBL<AccountAddressWebServiceBL>().GetAccountAddresses(GetLoggedInUser(18),
|
|
new GetAccountAddressesFilter()
|
|
{
|
|
IsDefault = true,
|
|
AccountI3Ds = new List<int>() { 10, 16 }
|
|
});
|
|
Assert.True(result.Status == ResultStatus.Error, "Expected error, because user should have no show rights");
|
|
Assert.True(result.MessageCode == DefaultMessageCodes.RightCheckFailed, "Expected right check failed message code");
|
|
Assert.True(result.Data == null || !result.Data.Any(), "Expected empty result list");
|
|
}
|
|
|
|
private void GetDefaultAddressForAccount()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var result = session.GetBL<AccountAddressWebServiceBL>().GetAccountAddresses(GetLoggedInUser(),
|
|
new GetAccountAddressesFilter()
|
|
{
|
|
IsDefault = true,
|
|
AccountI3Ds = new List<int>() { 10, 16 }
|
|
});
|
|
Assert.True(result.Status == ResultStatus.Success, result.Message);
|
|
Assert.True(result.Data.Count == 2, "Expected 2 addresses");
|
|
Assert.True(result.Data.All(f => f.IsDefault), "Expected only default addresses");
|
|
Assert.True(result.Data.All(f => f.Contacts == null || !f.Contacts.Any()), "Expected empty contact list");
|
|
}
|
|
|
|
private void GetSingleAccountAddressWithContacts()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
var result = session.GetBL<AccountAddressWebServiceBL>().GetAccountAddresses(GetLoggedInUser(),
|
|
new GetAccountAddressesFilter()
|
|
{
|
|
AddressI3Ds = new List<int>()
|
|
{
|
|
25
|
|
},
|
|
IncludeContacts = true
|
|
});
|
|
Assert.True(result.Status == ResultStatus.Success, result.Message);
|
|
Assert.True(result.Data.Count == 1 && result.Data.All(f => f.I3D == 25), "Expected 1 item with I3D = 25");
|
|
Assert.True(result.Data.First().Contacts.Any(), "Expected a contact list for account address");
|
|
}
|
|
|
|
public void TestLoadWithContacts()
|
|
{
|
|
var result = this.WithSession(s => s.GetBL<AccountAddressWebServiceBL>().GetAccountAddresses(this.GetLoggedInUser(), new GetAccountAddressesFilter
|
|
{
|
|
AccountI3Ds = new List<int>
|
|
{
|
|
10,
|
|
16
|
|
},
|
|
IncludeClosedAddresses = true,
|
|
IncludeContacts = true
|
|
})).ThrowIfError();
|
|
|
|
this.Verifier.Verify("AddressesWithContacts", result);
|
|
}
|
|
}
|
|
} |