diff --git a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs index a93b6a0b2..1cceb8069 100644 --- a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs +++ b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs @@ -241,9 +241,9 @@ private async Task AnalyseAppZone(Management mgt) if (existingAppZone is not null) { - WfReqTask? taskEntryNewAppZone = TaskList.FirstOrDefault(x => x.Title == userConfig.GetText("new_app_zone") + existingAppZone.IdString && x.OnManagement?.Id == mgt.Id); - WfReqTask? taskEntryUpdateAppZone = TaskList.FirstOrDefault(x => x.Title == userConfig.GetText("update_app_zone") + existingAppZone.IdString + userConfig.GetText("add_members") && x.OnManagement?.Id == mgt.Id); - WfReqTask? taskEntryDeleteAppZone = DeleteTasksList.FirstOrDefault(x => x.Title == userConfig.GetText("update_app_zone") + existingAppZone.IdString + userConfig.GetText("remove_members") && x.OnManagement?.Id == mgt.Id); + WfReqTask? taskEntryNewAppZone = TaskList.FirstOrDefault(x => x.Title == userConfig.GetText("new_app_zone") + existingAppZone.Name && x.OnManagement?.Id == mgt.Id); + WfReqTask? taskEntryUpdateAppZone = TaskList.FirstOrDefault(x => x.Title == userConfig.GetText("update_app_zone") + existingAppZone.Name + userConfig.GetText("add_members") && x.OnManagement?.Id == mgt.Id); + WfReqTask? taskEntryDeleteAppZone = DeleteTasksList.FirstOrDefault(x => x.Title == userConfig.GetText("update_app_zone") + existingAppZone.Name + userConfig.GetText("remove_members") && x.OnManagement?.Id == mgt.Id); if (!ResolveExistingApp(existingAppZone, mgt) && taskEntryNewAppZone is null) { @@ -275,7 +275,7 @@ private bool ResolveExistingApp(ModellingNwGroup app, Management mgt) string sanitizedARName = Sanitizer.SanitizeJsonFieldMand(app.IdString, ref shortened); if (allExistingAppRoles.ContainsKey(mgt.Id)) { - existingApp = allExistingAppRoles[mgt.Id].FirstOrDefault(a => a.Name == app.IdString || a.Name == sanitizedARName); + existingApp = allExistingAppRoles[mgt.Id].FirstOrDefault(a => a.Name == app.IdString || a.Name == sanitizedARName || a.Name == app.Name); } if (existingApp != null) { @@ -405,27 +405,30 @@ private void RequestUpdateApp(ModellingNwGroup app, Management mgt) { string title = ""; string additionalInfoKeys = ""; + string groupName = ""; if (app.GetType() == typeof(ModellingAppRole)) { title = userConfig.GetText("update_app_role"); additionalInfoKeys = AdditionalInfoKeys.AppRoleId; + groupName = app.IdString; } else if (app.GetType() == typeof(ModellingAppZone)) { title = userConfig.GetText("update_app_zone"); additionalInfoKeys = AdditionalInfoKeys.AppZoneId; + groupName = app.Name; } - FillGroupMembers(app.IdString, mgt); - Dictionary? addInfo = new() { { AdditionalInfoKeys.GrpName, app.IdString }, { additionalInfoKeys, app.Id.ToString() } }; + FillGroupMembers(groupName, mgt); + Dictionary? addInfo = new() { { AdditionalInfoKeys.GrpName, groupName }, { additionalInfoKeys, app.Id.ToString() } }; if (newGroupMembers.Count > 0) { newGroupMembers.AddRange(unchangedGroupMembers); newGroupMembers.AddRange(unchangedGroupMembersDuringCreate); // will be deleted later TaskList.Add(new() { - Title = title + app.IdString + userConfig.GetText("add_members"), + Title = title + groupName + userConfig.GetText("add_members"), TaskType = WfTaskType.group_modify.ToString(), RequestAction = RequestAction.modify.ToString(), ManagementId = mgt.Id, @@ -440,7 +443,7 @@ private void RequestUpdateApp(ModellingNwGroup app, Management mgt) deletedGroupMembers.AddRange(newCreatedGroupMembers); DeleteTasksList.Add(new() { - Title = title + app.IdString + userConfig.GetText("remove_members"), + Title = title + groupName + userConfig.GetText("remove_members"), TaskType = WfTaskType.group_modify.ToString(), RequestAction = RequestAction.modify.ToString(), ManagementId = mgt.Id, diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs index bff36f10a..95de2e7b8 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTest.cs @@ -106,19 +106,19 @@ public async Task TestAnalyseModelledConnections() ClassicAssert.AreEqual("source", TaskList[1].Elements[0].Field); ClassicAssert.AreEqual("addAfterCreation", TaskList[1].Elements[0].RequestAction); - ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[2].TaskType); + ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[2].TaskType); ClassicAssert.AreEqual("{\"GrpName\":\"AZ4711\",\"AppZoneId\":\"3\"}", TaskList[2].AdditionalInfo); - ClassicAssert.AreEqual("create", TaskList[2].RequestAction); + ClassicAssert.AreEqual("modify", TaskList[2].RequestAction); ClassicAssert.AreEqual(3, TaskList[2].TaskNumber); - ClassicAssert.AreEqual("New AppZone: AZ4711", TaskList[2].Title); + ClassicAssert.AreEqual("Update AppZone: AZ4711: Add Members", TaskList[2].Title); ClassicAssert.AreEqual(2, TaskList[2].Elements.Count); - ClassicAssert.AreEqual("AppServer1", TaskList[2].Elements[0].Name); - ClassicAssert.AreEqual("AppServer2", TaskList[2].Elements[1].Name); + ClassicAssert.AreEqual("AppServer2", TaskList[2].Elements[0].Name); + ClassicAssert.AreEqual("AppServer1", TaskList[2].Elements[1].Name); ClassicAssert.AreEqual("AZ4711", TaskList[2].Elements[0].GroupName); - ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[0].IpString); - ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[0].IpEnd); - ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[1].IpString); - ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[1].IpEnd); + ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[1].IpString); + ClassicAssert.AreEqual("1.1.1.1/32", TaskList[2].Elements[1].IpEnd); + ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[0].IpString); + ClassicAssert.AreEqual("2.2.2.2/32", TaskList[2].Elements[0].IpEnd); ClassicAssert.AreEqual("source", TaskList[2].Elements[0].Field); ClassicAssert.AreEqual("addAfterCreation", TaskList[2].Elements[0].RequestAction); @@ -191,7 +191,7 @@ public async Task TestAnalyseModelledConnections() ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[0].TaskType); ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[1].TaskType); ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[2].TaskType); - ClassicAssert.AreEqual(WfTaskType.group_create.ToString(), TaskList[3].TaskType); + ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[3].TaskType); ClassicAssert.AreEqual(WfTaskType.access.ToString(), TaskList[4].TaskType); ClassicAssert.AreEqual(WfTaskType.group_modify.ToString(), TaskList[5].TaskType); diff --git a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs index ce928af52..741aea4bd 100644 --- a/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs +++ b/roles/test/files/FWO.Test/ModellingVarianceAnalysisTestApiConn.cs @@ -15,7 +15,7 @@ internal class ModellingVarianceAnalysisTestApiConn : SimulatedApiConnection static readonly NetworkObject Nwgroup1 = new() { Id = 1, Name = "AR504711-001", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }, new() { Object = NwObj3 }] }; static readonly ModellingAppServer AppServer1 = new() { Id = 13, Name = "AppServer1", Ip = "1.1.1.1/32", IpEnd = "1.1.1.1/32" }; static readonly ModellingAppServer AppServer2 = new() { Id = 14, Name = "AppServer2", Ip = "2.2.2.2/32", IpEnd = "2.2.2.2/32" }; - static readonly NetworkObject AZProd = new() { Id = 2, Name = "AZ4711", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }, new() { Object = NwObj2 }] }; + static readonly NetworkObject AZProd = new() { Id = 2, Name = "AZ4711", Type = new() { Name = ObjectType.Group }, ObjectGroupFlats = [new() { Object = NwObj1 }] }; static readonly ModellingAppZone AZExist = new() { Id = 3, Name = "AZ4711", AppServers = new() { new() { Content = AppServer1 }, new() { Content = AppServer2 } } }; public override async Task SendQueryAsync(string query, object? variables = null, string? operationName = null)