/// <summary> /// Validates incoming SharedProfileUpdateItem update item. /// </summary> /// <param name="UpdateItem">Update item to validate.</param> /// <param name="Index">Item index in the update message.</param> /// <param name="SharedProfilesCount">Number of profiles the neighbor already shares with the profile server.</param> /// <param name="UsedProfileIdsInBatch">List of profile network IDs of already validated items of this batch.</param> /// <param name="MessageBuilder">Client's network message builder.</param> /// <param name="RequestMessage">Full request message received by the client.</param> /// <param name="ErrorResponse">If the validation fails, this is filled with response message to be sent to the neighbor.</param> /// <returns>true if the validation is successful, false otherwise.</returns> public static bool ValidateSharedProfileUpdateItem(SharedProfileUpdateItem UpdateItem, int Index, int SharedProfilesCount, HashSet <byte[]> UsedProfileIdsInBatch, PsMessageBuilder MessageBuilder, PsProtocolMessage RequestMessage, out PsProtocolMessage ErrorResponse) { log.Trace("(Index:{0},SharedProfilesCount:{1})", Index, SharedProfilesCount); bool res = false; ErrorResponse = null; if (UpdateItem == null) { UpdateItem = new SharedProfileUpdateItem(); } switch (UpdateItem.ActionTypeCase) { case SharedProfileUpdateItem.ActionTypeOneofCase.Add: res = ValidateSharedProfileAddItem(UpdateItem.Add, Index, SharedProfilesCount, UsedProfileIdsInBatch, MessageBuilder, RequestMessage, out ErrorResponse); break; case SharedProfileUpdateItem.ActionTypeOneofCase.Change: res = ValidateSharedProfileChangeItem(UpdateItem.Change, Index, UsedProfileIdsInBatch, MessageBuilder, RequestMessage, out ErrorResponse); break; case SharedProfileUpdateItem.ActionTypeOneofCase.Delete: res = ValidateSharedProfileDeleteItem(UpdateItem.Delete, Index, UsedProfileIdsInBatch, MessageBuilder, RequestMessage, out ErrorResponse); break; case SharedProfileUpdateItem.ActionTypeOneofCase.Refresh: res = true; break; default: ErrorResponse = MessageBuilder.CreateErrorProtocolViolationResponse(RequestMessage); res = false; break; } log.Trace("(-):{0}", res); return(res); }
/// <summary> /// Implementation of the test itself. /// </summary> /// <returns>true if the test passes, false otherwise.</returns> public override async Task <bool> RunAsync() { IPAddress ServerIp = (IPAddress)ArgumentValues["Server IP"]; int PrimaryPort = (int)ArgumentValues["primary Port"]; int BasePort = (int)ArgumentValues["Base Port"]; int LocPort = (int)ArgumentValues["LOC Port"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1},BasePort:{2},LocPort:{3})", ServerIp, PrimaryPort, BasePort, LocPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); ProfileServer profileServer = null; LocServer locServer = null; try { MessageBuilder mb = client.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. await client.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await client.ListServerPorts(rolePorts); client.CloseConnection(); // Create identities. ProfilePublicKeys = new List <byte[]>(); for (int i = 0; i < ProfileNames.Count; i++) { ProtocolClient protocolClient = new ProtocolClient(); ProfilePublicKeys.Add(protocolClient.GetIdentityKeys().PublicKey); protocolClient.Dispose(); } // Start simulated profile server. profileServer = new ProfileServer("TestProfileServer", ServerIp, BasePort, client.GetIdentityKeys(), new GpsLocation(1, 2)); bool profileServerStartOk = profileServer.Start(); // Start simulated LOC server. locServer = new LocServer("TestLocServer", ServerIp, LocPort); bool locServerStartOk = locServer.Start(); await locServer.WaitForProfileServerConnectionAsync(); bool step1Ok = profileServerStartOk && locServerStartOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); // Initialize the original set of update messages update. List <SharedProfileUpdateItem> originalAddUpdateItems = new List <SharedProfileUpdateItem>(); for (int i = 0; i < ProfileNames.Count; i++) { SharedProfileUpdateItem updateItem = new SharedProfileUpdateItem() { Add = new SharedProfileAddItem() { Version = SemVer.V100.ToByteString(), Name = ProfileNames[i], Type = ProfileTypes[i], ExtraData = ProfileExtraData[i] != null ? ProfileExtraData[i] : "", Latitude = ProfileLocations[i].GetLocationTypeLatitude(), Longitude = ProfileLocations[i].GetLocationTypeLongitude(), IdentityPublicKey = ProtocolHelper.ByteArrayToByteString(ProfilePublicKeys[i]), SetThumbnailImage = ProfileImages[i] != null, ThumbnailImage = ProtocolHelper.ByteArrayToByteString(ProfileImages[i] != null ? File.ReadAllBytes(ProfileImages[i]) : new byte[0]) } }; originalAddUpdateItems.Add(updateItem); } // Neighborhood initialization process. // Announce new neighbor. Iop.Locnet.NeighbourhoodChange change = new Iop.Locnet.NeighbourhoodChange() { AddedNodeInfo = profileServer.GetNodeInfo(LocPort) }; bool addNeighborOk = await locServer.SendChangeNotification(change); // Wait for start of neighborhood initialization process. IncomingServerMessage incomingServerMessage = await profileServer.WaitForConversationRequest(ServerRole.ServerNeighbor, ConversationRequest.RequestTypeOneofCase.StartNeighborhoodInitialization); List <SharedProfileUpdateItem> updateItems = new List <SharedProfileUpdateItem>(); updateItems.Add(originalAddUpdateItems[0]); updateItems.Add(originalAddUpdateItems[1]); updateItems.Add(originalAddUpdateItems[5]); updateItems.Add(originalAddUpdateItems[6]); SharedProfileUpdateItem changeItem0 = new SharedProfileUpdateItem() { Change = new SharedProfileChangeItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(originalAddUpdateItems[0].Add.IdentityPublicKey.ToByteArray())), } }; SharedProfileUpdateItem changeItem1 = new SharedProfileUpdateItem() { Change = new SharedProfileChangeItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(originalAddUpdateItems[1].Add.IdentityPublicKey.ToByteArray())), SetName = true, Name = "X" } }; List <SharedProfileUpdateItem> originalUpdateItems = new List <SharedProfileUpdateItem>(); originalUpdateItems.Add(changeItem1); originalUpdateItems.Add(originalAddUpdateItems[2]); originalUpdateItems.Add(originalAddUpdateItems[3]); originalUpdateItems.Add(originalAddUpdateItems[4]); Message requestMessage = await profileServer.SendNeighborhoodSharedProfileUpdateRequest(incomingServerMessage.Client, updateItems); incomingServerMessage = await profileServer.WaitForResponse(ServerRole.ServerNeighbor, requestMessage); bool statusOk = incomingServerMessage.IncomingMessage.Response.Status == Status.Ok; bool updateOk = statusOk; // Finish neighborhood initialization process. Message finishRequest = await profileServer.SendFinishNeighborhoodInitializationRequest(incomingServerMessage.Client); incomingServerMessage = await profileServer.WaitForResponse(ServerRole.ServerNeighbor, finishRequest); statusOk = incomingServerMessage.IncomingMessage.Response.Status == Status.Ok; bool finishOk = (finishRequest != null) && statusOk; bool step2Ok = addNeighborOk && updateOk && finishOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool verifyIdentityOk = await client.VerifyIdentityAsync(); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Version = ProtocolHelper.ByteArrayToByteString(new byte[] { 1, 0 }); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.version"); bool step3Ok = verifyIdentityOk && updateOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Version = ProtocolHelper.ByteArrayToByteString(new byte[] { 0, 0, 0 }); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.version"); bool step4Ok = verifyIdentityOk && updateOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.IdentityPublicKey = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(new string ('a', 300))); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.identityPublicKey"); bool step5Ok = updateOk; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 log.Trace("Step 6"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.IdentityPublicKey = originalAddUpdateItems[0].Add.IdentityPublicKey; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.identityPublicKey"); bool step6Ok = updateOk; log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED"); // Step 7 log.Trace("Step 7"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Name = new string('a', 70); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.name"); bool step7Ok = updateOk; log.Trace("Step 7: {0}", step7Ok ? "PASSED" : "FAILED"); // Step 8 log.Trace("Step 8"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Name = new string('ɐ', 50); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.name"); bool step8Ok = updateOk; log.Trace("Step 8: {0}", step8Ok ? "PASSED" : "FAILED"); // Step 9 log.Trace("Step 9"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Type = new string('a', 70); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.type"); bool step9Ok = updateOk; log.Trace("Step 9: {0}", step9Ok ? "PASSED" : "FAILED"); // Step 10 log.Trace("Step 10"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Type = new string('ɐ', 50); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.type"); bool step10Ok = updateOk; log.Trace("Step 10: {0}", step10Ok ? "PASSED" : "FAILED"); // Step 11 log.Trace("Step 11"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Type = ""; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.type"); bool step11Ok = updateOk; log.Trace("Step 11: {0}", step11Ok ? "PASSED" : "FAILED"); // Step 12 log.Trace("Step 12"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.SetThumbnailImage = true; updateItems[1].Add.ThumbnailImage = ProtocolHelper.ByteArrayToByteString(new byte[0]); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.thumbnailImage"); bool step12Ok = updateOk; log.Trace("Step 12: {0}", step12Ok ? "PASSED" : "FAILED"); // Step 13 log.Trace("Step 13"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.SetThumbnailImage = true; updateItems[1].Add.ThumbnailImage = ProtocolHelper.ByteArrayToByteString(new byte[] { 0, 1, 2 }); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.thumbnailImage"); bool step13Ok = updateOk; log.Trace("Step 13: {0}", step13Ok ? "PASSED" : "FAILED"); // Step 14 log.Trace("Step 14"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Latitude = 987654321; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.latitude"); bool step14Ok = updateOk; log.Trace("Step 14: {0}", step14Ok ? "PASSED" : "FAILED"); // Step 15 log.Trace("Step 15"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Longitude = 987654321; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.longitude"); bool step15Ok = updateOk; log.Trace("Step 15: {0}", step15Ok ? "PASSED" : "FAILED"); // Step 16 log.Trace("Step 16"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.ExtraData = new string('a', 270); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.extraData"); bool step16Ok = updateOk; log.Trace("Step 16: {0}", step16Ok ? "PASSED" : "FAILED"); // Step 17 log.Trace("Step 17"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.ExtraData = new string('ɐ', 150); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.extraData"); bool step17Ok = updateOk; log.Trace("Step 17: {0}", step17Ok ? "PASSED" : "FAILED"); // Step 18 log.Trace("Step 18"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem() { Change = new SharedProfileChangeItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(originalAddUpdateItems[0].Add.IdentityPublicKey.ToByteArray())), } }; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.set*"); bool step18Ok = updateOk; log.Trace("Step 18: {0}", step18Ok ? "PASSED" : "FAILED"); // Step 19 log.Trace("Step 19"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem() { Change = new SharedProfileChangeItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(new byte[] { 0, 1, 2 }), SetName = true, Name = "X" } }; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.identityNetworkId"); bool step19Ok = updateOk; log.Trace("Step 19: {0}", step19Ok ? "PASSED" : "FAILED"); // Step 20 log.Trace("Step 20"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[0] = new SharedProfileUpdateItem() { Change = new SharedProfileChangeItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(originalAddUpdateItems[0].Add.IdentityPublicKey.ToByteArray())), SetName = true, Name = "X" } }; updateItems[1] = new SharedProfileUpdateItem() { Delete = new SharedProfileDeleteItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(originalAddUpdateItems[0].Add.IdentityPublicKey.ToByteArray())), } }; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.delete.identityNetworkId"); bool step20Ok = updateOk; log.Trace("Step 20: {0}", step20Ok ? "PASSED" : "FAILED"); // Step 21 log.Trace("Step 21"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[0] = new SharedProfileUpdateItem(originalAddUpdateItems[2]); updateItems[1] = new SharedProfileUpdateItem() { Change = new SharedProfileChangeItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(originalAddUpdateItems[2].Add.IdentityPublicKey.ToByteArray())), SetName = true, Name = "X" } }; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.identityNetworkId"); bool step21Ok = updateOk; log.Trace("Step 21: {0}", step21Ok ? "PASSED" : "FAILED"); // Step 22 log.Trace("Step 22"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[0] = new SharedProfileUpdateItem() { Change = new SharedProfileChangeItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(originalAddUpdateItems[2].Add.IdentityPublicKey.ToByteArray())), SetName = true, Name = "X" } }; updateItems[1] = new SharedProfileUpdateItem(originalAddUpdateItems[2]); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.identityPublicKey"); bool step22Ok = updateOk; log.Trace("Step 22: {0}", step22Ok ? "PASSED" : "FAILED"); // Step 23 log.Trace("Step 23"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetVersion = true; updateItems[1].Change.Version = ProtocolHelper.ByteArrayToByteString(new byte[] { 1, 0 }); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.version"); bool step23Ok = updateOk; log.Trace("Step 23: {0}", step23Ok ? "PASSED" : "FAILED"); // Step 24 log.Trace("Step 24"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetVersion = true; updateItems[1].Change.Version = ProtocolHelper.ByteArrayToByteString(new byte[] { 0, 0, 0 }); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.version"); bool step24Ok = updateOk; log.Trace("Step 24: {0}", step24Ok ? "PASSED" : "FAILED"); // Step 25 log.Trace("Step 25"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetName = true; updateItems[1].Change.Name = new string('a', 70); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.name"); bool step25Ok = updateOk; log.Trace("Step 25: {0}", step25Ok ? "PASSED" : "FAILED"); // Step 26 log.Trace("Step 26"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetName = true; updateItems[1].Change.Name = new string('ɐ', 50); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.name"); bool step26Ok = updateOk; log.Trace("Step 26: {0}", step26Ok ? "PASSED" : "FAILED"); // Step 27 log.Trace("Step 27"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetThumbnailImage = true; updateItems[1].Change.ThumbnailImage = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(new string((char)0x40, 6000))); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.thumbnailImage"); bool step27Ok = updateOk; log.Trace("Step 27: {0}", step27Ok ? "PASSED" : "FAILED"); // Step 28 log.Trace("Step 28"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetThumbnailImage = true; updateItems[1].Change.ThumbnailImage = ProtocolHelper.ByteArrayToByteString(new byte[] { 0, 1, 2 }); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.thumbnailImage"); bool step28Ok = updateOk; log.Trace("Step 28: {0}", step28Ok ? "PASSED" : "FAILED"); // Step 29 log.Trace("Step 29"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetLocation = true; updateItems[1].Change.Latitude = 987654321; updateItems[1].Change.Longitude = 0; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.latitude"); bool step29Ok = updateOk; log.Trace("Step 29: {0}", step29Ok ? "PASSED" : "FAILED"); // Step 30 log.Trace("Step 30"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetLocation = true; updateItems[1].Change.Latitude = 0; updateItems[1].Change.Longitude = 987654321; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.longitude"); bool step30Ok = updateOk; log.Trace("Step 30: {0}", step30Ok ? "PASSED" : "FAILED"); // Step 31 log.Trace("Step 31"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetExtraData = true; updateItems[1].Change.ExtraData = new string('a', 270); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.extraData"); bool step31Ok = updateOk; log.Trace("Step 31: {0}", step31Ok ? "PASSED" : "FAILED"); // Step 32 log.Trace("Step 32"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetExtraData = true; updateItems[1].Change.ExtraData = new string('ɐ', 150); updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.extraData"); bool step32Ok = updateOk; log.Trace("Step 32: {0}", step32Ok ? "PASSED" : "FAILED"); // Step 33 log.Trace("Step 33"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem() { Delete = new SharedProfileDeleteItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(new byte[] { 0, 1, 2 }) } }; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.delete.identityNetworkId"); bool step33Ok = updateOk; log.Trace("Step 33: {0}", step33Ok ? "PASSED" : "FAILED"); // Step 34 log.Trace("Step 34"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(updateItems[1]); updateItems[1].Add.Name = ""; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.add.name"); bool step34Ok = updateOk; log.Trace("Step 34: {0}", step34Ok ? "PASSED" : "FAILED"); // Step 35 log.Trace("Step 35"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[1] = new SharedProfileUpdateItem(changeItem0); updateItems[1].Change.SetName = true; updateItems[1].Change.Name = ""; updateOk = await PerformNeighborhoodUpdateAsync(updateItems, client, "1.change.name"); bool step35Ok = updateOk; log.Trace("Step 35: {0}", step35Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok && step7Ok && step8Ok && step9Ok && step10Ok && step11Ok && step12Ok && step13Ok && step14Ok && step15Ok && step16Ok && step17Ok && step18Ok && step19Ok && step20Ok && step21Ok && step22Ok && step23Ok && step24Ok && step25Ok && step26Ok && step27Ok && step28Ok && step29Ok && step30Ok && step31Ok && step32Ok && step33Ok && step34Ok && step35Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); if (profileServer != null) { profileServer.Shutdown(); } if (locServer != null) { locServer.Shutdown(); } log.Trace("(-):{0}", res); return(res); }
/// <summary> /// Implementation of the test itself. /// </summary> /// <returns>true if the test passes, false otherwise.</returns> public override async Task <bool> RunAsync() { IPAddress ServerIp = (IPAddress)ArgumentValues["Server IP"]; int PrimaryPort = (int)ArgumentValues["primary Port"]; int BasePort = (int)ArgumentValues["Base Port"]; int LocPort = (int)ArgumentValues["LOC Port"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1},BasePort:{2},LocPort:{3})", ServerIp, PrimaryPort, BasePort, LocPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); ProfileServer profileServer = null; LocServer locServer = null; try { MessageBuilder mb = client.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. await client.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await client.ListServerPorts(rolePorts); client.CloseConnection(); // Create identities. int profileNumber = 0; byte[] imageData = File.ReadAllBytes(Path.Combine("images", TestName + ".png")); Dictionary <string, ProtocolClient> expectedLastClients = new Dictionary <string, ProtocolClient>(StringComparer.Ordinal); List <string> excessClientNames = new List <string>(); for (int i = 0; i < 20050; i++) { ProtocolClient protocolClient = new ProtocolClient(); protocolClient.InitializeRandomProfile(profileNumber, imageData); profileNumber++; if (i >= 19990) { protocolClient.Profile.Type = "last"; if (i < 20000) { expectedLastClients.Add(protocolClient.Profile.Name, protocolClient); } else { excessClientNames.Add(protocolClient.Profile.Name); } } TestProfiles.Add(protocolClient.Profile.Name, protocolClient); } // Start simulated profile server. profileServer = new ProfileServer("TestProfileServer", ServerIp, BasePort, client.GetIdentityKeys(), new GpsLocation(1, 2)); bool profileServerStartOk = profileServer.Start(); // Start simulated LOC server. locServer = new LocServer("TestLocServer", ServerIp, LocPort); bool locServerStartOk = locServer.Start(); await locServer.WaitForProfileServerConnectionAsync(); bool step1Ok = profileServerStartOk && locServerStartOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); // Announce new neighbor. Iop.Locnet.NeighbourhoodChange change = new Iop.Locnet.NeighbourhoodChange() { AddedNodeInfo = profileServer.GetNodeInfo(LocPort) }; bool changeNotificationOk = await locServer.SendChangeNotification(change); // Wait for start of neighborhood initialization process. IncomingServerMessage incomingServerMessage = await profileServer.WaitForConversationRequest(ServerRole.ServerNeighbor, ConversationRequest.RequestTypeOneofCase.StartNeighborhoodInitialization); // Send update. bool statusOk = false; bool updateOk = true; int profilesSent = 0; List <ProtocolClient> allProfiles = new List <ProtocolClient>(TestProfiles.Values); List <ProtocolClient> profilesToSend = allProfiles.GetRange(0, 19990); while (profilesToSend.Count > 0) { int batchSize = Math.Min(Rng.Next(100, 150), profilesToSend.Count); List <SharedProfileUpdateItem> updateItems = new List <SharedProfileUpdateItem>(); foreach (ProtocolClient pc in profilesToSend.GetRange(0, batchSize)) { updateItems.Add(pc.GetSharedProfileUpdateAddItem()); } profilesToSend.RemoveRange(0, batchSize); Message updateRequest = await profileServer.SendNeighborhoodSharedProfileUpdateRequest(incomingServerMessage.Client, updateItems); profilesSent += batchSize; incomingServerMessage = await profileServer.WaitForResponse(ServerRole.ServerNeighbor, updateRequest); statusOk = incomingServerMessage.IncomingMessage.Response.Status == Status.Ok; bool batchOk = (updateRequest != null) && statusOk; if (!batchOk) { updateOk = false; break; } } // Finish neighborhood initialization process. Message finishRequest = await profileServer.SendFinishNeighborhoodInitializationRequest(incomingServerMessage.Client); incomingServerMessage = await profileServer.WaitForResponse(ServerRole.ServerNeighbor, finishRequest); statusOk = incomingServerMessage.IncomingMessage.Response.Status == Status.Ok; bool finishOk = (finishRequest != null) && statusOk; bool step2Ok = changeNotificationOk && updateOk && finishOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool verifyIdentityOk = await client.VerifyIdentityAsync(); List <SharedProfileUpdateItem> badUpdateItems = new List <SharedProfileUpdateItem>(); foreach (ProtocolClient pc in allProfiles.GetRange(19990, 60)) { badUpdateItems.Add(pc.GetSharedProfileUpdateAddItem()); } Message requestMessage = mb.CreateNeighborhoodSharedProfileUpdateRequest(badUpdateItems); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; bool detailsOk = responseMessage.Response.Details == "10.add"; bool badUpdateOk = idOk && statusOk && detailsOk; client.CloseConnection(); // Step 3 Acceptance bool step3Ok = verifyIdentityOk && badUpdateOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); // Start conversation. await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool startConversationOk = await client.StartConversationAsync(); HashSet <byte[]> expectedCoveredServers = new HashSet <byte[]>(StructuralEqualityComparer <byte[]> .Default) { client.GetIdentityId(), Crypto.Sha256(client.ServerKey) }; // Search all profiles with type "last". requestMessage = mb.CreateProfileSearchRequest("last", null, null, null, 0, 100, 100); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool totalRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == 10; bool maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100; bool profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == 10; bool resultsOk = client.CheckProfileListMatchSearchResultItems(expectedLastClients, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.ToList(), false, false, client.GetIdentityId(), true); bool queryOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && resultsOk; client.CloseConnection(); // Step 4 Acceptance bool step4Ok = startConversationOk && queryOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); // Make TestProfiles reflect the status on the target profile server. foreach (string excessClientName in excessClientNames) { TestProfiles[excessClientName].Dispose(); TestProfiles.Remove(excessClientName); } await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); verifyIdentityOk = await client.VerifyIdentityAsync(); // Select 140 profiles for deletion. List <SharedProfileUpdateItem> deleteUpdateItems = new List <SharedProfileUpdateItem>(); while (deleteUpdateItems.Count < 140) { int index = Rng.Next(TestProfiles.Count); ProtocolClient pc = TestProfiles.ElementAt(index).Value; deleteUpdateItems.Add(pc.GetSharedProfileUpdateDeleteItem()); if (expectedLastClients.ContainsKey(pc.Profile.Name)) { expectedLastClients.Remove(pc.Profile.Name); } TestProfiles.Remove(pc.Profile.Name); pc.Dispose(); } // Send delete update. requestMessage = mb.CreateNeighborhoodSharedProfileUpdateRequest(deleteUpdateItems); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool deleteUpdateOk = idOk && statusOk; // Generate 160 new identities. badUpdateItems.Clear(); excessClientNames.Clear(); for (int i = 0; i < 160; i++) { ProtocolClient protocolClient = new ProtocolClient(); protocolClient.InitializeRandomProfile(profileNumber, imageData); profileNumber++; protocolClient.Profile.Type = "last"; if (TestProfiles.Count < 20000) { expectedLastClients.Add(protocolClient.Profile.Name, protocolClient); } else { excessClientNames.Add(protocolClient.Profile.Name); } TestProfiles.Add(protocolClient.Profile.Name, protocolClient); badUpdateItems.Add(protocolClient.GetSharedProfileUpdateAddItem()); } // Add the new profiles to the profile server. requestMessage = mb.CreateNeighborhoodSharedProfileUpdateRequest(badUpdateItems); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "140.add"; badUpdateOk = idOk && statusOk && detailsOk; client.CloseConnection(); // Step 5 Acceptance bool step5Ok = verifyIdentityOk && deleteUpdateOk && badUpdateOk; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 log.Trace("Step 6"); // Make TestProfiles reflect the status on the target profile server. foreach (string excessClientName in excessClientNames) { TestProfiles[excessClientName].Dispose(); TestProfiles.Remove(excessClientName); } // Start conversation. await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); startConversationOk = await client.StartConversationAsync(); // Search all profiles with type "last". requestMessage = mb.CreateProfileSearchRequest("last", null, null, null, 0, 1000, 1000, false, false); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; totalRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == expectedLastClients.Count; maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 1000; profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == expectedLastClients.Count; resultsOk = client.CheckProfileListMatchSearchResultItems(expectedLastClients, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.ToList(), false, false, client.GetIdentityId(), false); queryOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && resultsOk; client.CloseConnection(); // Step 6 Acceptance bool step6Ok = startConversationOk && queryOk; log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED"); // Step 7 log.Trace("Step 7"); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); verifyIdentityOk = await client.VerifyIdentityAsync(); // Select 40 profiles for deletion. deleteUpdateItems = new List <SharedProfileUpdateItem>(); while (deleteUpdateItems.Count < 40) { int index = Rng.Next(TestProfiles.Count); ProtocolClient pc = TestProfiles.ElementAt(index).Value; deleteUpdateItems.Add(pc.GetSharedProfileUpdateDeleteItem()); if (expectedLastClients.ContainsKey(pc.Profile.Name)) { expectedLastClients.Remove(pc.Profile.Name); } TestProfiles.Remove(pc.Profile.Name); pc.Dispose(); } // Select 40 profiles for change, but avoid updating one profile twice in a single update message, which is forbidden. HashSet <int> usedIndexes = new HashSet <int>(); List <SharedProfileUpdateItem> changeUpdateItems = new List <SharedProfileUpdateItem>(); while (changeUpdateItems.Count < 40) { int index = Rng.Next(TestProfiles.Count); if (usedIndexes.Contains(index)) { continue; } usedIndexes.Add(index); ProtocolClient pc = TestProfiles.ElementAt(index).Value; pc.Profile.ExtraData = "1234567890"; SharedProfileUpdateItem changeUpdateItem = new SharedProfileUpdateItem() { Change = new SharedProfileChangeItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(pc.GetIdentityId()), SetExtraData = true, ExtraData = pc.Profile.ExtraData } }; changeUpdateItems.Add(changeUpdateItem); } // Generate 40 new identities. List <SharedProfileUpdateItem> addUpdateItems = new List <SharedProfileUpdateItem>(); for (int i = 0; i < 40; i++) { ProtocolClient protocolClient = new ProtocolClient(); protocolClient.InitializeRandomProfile(profileNumber, imageData); profileNumber++; protocolClient.Profile.Type = "last"; expectedLastClients.Add(protocolClient.Profile.Name, protocolClient); TestProfiles.Add(protocolClient.Profile.Name, protocolClient); addUpdateItems.Add(protocolClient.GetSharedProfileUpdateAddItem()); } // Send all the updates as one. List <SharedProfileUpdateItem> newUpdateItems = new List <SharedProfileUpdateItem>(); newUpdateItems.AddRange(deleteUpdateItems); newUpdateItems.AddRange(changeUpdateItems); newUpdateItems.AddRange(addUpdateItems); requestMessage = mb.CreateNeighborhoodSharedProfileUpdateRequest(newUpdateItems); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool newUpdateOk = idOk && statusOk; client.CloseConnection(); // Step 7 Acceptance bool step7Ok = verifyIdentityOk && newUpdateOk; log.Trace("Step 7: {0}", step7Ok ? "PASSED" : "FAILED"); // Step 8 log.Trace("Step 8"); // Start conversation. await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); startConversationOk = await client.StartConversationAsync(); // Search all profiles with type "last". requestMessage = mb.CreateProfileSearchRequest("last", null, null, null, 0, 1000, 1000, false, false); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; totalRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == expectedLastClients.Count; maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 1000; profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == expectedLastClients.Count; resultsOk = client.CheckProfileListMatchSearchResultItems(expectedLastClients, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.ToList(), false, false, client.GetIdentityId(), false); queryOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && resultsOk; client.CloseConnection(); // Step 8 Acceptance bool step8Ok = startConversationOk && queryOk; log.Trace("Step 8: {0}", step8Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok && step7Ok && step8Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); foreach (ProtocolClient protocolClient in TestProfiles.Values) { protocolClient.Dispose(); } if (profileServer != null) { profileServer.Shutdown(); } if (locServer != null) { locServer.Shutdown(); } log.Trace("(-):{0}", res); return(res); }
/// <summary> /// Implementation of the test itself. /// </summary> /// <returns>true if the test passes, false otherwise.</returns> public override async Task <bool> RunAsync() { IPAddress ServerIp = (IPAddress)ArgumentValues["Server IP"]; int PrimaryPort = (int)ArgumentValues["primary Port"]; int BasePort = (int)ArgumentValues["Base Port"]; int LocPort = (int)ArgumentValues["LOC Port"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1},BasePort:{2},LocPort:{3})", ServerIp, PrimaryPort, BasePort, LocPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); ProfileServer profileServer = null; LocServer locServer = null; try { MessageBuilder mb = client.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. await client.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await client.ListServerPorts(rolePorts); client.CloseConnection(); // Create identities. ProfilePublicKeys = new List <byte[]>(); for (int i = 0; i < ProfileNames.Count; i++) { ProtocolClient protocolClient = new ProtocolClient(); ProfilePublicKeys.Add(protocolClient.GetIdentityKeys().PublicKey); protocolClient.Dispose(); } // Start simulated profile server. profileServer = new ProfileServer("TestProfileServer", ServerIp, BasePort, client.GetIdentityKeys(), new GpsLocation(1, 2)); bool profileServerStartOk = profileServer.Start(); // Start simulated LOC server. locServer = new LocServer("TestLocServer", ServerIp, LocPort); bool locServerStartOk = locServer.Start(); await locServer.WaitForProfileServerConnectionAsync(); bool step1Ok = profileServerStartOk && locServerStartOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); // Initialize the original set of update messages update. List <SharedProfileUpdateItem> originalUpdateItems = new List <SharedProfileUpdateItem>(); for (int i = 0; i < ProfileNames.Count; i++) { SharedProfileUpdateItem updateItem = new SharedProfileUpdateItem() { Add = new SharedProfileAddItem() { Version = SemVer.V100.ToByteString(), Name = ProfileNames[i], Type = ProfileTypes[i], ExtraData = ProfileExtraData[i] != null ? ProfileExtraData[i] : "", Latitude = ProfileLocations[i].GetLocationTypeLatitude(), Longitude = ProfileLocations[i].GetLocationTypeLongitude(), IdentityPublicKey = ProtocolHelper.ByteArrayToByteString(ProfilePublicKeys[i]), SetThumbnailImage = ProfileImages[i] != null, ThumbnailImage = ProtocolHelper.ByteArrayToByteString(ProfileImages[i] != null ? File.ReadAllBytes(ProfileImages[i]) : new byte[0]) } }; originalUpdateItems.Add(updateItem); } List <SharedProfileUpdateItem> updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Version = ProtocolHelper.ByteArrayToByteString(new byte[] { 1, 0 }); bool initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.version"); bool step2Ok = initOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Version = ProtocolHelper.ByteArrayToByteString(new byte[] { 0, 0, 0 }); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.version"); bool step3Ok = initOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.IdentityPublicKey = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(new string ('a', 300))); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.identityPublicKey"); bool step4Ok = initOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.IdentityPublicKey = updateItems[0].Add.IdentityPublicKey; initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.identityPublicKey"); bool step5Ok = initOk; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 log.Trace("Step 6"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Name = new string('a', 70); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.name"); bool step6Ok = initOk; log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED"); // Step 7 log.Trace("Step 7"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Name = new string('ɐ', 50); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.name"); bool step7Ok = initOk; log.Trace("Step 7: {0}", step7Ok ? "PASSED" : "FAILED"); // Step 8 log.Trace("Step 8"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Type = new string('a', 70); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.type"); bool step8Ok = initOk; log.Trace("Step 8: {0}", step8Ok ? "PASSED" : "FAILED"); // Step 9 log.Trace("Step 9"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Type = new string('ɐ', 50); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.type"); bool step9Ok = initOk; log.Trace("Step 9: {0}", step9Ok ? "PASSED" : "FAILED"); // Step 10 log.Trace("Step 10"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Type = ""; initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.type"); bool step10Ok = initOk; log.Trace("Step 10: {0}", step10Ok ? "PASSED" : "FAILED"); // Step 11 log.Trace("Step 11"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.SetThumbnailImage = true; updateItems[2].Add.ThumbnailImage = ProtocolHelper.ByteArrayToByteString(new byte[0]); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.thumbnailImage"); bool step11Ok = initOk; log.Trace("Step 11: {0}", step11Ok ? "PASSED" : "FAILED"); // Step 12 log.Trace("Step 12"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.SetThumbnailImage = true; updateItems[2].Add.ThumbnailImage = ProtocolHelper.ByteArrayToByteString(new byte[] { 0, 1, 2 }); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.thumbnailImage"); bool step12Ok = initOk; log.Trace("Step 12: {0}", step12Ok ? "PASSED" : "FAILED"); // Step 13 log.Trace("Step 13"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Latitude = 987654321; initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.latitude"); bool step13Ok = initOk; log.Trace("Step 13: {0}", step13Ok ? "PASSED" : "FAILED"); // Step 14 log.Trace("Step 14"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Longitude = 987654321; initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.longitude"); bool step14Ok = initOk; log.Trace("Step 14: {0}", step14Ok ? "PASSED" : "FAILED"); // Step 15 log.Trace("Step 15"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.ExtraData = new string('a', 270); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.extraData"); bool step15Ok = initOk; log.Trace("Step 15: {0}", step15Ok ? "PASSED" : "FAILED"); // Step 16 log.Trace("Step 16"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.ExtraData = new string('ɐ', 150); initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.extraData"); bool step16Ok = initOk; log.Trace("Step 16: {0}", step16Ok ? "PASSED" : "FAILED"); // Step 17 log.Trace("Step 17"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem() { Change = new SharedProfileChangeItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(updateItems[0].Add.IdentityPublicKey.ToByteArray())) } }; initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.actionType"); bool step17Ok = initOk; log.Trace("Step 17: {0}", step17Ok ? "PASSED" : "FAILED"); // Step 18 log.Trace("Step 18"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem() { Delete = new SharedProfileDeleteItem() { IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(Crypto.Sha256(updateItems[0].Add.IdentityPublicKey.ToByteArray())) } }; initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.actionType"); bool step18Ok = initOk; log.Trace("Step 18: {0}", step18Ok ? "PASSED" : "FAILED"); // Step 19 log.Trace("Step 19"); updateItems = new List <SharedProfileUpdateItem>(originalUpdateItems); updateItems[2] = new SharedProfileUpdateItem(updateItems[2]); updateItems[2].Add.Name = ""; initOk = await PerformInitializationProcessWithUpdateItemsAsync(updateItems, profileServer, locServer, "2.add.name"); bool step19Ok = initOk; log.Trace("Step 19: {0}", step19Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok && step7Ok && step8Ok && step9Ok && step10Ok && step11Ok && step12Ok && step13Ok && step14Ok && step15Ok && step16Ok && step17Ok && step18Ok && step19Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); if (profileServer != null) { profileServer.Shutdown(); } if (locServer != null) { locServer.Shutdown(); } log.Trace("(-):{0}", res); return(res); }