/// <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 ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; int ClCustomerPort = (int)ArgumentValues["clCustomer Port"]; log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1},ClCustomerPort:{2})", ServerIp, ClNonCustomerPort, ClCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); try { MessageBuilder mb = client.MessageBuilder; // Step 1 await client.ConnectAsync(ServerIp, ClNonCustomerPort, true); bool establishHostingOk = await client.EstablishHostingAsync(); // Step 1 Acceptance bool step1Ok = establishHostingOk; client.CloseConnection(); // Step 2 await client.ConnectAsync(ServerIp, ClCustomerPort, true); bool startConversationOk = await client.StartConversationAsync(); Message requestMessage = mb.CreateUpdateProfileRequest(SemVer.V100, "Test Identity", null, new GpsLocation(0, 0), null); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.ErrorUnauthorized; bool updateProfileOk = idOk && statusOk; // Step 2 Acceptance bool step2Ok = startConversationOk && updateProfileOk; Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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 NodeIp = (IPAddress)ArgumentValues["Node IP"]; int ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1})", NodeIp, ClNonCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); try { MessageBuilder mb = client.MessageBuilder; // Step 1 await client.ConnectAsync(NodeIp, ClNonCustomerPort, true); bool establishHomeNodeOk = await client.EstablishHomeNodeAsync(); // Step 1 Acceptance bool step1Ok = establishHomeNodeOk; client.CloseConnection(); // Step 2 await client.ConnectAsync(NodeIp, ClNonCustomerPort, true); bool verifyIdentityOk = await client.VerifyIdentityAsync(); Message requestMessage = mb.CreateUpdateProfileRequest(new byte[] { 1, 0, 0 }, "Test Identity", null, 0x12345678, null); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.ErrorUnauthorized; bool updateProfileOk = idOk && statusOk; // Step 2 Acceptance bool step2Ok = verifyIdentityOk && updateProfileOk; Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient client1 = new ProtocolClient(); ProtocolClient client2 = new ProtocolClient(); try { MessageBuilder mb = client1.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. await client1.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await client1.ListServerPorts(rolePorts); client1.CloseConnection(); bool profileInitializationOk = true; byte[] testImageData = File.ReadAllBytes(Path.Combine("images", TestName + ".jpg")); int profileIndex = 1; int profileCount = 10; for (int i = 0; i < profileCount; i++) { ProtocolClient profileClient = new ProtocolClient(); profileClient.InitializeRandomProfile(profileIndex, testImageData); profileIndex++; if (await profileClient.RegisterAndInitializeProfileAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], (int)rolePorts[ServerRoleType.ClCustomer])) { TestProfiles.Add(profileClient.Profile.Name, profileClient); } else { profileClient.Dispose(); profileInitializationOk = false; break; } } bool step1Ok = listPortsOk && profileInitializationOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await client1.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool neighborhoodInitializationProcessOk = await client1.NeighborhoodInitializationProcessAsync(1, 1, TestProfiles); client1.CloseConnection(); bool step2Ok = neighborhoodInitializationProcessOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); await client2.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool verifyIdentityOk = await client2.VerifyIdentityAsync(); // Start neighborhood initialization process. Message requestMessage = client2.MessageBuilder.CreateStartNeighborhoodInitializationRequest(2, 2); await client2.SendMessageAsync(requestMessage); Message responseMessage = await client2.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.ErrorRejected; bool startNeighborhoodInitializationOk = idOk && statusOk; bool step3Ok = profileInitializationOk && startNeighborhoodInitializationOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client1.Dispose(); client2.Dispose(); foreach (ProtocolClient protocolClient in TestProfiles.Values) { protocolClient.Dispose(); } 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); 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(); // Start conversation. await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool startConversationOk = await client.StartConversationAsync(); // Search profile requests. Message requestMessage = mb.CreateProfileSearchRequest(null, null, null, null, 0, 0, 1000, false, true); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; bool detailsOk = responseMessage.Response.Details == "maxResponseRecordCount"; bool query1Ok = idOk && statusOk && detailsOk; requestMessage = mb.CreateProfileSearchRequest(null, null, null, null, 0, 200, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "maxResponseRecordCount"; bool query2Ok = idOk && statusOk && detailsOk; requestMessage = mb.CreateProfileSearchRequest(null, null, null, null, 0, 1200, 2000, false, false); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "maxResponseRecordCount"; bool query3Ok = idOk && statusOk && detailsOk; requestMessage = mb.CreateProfileSearchRequest(null, null, null, null, 0, 50, 25, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "maxResponseRecordCount"; bool query4Ok = idOk && statusOk && detailsOk; requestMessage = mb.CreateProfileSearchRequest(null, null, null, null, 0, 50, 1001, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "maxTotalRecordCount"; bool query5Ok = idOk && statusOk && detailsOk; requestMessage = mb.CreateProfileSearchRequest(null, null, null, null, 0, 50, 10010, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "maxTotalRecordCount"; bool query6Ok = idOk && statusOk && detailsOk; string type = new string('a', 70); requestMessage = mb.CreateProfileSearchRequest(type, null, null, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "type"; bool query7Ok = idOk && statusOk && detailsOk; type = new string('ɐ', 50); requestMessage = mb.CreateProfileSearchRequest(type, null, null, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "type"; bool query8Ok = idOk && statusOk && detailsOk; string name = new string('a', 70); requestMessage = mb.CreateProfileSearchRequest(null, name, null, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "name"; bool query9Ok = idOk && statusOk && detailsOk; name = new string('ɐ', 50); requestMessage = mb.CreateProfileSearchRequest(null, name, null, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "name"; bool query10Ok = idOk && statusOk && detailsOk; GpsLocation loc = new GpsLocation(-90000001, 1); requestMessage = mb.CreateProfileSearchRequest(null, null, null, loc, 1, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "latitude"; bool query11Ok = idOk && statusOk && detailsOk; loc = new GpsLocation(90000001, 1); requestMessage = mb.CreateProfileSearchRequest(null, null, null, loc, 1, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "latitude"; bool query12Ok = idOk && statusOk && detailsOk; loc = new GpsLocation(1, -180000000); requestMessage = mb.CreateProfileSearchRequest(null, null, null, loc, 1, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "longitude"; bool query13Ok = idOk && statusOk && detailsOk; loc = new GpsLocation(1, 180000001); requestMessage = mb.CreateProfileSearchRequest(null, null, null, loc, 1, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "longitude"; bool query14Ok = idOk && statusOk && detailsOk; loc = new GpsLocation(1, 1); requestMessage = mb.CreateProfileSearchRequest(null, null, null, loc, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "radius"; bool query15Ok = idOk && statusOk && detailsOk; string extraData = new string('a', 300); requestMessage = mb.CreateProfileSearchRequest(null, null, extraData, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "extraData"; bool query16Ok = idOk && statusOk && detailsOk; extraData = new string('ɐ', 150); requestMessage = mb.CreateProfileSearchRequest(null, null, extraData, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "extraData"; bool query17Ok = idOk && statusOk && detailsOk; extraData = @"(^|;)key=([^=]+;)?va(?'alpha')lue($|,|;)"; requestMessage = mb.CreateProfileSearchRequest(null, null, extraData, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "extraData"; bool query18Ok = idOk && statusOk && detailsOk; extraData = @"iuawhefiuhawef\aaerwergj"; requestMessage = mb.CreateProfileSearchRequest(null, null, extraData, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "extraData"; bool query19Ok = idOk && statusOk && detailsOk; extraData = @"aerghearg\beraarg"; requestMessage = mb.CreateProfileSearchRequest(null, null, extraData, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "extraData"; bool query20Ok = idOk && statusOk && detailsOk; extraData = @"afewafawefwaef\"; requestMessage = mb.CreateProfileSearchRequest(null, null, extraData, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "extraData"; bool query21Ok = idOk && statusOk && detailsOk; extraData = @"(^|;)key=([^=]+;)?(?<double>A)B<double>($|,|;)"; requestMessage = mb.CreateProfileSearchRequest(null, null, extraData, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "extraData"; bool query22Ok = idOk && statusOk && detailsOk; extraData = @"(^|;)key=rai??n($|,|;)"; requestMessage = mb.CreateProfileSearchRequest(null, null, extraData, null, 0, 100, 1000, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "extraData"; bool query23Ok = idOk && statusOk && detailsOk; // Step 1 Acceptance bool step1Ok = listPortsOk && startConversationOk && query1Ok && query2Ok && query3Ok && query4Ok && query5Ok && query6Ok && query7Ok && query8Ok && query9Ok && query10Ok && query11Ok && query12Ok && query13Ok && query14Ok && query15Ok && query16Ok && query17Ok && query18Ok && query19Ok && query20Ok && query21Ok && query22Ok && query23Ok; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 1 log.Trace("Step 2"); requestMessage = mb.CreateProfileSearchPartRequest(10, 20); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorNotAvailable; // Step 2 Acceptance bool step2Ok = idOk && statusOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); ProfileServer profileServer = 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(); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool verifyIdentityOk = await client.VerifyIdentityAsync(); Message requestMessage = mb.CreateFinishNeighborhoodInitializationRequest(); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.ErrorRejected; bool finishNeighborhoodInitializationOk = idOk && statusOk; requestMessage = mb.CreateNeighborhoodSharedProfileUpdateRequest(); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorRejected; bool neighborhoodSharedProfileUpdateOk = idOk && statusOk; requestMessage = mb.CreateStopNeighborhoodUpdatesRequest(); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorNotFound; bool stopNeighborhoodUpdatesOk = idOk && statusOk; bool step1Ok = listPortsOk && verifyIdentityOk && finishNeighborhoodInitializationOk && neighborhoodSharedProfileUpdateOk && stopNeighborhoodUpdatesOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); Passed = step1Ok; 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(); } 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 NodeIp = (IPAddress)ArgumentValues["Node IP"]; int ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; int ClCustomerPort = (int)ArgumentValues["clCustomer Port"]; log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1},ClCustomerPort:{2})", NodeIp, ClNonCustomerPort, ClCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); try { MessageBuilder mb = client.MessageBuilder; byte[] testIdentityId = client.GetIdentityId(); // Step 1 await client.ConnectAsync(NodeIp, ClNonCustomerPort, true); bool establishHomeNodeOk = await client.EstablishHomeNodeAsync(); // Step 1 Acceptance bool step1Ok = establishHomeNodeOk; client.CloseConnection(); // Step 2 await client.ConnectAsync(NodeIp, ClCustomerPort, true); bool checkInOk = await client.CheckInAsync(); byte[] newNodeId = Crypto.Sha1(Encoding.UTF8.GetBytes("test")); Message requestMessage = mb.CreateCancelHomeNodeAgreementRequest(newNodeId); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool cancelAgreementOk = idOk && statusOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted == false; bool isTargetHomeNodeKnownOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsTargetHomeNodeKnown; byte[] receivedHomeNodeId = responseMessage.Response.SingleResponse.GetIdentityInformation.TargetHomeNodeNetworkId.ToByteArray(); bool targetHomeNodeIdOk = StructuralComparisons.StructuralComparer.Compare(receivedHomeNodeId, newNodeId) == 0; bool getIdentityInfoOk = idOk && statusOk && isHostedOk && isTargetHomeNodeKnownOk && targetHomeNodeIdOk; // Step 2 Acceptance bool step2Ok = checkInOk && cancelAgreementOk && getIdentityInfoOk; Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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 ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; int ClCustomerPort = (int)ArgumentValues["clCustomer Port"]; log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1},ClCustomerPort:{2})", ServerIp, ClNonCustomerPort, ClCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); try { MessageBuilder mb = client.MessageBuilder; // Step 1 await client.ConnectAsync(ServerIp, ClNonCustomerPort, true); bool establishHostingOk = await client.EstablishHostingAsync(); // Step 1 Acceptance bool step1Ok = establishHostingOk; client.CloseConnection(); // Step 2 await client.ConnectAsync(ServerIp, ClCustomerPort, true); bool startConversationOk = await client.StartConversationAsync(); // Invalidate the challenge. byte[] challenge = new byte[client.Challenge.Length]; Array.Copy(client.Challenge, challenge, client.Challenge.Length); challenge[0] ^= 0x12; Message requestMessage = mb.CreateCheckInRequest(challenge); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; bool detailsOk = responseMessage.Response.Details == "challenge"; bool checkInOk = idOk && statusOk && detailsOk; // Step 2 Acceptance bool step2Ok = startConversationOk && checkInOk; Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1},BasePort:{2})", ServerIp, PrimaryPort, BasePort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); ProfileServer profileServer = 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(); bool profileInitializationOk = true; byte[] testImageData = File.ReadAllBytes(Path.Combine("images", TestName + ".jpg")); int profileIndex = 1; int profileCount = 10; for (int i = 0; i < profileCount; i++) { ProtocolClient profileClient = new ProtocolClient(); profileClient.InitializeRandomProfile(profileIndex, testImageData); profileIndex++; if (!await profileClient.RegisterAndInitializeProfileAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], (int)rolePorts[ServerRoleType.ClCustomer])) { profileClient.Dispose(); profileInitializationOk = false; break; } TestProfiles.Add(profileClient.Profile.Name, profileClient); } profileServer = new ProfileServer("TestServer", ServerIp, BasePort, client.GetIdentityKeys()); bool serverStartOk = profileServer.Start(); bool step1Ok = listPortsOk && profileInitializationOk && serverStartOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool neighborhoodInitializationProcessOk = await client.NeighborhoodInitializationProcessAsync(profileServer.PrimaryPort, 1, TestProfiles); bool step2Ok = neighborhoodInitializationProcessOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); profileInitializationOk = true; profileCount = 5; Dictionary<string, ProtocolClient> newProfiles = new Dictionary<string, ProtocolClient>(StringComparer.Ordinal); for (int i = 0; i < profileCount; i++) { ProtocolClient profileClient = new ProtocolClient(); profileClient.InitializeRandomProfile(profileIndex, testImageData); profileIndex++; if (!await profileClient.RegisterAndInitializeProfileAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], (int)rolePorts[ServerRoleType.ClCustomer])) { profileClient.Dispose(); profileInitializationOk = false; break; } TestProfiles.Add(profileClient.Profile.Name, profileClient); newProfiles.Add(profileClient.Profile.Name, profileClient); } // Wait at most 12 minutes for updates from the server. List<SharedProfileAddItem> addUpdates = new List<SharedProfileAddItem>(); bool profilesOk = false; for (int time = 0; time < 12 * 60; time++) { await Task.Delay(1000); // Meanwhile we expect updates to arrive on our simulated profile server. bool error = false; List<IncomingServerMessage> psMessages = profileServer.GetMessageList(); foreach (IncomingServerMessage ism in psMessages) { if (ism.Role != ServerRole.ServerNeighbor) continue; Message message = ism.IncomingMessage; if ((message.MessageTypeCase == Message.MessageTypeOneofCase.Request) && (message.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.ConversationRequest) && (message.Request.ConversationRequest.RequestTypeCase == ConversationRequest.RequestTypeOneofCase.NeighborhoodSharedProfileUpdate)) { foreach (SharedProfileUpdateItem updateItem in message.Request.ConversationRequest.NeighborhoodSharedProfileUpdate.Items) { if (updateItem.ActionTypeCase == SharedProfileUpdateItem.ActionTypeOneofCase.Add) { SharedProfileAddItem addItem = updateItem.Add; addUpdates.Add(addItem); } else { log.Trace("Received invalid update action type {0}.", updateItem.ActionTypeCase); error = true; break; } } } if (error) break; } // Terminate if any error occurred. if (error) break; // Terminate if the received profiles match what is expected. profilesOk = client.CheckProfileListMatchAddItems(newProfiles, addUpdates); if (profilesOk) break; // Terminate if we do not expect any more updates to come. if (addUpdates.Count >= newProfiles.Count) break; } bool step3Ok = profileInitializationOk && profilesOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok; 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(); 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. for (int i = 0; i < ProfileNames.Count; i++) { byte[] imageData = ProfileImages[i] != null?File.ReadAllBytes(ProfileImages[i]) : null; ProtocolClient profileClient = new ProtocolClient(); profileClient.Profile = new ClientProfile() { Version = SemVer.V100, Name = ProfileNames[i], Type = ProfileTypes[i], ProfileImage = imageData, ThumbnailImage = imageData, Location = ProfileLocations[i], ExtraData = ProfileExtraData[i], PublicKey = profileClient.GetIdentityKeys().PublicKey }; TestProfiles.Add(profileClient.Profile.Name, profileClient); } // 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. List <SharedProfileUpdateItem> updateItems = new List <SharedProfileUpdateItem>(); foreach (ProtocolClient pc in TestProfiles.Values) { updateItems.Add(pc.GetSharedProfileUpdateAddItem()); } Message updateRequest = await profileServer.SendNeighborhoodSharedProfileUpdateRequest(incomingServerMessage.Client, updateItems); incomingServerMessage = await profileServer.WaitForResponse(ServerRole.ServerNeighbor, updateRequest); bool statusOk = incomingServerMessage.IncomingMessage.Response.Status == Status.Ok; bool updateOk = (updateRequest != null) && 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 = changeNotificationOk && updateOk && finishOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool startConversationOk = await client.StartConversationAsync(); Message requestMessage = mb.CreateProfileSearchRequest(null, null, null, null, 0, 100, 100, false, true); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; HashSet <byte[]> expectedCoveredServers = new HashSet <byte[]>(StructuralEqualityComparer <byte[]> .Default) { client.GetIdentityId(), Crypto.Sha256(client.ServerKey) }; HashSet <byte[]> realCoveredServers = new HashSet <byte[]>(StructuralEqualityComparer <byte[]> .Default); foreach (ByteString csId in responseMessage.Response.ConversationResponse.ProfileSearch.CoveredServers) { realCoveredServers.Add(csId.ToByteArray()); } bool coveredServersOk = expectedCoveredServers.SetEquals(realCoveredServers); bool profileListOk = client.CheckProfileListMatchSearchResultItems(TestProfiles, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.ToList(), false, false, client.GetIdentityId(), true); // Step 3 Acceptance bool step3Ok = startConversationOk && idOk && statusOk && profileListOk && coveredServersOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok; 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> 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient client1 = new ProtocolClient(); ProtocolClient client2 = new ProtocolClient(); try { MessageBuilder mb = client1.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. await client1.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await client1.ListServerPorts(rolePorts); client1.CloseConnection(); bool profileInitializationOk = true; byte[] testImageData = File.ReadAllBytes(Path.Combine("images", TestName + ".jpg")); int profileIndex = 1; int profileCount = 10; for (int i = 0; i < profileCount; i++) { ProtocolClient profileClient = new ProtocolClient(); profileClient.InitializeRandomProfile(profileIndex, testImageData); profileIndex++; if (await profileClient.RegisterAndInitializeProfileAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], (int)rolePorts[ServerRoleType.ClCustomer])) { TestProfiles.Add(profileClient.Profile.Name, profileClient); } else { profileClient.Dispose(); profileInitializationOk = false; break; } } bool step1Ok = listPortsOk && profileInitializationOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await client1.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool verifyIdentityOk = await client1.VerifyIdentityAsync(); // Start neighborhood initialization process. Message requestMessage = mb.CreateStartNeighborhoodInitializationRequest(1, 1); await client1.SendMessageAsync(requestMessage); Message responseMessage = await client1.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool startNeighborhoodInitializationOk = idOk && statusOk; bool step2Ok = verifyIdentityOk && startNeighborhoodInitializationOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); await client2.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); verifyIdentityOk = await client2.VerifyIdentityAsync(); // Start neighborhood initialization process. requestMessage = client2.MessageBuilder.CreateStartNeighborhoodInitializationRequest(2, 2); await client2.SendMessageAsync(requestMessage); responseMessage = await client2.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorBusy; startNeighborhoodInitializationOk = idOk && statusOk; client2.CloseConnection(); bool step3Ok = verifyIdentityOk && startNeighborhoodInitializationOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); // Wait for update request. Message serverRequestMessage = null; Message clientResponseMessage = null; bool typeOk = false; List <SharedProfileAddItem> receivedItems = new List <SharedProfileAddItem>(); bool error = false; while (receivedItems.Count < TestProfiles.Count) { serverRequestMessage = await client1.ReceiveMessageAsync(); typeOk = serverRequestMessage.MessageTypeCase == Message.MessageTypeOneofCase.Request && serverRequestMessage.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.ConversationRequest && serverRequestMessage.Request.ConversationRequest.RequestTypeCase == ConversationRequest.RequestTypeOneofCase.NeighborhoodSharedProfileUpdate; clientResponseMessage = mb.CreateNeighborhoodSharedProfileUpdateResponse(serverRequestMessage); await client1.SendMessageAsync(clientResponseMessage); if (!typeOk) { break; } foreach (SharedProfileUpdateItem updateItem in serverRequestMessage.Request.ConversationRequest.NeighborhoodSharedProfileUpdate.Items) { if (updateItem.ActionTypeCase != SharedProfileUpdateItem.ActionTypeOneofCase.Add) { log.Trace("Received invalid update item action type '{0}'.", updateItem.ActionTypeCase); error = true; break; } receivedItems.Add(updateItem.Add); } if (error) { break; } } log.Trace("Received {0} profiles from target profile server.", receivedItems.Count); bool receivedProfilesOk = !error && client1.CheckProfileListMatchAddItems(TestProfiles, receivedItems); // Wait for finish request. serverRequestMessage = await client1.ReceiveMessageAsync(); typeOk = serverRequestMessage.MessageTypeCase == Message.MessageTypeOneofCase.Request && serverRequestMessage.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.ConversationRequest && serverRequestMessage.Request.ConversationRequest.RequestTypeCase == ConversationRequest.RequestTypeOneofCase.FinishNeighborhoodInitialization; bool finishNeighborhoodInitializationResponseOk = typeOk; clientResponseMessage = mb.CreateFinishNeighborhoodInitializationResponse(serverRequestMessage); await client1.SendMessageAsync(clientResponseMessage); client1.CloseConnection(); bool step4Ok = verifyIdentityOk && startNeighborhoodInitializationOk && receivedProfilesOk && finishNeighborhoodInitializationResponseOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); await client2.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool neighborhoodInitializationProcessOk = await client2.NeighborhoodInitializationProcessAsync(2, 2, TestProfiles); client2.CloseConnection(); bool step5Ok = neighborhoodInitializationProcessOk; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client1.Dispose(); client2.Dispose(); foreach (ProtocolClient protocolClient in TestProfiles.Values) { protocolClient.Dispose(); } 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1},BasePort:{2})", ServerIp, PrimaryPort, BasePort); bool res = false; Passed = false; ProtocolClient client1 = new ProtocolClient(); ProtocolClient client2 = new ProtocolClient(0, SemVer.V100, client1.GetIdentityKeys()); ProfileServer profileServer = null; try { MessageBuilder mb1 = client1.MessageBuilder; MessageBuilder mb2 = client2.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. await client1.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await client1.ListServerPorts(rolePorts); client1.CloseConnection(); bool profileInitializationOk = true; byte[] testImageData = File.ReadAllBytes(Path.Combine("images", TestName + ".jpg")); int profileIndex = 1; int profileCount = 10; for (int i = 0; i < profileCount; i++) { ProtocolClient profileClient = new ProtocolClient(); profileClient.InitializeRandomProfile(profileIndex, testImageData); profileIndex++; if (!await profileClient.RegisterAndInitializeProfileAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], (int)rolePorts[ServerRoleType.ClCustomer])) { profileClient.Dispose(); profileInitializationOk = false; break; } TestProfiles.Add(profileClient.Profile.Name, profileClient); } profileServer = new ProfileServer("TestServer", ServerIp, BasePort, client1.GetIdentityKeys()); bool serverStartOk = profileServer.Start(); bool step1Ok = listPortsOk && profileInitializationOk && serverStartOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await client1.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool verifyIdentityOk = await client1.VerifyIdentityAsync(); // Start neighborhood initialization process. Message requestMessage = mb1.CreateStartNeighborhoodInitializationRequest((uint)profileServer.PrimaryPort, (uint)profileServer.ServerNeighborPort); await client1.SendMessageAsync(requestMessage); Message responseMessage = await client1.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool startNeighborhoodInitializationOk = idOk && statusOk; // Wait for update request. Message serverRequestMessage = null; Message clientResponseMessage = null; List <SharedProfileAddItem> receivedItems = new List <SharedProfileAddItem>(); bool error = false; while (!error) { serverRequestMessage = await client1.ReceiveMessageAsync(); bool isNspUpdate = serverRequestMessage.MessageTypeCase == Message.MessageTypeOneofCase.Request && serverRequestMessage.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.ConversationRequest && serverRequestMessage.Request.ConversationRequest.RequestTypeCase == ConversationRequest.RequestTypeOneofCase.NeighborhoodSharedProfileUpdate; bool isNspFinish = serverRequestMessage.MessageTypeCase == Message.MessageTypeOneofCase.Request && serverRequestMessage.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.ConversationRequest && serverRequestMessage.Request.ConversationRequest.RequestTypeCase == ConversationRequest.RequestTypeOneofCase.FinishNeighborhoodInitialization; if (isNspFinish) { break; } if (!isNspUpdate) { error = true; break; } clientResponseMessage = mb1.CreateNeighborhoodSharedProfileUpdateResponse(serverRequestMessage); await client1.SendMessageAsync(clientResponseMessage); foreach (SharedProfileUpdateItem updateItem in serverRequestMessage.Request.ConversationRequest.NeighborhoodSharedProfileUpdate.Items) { if (updateItem.ActionTypeCase != SharedProfileUpdateItem.ActionTypeOneofCase.Add) { log.Trace("Received invalid update item action type '{0}'.", updateItem.ActionTypeCase); error = true; break; } log.Trace("Received profile name '{0}'.", updateItem.Add.Name); receivedItems.Add(updateItem.Add); } if (error) { break; } } bool step2Ok = verifyIdentityOk && startNeighborhoodInitializationOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); profileInitializationOk = true; profileCount = 5; for (int i = 0; i < profileCount; i++) { ProtocolClient profileClient = new ProtocolClient(); profileClient.InitializeRandomProfile(profileIndex, testImageData); profileIndex++; if (!await profileClient.RegisterAndInitializeProfileAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], (int)rolePorts[ServerRoleType.ClCustomer])) { profileClient.Dispose(); profileInitializationOk = false; break; } TestProfiles.Add(profileClient.Profile.Name, profileClient); } bool step3Ok = profileInitializationOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); await client2.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); verifyIdentityOk = await client2.VerifyIdentityAsync(); // Start neighborhood initialization process. requestMessage = mb1.CreateStartNeighborhoodInitializationRequest((uint)profileServer.PrimaryPort, (uint)profileServer.ServerNeighborPort); await client2.SendMessageAsync(requestMessage); responseMessage = await client2.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorAlreadyExists; startNeighborhoodInitializationOk = idOk && statusOk; client2.CloseConnection(); bool step4Ok = verifyIdentityOk && startNeighborhoodInitializationOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); clientResponseMessage = mb1.CreateFinishNeighborhoodInitializationResponse(serverRequestMessage); await client1.SendMessageAsync(clientResponseMessage); client1.CloseConnection(); await Task.Delay(20000); bool step5Ok = !error; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 log.Trace("Step 6"); // Meanwhile we expect updates to arrive on our simulated profile server. error = false; List <IncomingServerMessage> psMessages = profileServer.GetMessageList(); foreach (IncomingServerMessage ism in psMessages) { if (ism.Role != ServerRole.ServerNeighbor) { continue; } Message message = ism.IncomingMessage; if ((message.MessageTypeCase == Message.MessageTypeOneofCase.Request) && (message.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.ConversationRequest) && (message.Request.ConversationRequest.RequestTypeCase == ConversationRequest.RequestTypeOneofCase.NeighborhoodSharedProfileUpdate)) { foreach (SharedProfileUpdateItem updateItem in message.Request.ConversationRequest.NeighborhoodSharedProfileUpdate.Items) { if (updateItem.ActionTypeCase == SharedProfileUpdateItem.ActionTypeOneofCase.Add) { SharedProfileAddItem addItem = updateItem.Add; receivedItems.Add(addItem); log.Trace("Received profile name '{0}'.", updateItem.Add.Name); } else { log.Trace("Received invalid update action type {0}.", updateItem.ActionTypeCase); error = true; break; } } } if (error) { break; } } bool receivedUpdatesOk = !error; bool profilesOk = client1.CheckProfileListMatchAddItems(TestProfiles, receivedItems); bool step6Ok = receivedUpdatesOk && profilesOk; log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client1.Dispose(); client2.Dispose(); foreach (ProtocolClient protocolClient in TestProfiles.Values) { protocolClient.Dispose(); } if (profileServer != null) { profileServer.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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); 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(); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool verifyIdentityOk = await client.VerifyIdentityAsync(); Message requestMessage = mb.CreateStartNeighborhoodInitializationRequest(0, 1); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; bool detailsOk = responseMessage.Response.Details == "primaryPort"; bool startNeighborhoodInitializationOk1 = idOk && statusOk && detailsOk; requestMessage = mb.CreateStartNeighborhoodInitializationRequest(1, 0); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "srNeighborPort"; bool startNeighborhoodInitializationOk2 = idOk && statusOk && detailsOk; requestMessage = mb.CreateStartNeighborhoodInitializationRequest(100000, 1); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "primaryPort"; bool startNeighborhoodInitializationOk3 = idOk && statusOk && detailsOk; requestMessage = mb.CreateStartNeighborhoodInitializationRequest(1, 100000); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "srNeighborPort"; bool startNeighborhoodInitializationOk4 = idOk && statusOk && detailsOk; bool step1Ok = listPortsOk && startNeighborhoodInitializationOk1 && startNeighborhoodInitializationOk2 && startNeighborhoodInitializationOk3 && startNeighborhoodInitializationOk4; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); Passed = step1Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient clientCallee = new ProtocolClient(); ProtocolClient clientCalleeAppService = new ProtocolClient(0, SemVer.V100, clientCallee.GetIdentityKeys()); ProtocolClient clientCaller = new ProtocolClient(); ProtocolClient clientCallerAppService = new ProtocolClient(0, SemVer.V100, clientCaller.GetIdentityKeys()); try { MessageBuilder mbCallee = clientCallee.MessageBuilder; MessageBuilder mbCalleeAppService = clientCalleeAppService.MessageBuilder; MessageBuilder mbCaller = clientCaller.MessageBuilder; MessageBuilder mbCallerAppService = clientCallerAppService.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. byte[] pubKeyCallee = clientCallee.GetIdentityKeys().PublicKey; byte[] identityIdCallee = clientCallee.GetIdentityId(); byte[] pubKeyCaller = clientCaller.GetIdentityKeys().PublicKey; byte[] identityIdCaller = clientCaller.GetIdentityId(); await clientCallee.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await clientCallee.ListServerPorts(rolePorts); clientCallee.CloseConnection(); // Establish hosting agreement for identity 1. await clientCallee.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool establishHostingOk = await clientCallee.EstablishHostingAsync(); clientCallee.CloseConnection(); // Check-in and initialize the profile of identity 1. await clientCallee.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClCustomer], true); bool checkInOk = await clientCallee.CheckInAsync(); bool initializeProfileOk = await clientCallee.InitializeProfileAsync("Test Identity", null, new GpsLocation(0, 0), null); // Add application service to the current session. string serviceName = "Test Service"; bool addAppServiceOk = await clientCallee.AddApplicationServicesAsync(new List <string>() { serviceName }); // Step 1 Acceptance bool step1Ok = listPortsOk && establishHostingOk && checkInOk && initializeProfileOk && addAppServiceOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await clientCaller.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool verifyIdentityOk = await clientCaller.VerifyIdentityAsync(); Message requestMessage = mbCaller.CreateCallIdentityApplicationServiceRequest(identityIdCallee, serviceName); await clientCaller.SendMessageAsync(requestMessage); // Step 2 Acceptance bool step2Ok = verifyIdentityOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); Message serverRequestMessage = await clientCallee.ReceiveMessageAsync(); byte[] receivedPubKey = serverRequestMessage.Request.ConversationRequest.IncomingCallNotification.CallerPublicKey.ToByteArray(); bool pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, pubKeyCaller) == 0; bool serviceNameOk = serverRequestMessage.Request.ConversationRequest.IncomingCallNotification.ServiceName == serviceName; bool incomingCallNotificationOk = pubKeyOk && serviceNameOk; byte[] calleeToken = serverRequestMessage.Request.ConversationRequest.IncomingCallNotification.CalleeToken.ToByteArray(); Message serverResponseMessage = mbCallee.CreateIncomingCallNotificationResponse(serverRequestMessage); await clientCallee.SendMessageAsync(serverResponseMessage); // Connect to clAppService and send initialization message. await clientCalleeAppService.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClAppService], true); Message requestMessageAppServiceCallee = mbCalleeAppService.CreateApplicationServiceSendMessageRequest(calleeToken, null); await clientCalleeAppService.SendMessageAsync(requestMessageAppServiceCallee); // Step 3 Acceptance bool step3Ok = incomingCallNotificationOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); Message responseMessage = await clientCaller.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; byte[] callerToken = responseMessage.Response.ConversationResponse.CallIdentityApplicationService.CallerToken.ToByteArray(); bool callIdentityOk = idOk && statusOk; // Connect to clAppService and send initialization message. await clientCallerAppService.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClAppService], true); Message requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(callerToken, null); await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); Message responseMessageAppServiceCaller = await clientCallerAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCaller.Id == requestMessageAppServiceCaller.Id; statusOk = responseMessageAppServiceCaller.Response.Status == Status.Ok; bool initAppServiceMessageOk = idOk && statusOk; clientCaller.CloseConnection(); // Step 4 Acceptance bool step4Ok = callIdentityOk && initAppServiceMessageOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); Message responseMessageAppServiceCallee = await clientCalleeAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCallee.Id == requestMessageAppServiceCallee.Id; statusOk = responseMessageAppServiceCallee.Response.Status == Status.Ok; bool appServiceSendOk = idOk && statusOk; // Step 5 Acceptance bool step5Ok = appServiceSendOk; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 log.Trace("Step 6"); bool error = false; int messagesDelivered = 0; int messagesSent = 0; bool disconnectedOk = false; for (int i = 0; i < 20; i++) { try { // Caller sends message. string callerMessage = string.Format("Message #{0} to callee.", i + 1); byte[] messageBytes = Encoding.UTF8.GetBytes(callerMessage); requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(callerToken, messageBytes); await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); messagesSent++; // Callee receives message. Message serverRequestAppServiceCallee = await clientCalleeAppService.ReceiveMessageAsync(); SemVer receivedVersion = new SemVer(serverRequestAppServiceCallee.Request.SingleRequest.Version); bool versionOk = receivedVersion.Equals(SemVer.V100); bool typeOk = (serverRequestAppServiceCallee.MessageTypeCase == Message.MessageTypeOneofCase.Request) && (serverRequestAppServiceCallee.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.SingleRequest) && (serverRequestAppServiceCallee.Request.SingleRequest.RequestTypeCase == SingleRequest.RequestTypeOneofCase.ApplicationServiceReceiveMessageNotification); string receivedMessage = Encoding.UTF8.GetString(serverRequestAppServiceCallee.Request.SingleRequest.ApplicationServiceReceiveMessageNotification.Message.ToByteArray()); bool messageOk = receivedMessage == callerMessage; bool receiveMessageOk = versionOk && typeOk && messageOk; if (receiveMessageOk) { messagesDelivered++; log.Trace("Delivery of message #{0} succeeded.", i + 1); } else { log.Trace("Delivery of message #{0} failed.", i + 1); error = true; break; } await Task.Delay(10 * 1000); } catch { log.Trace("Expected exception occurred."); disconnectedOk = true; break; } } // Step 6 Acceptance bool step6Ok = !error && disconnectedOk && (messagesDelivered < 20); log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } clientCallee.Dispose(); clientCalleeAppService.Dispose(); clientCaller.Dispose(); clientCallerAppService.Dispose(); 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); 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(); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool hostingOk = await client.EstablishHostingAsync("Test"); client.CloseConnection(); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClCustomer], true); bool checkInOk = await client.CheckInAsync(); bool step1Ok = listPortsOk && hostingOk && checkInOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); string validityString = DateTime.UtcNow.AddMonths(1).ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", DateTimeFormatInfo.InvariantInfo); CanIpnsEntry ipnsRecord = new CanIpnsEntry() { Value = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes("/ipfs/QmaRvpLT4RgBDVY6cQKwqQGQNtbM31KSqh8TxvQgFoEUus")), ValidityType = CanIpnsEntry.Types.ValidityType.Eol, Validity = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(validityString)), Sequence = 1, Ttl = 6000000000, }; ipnsRecord.Signature = ProtocolHelper.ByteArrayToByteString(client.CreateIpnsRecordSignature(ipnsRecord)); Message requestMessage = mb.CreateCanPublishIpnsRecordRequest(ipnsRecord); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = (responseMessage.Response.Status == Status.ErrorNotFound) || ((responseMessage.Response.Status == Status.ErrorInvalidValue) && (responseMessage.Response.Details == "record.value")); bool canPublishIpnsRecordOk = idOk && statusOk; // Step 2 Acceptance bool step2Ok = canPublishIpnsRecordOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); byte[] serverId = Crypto.Sha256(client.ServerKey); List <CanKeyValue> clientData = new List <CanKeyValue>() { new CanKeyValue() { Key = "key1", StringValue = "value 1" }, new CanKeyValue() { Key = "key2", Uint32Value = 2 }, new CanKeyValue() { Key = "key3", BoolValue = true }, new CanKeyValue() { Key = "key4", BinaryValue = ProtocolHelper.ByteArrayToByteString(new byte[] { 1, 2, 3 }) }, }; CanIdentityData identityData1 = new CanIdentityData() { HostingServerId = ProtocolHelper.ByteArrayToByteString(serverId) }; identityData1.KeyValueList.AddRange(clientData); requestMessage = mb.CreateCanStoreDataRequest(identityData1); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool canStoreDataOk = idOk && statusOk; byte[] objectHash1 = responseMessage.Response.ConversationResponse.CanStoreData.Hash.ToByteArray(); string objectPath1 = client.CreateIpfsPathFromHash(objectHash1); log.Trace("Object path 1 is '{0}'.", objectPath1); requestMessage = mb.CreateCanPublishIpnsRecordRequest(null); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; bool detailsOk = responseMessage.Response.Details == "record"; canPublishIpnsRecordOk = idOk && statusOk && detailsOk; // Step 3 Acceptance bool step3Ok = canStoreDataOk && canPublishIpnsRecordOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); validityString = DateTime.UtcNow.AddMonths(1).ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", DateTimeFormatInfo.InvariantInfo); ipnsRecord = new CanIpnsEntry() { Value = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes("ipfabc")), ValidityType = CanIpnsEntry.Types.ValidityType.Eol, Validity = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(validityString)), Sequence = 1, Ttl = 6000000000, }; ipnsRecord.Signature = ProtocolHelper.ByteArrayToByteString(client.CreateIpnsRecordSignature(ipnsRecord)); requestMessage = mb.CreateCanPublishIpnsRecordRequest(ipnsRecord); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; detailsOk = responseMessage.Response.Details == "record.value"; canPublishIpnsRecordOk = idOk && statusOk && detailsOk; // Step 4 Acceptance bool step4Ok = canPublishIpnsRecordOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); validityString = DateTime.UtcNow.AddMonths(1).ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", DateTimeFormatInfo.InvariantInfo); ipnsRecord = new CanIpnsEntry() { Value = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(objectPath1)), ValidityType = CanIpnsEntry.Types.ValidityType.Eol, Validity = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(validityString)), Sequence = 1, Ttl = 6000000000, }; ipnsRecord.Signature = ProtocolHelper.ByteArrayToByteString(client.CreateIpnsRecordSignature(ipnsRecord)); requestMessage = mb.CreateCanPublishIpnsRecordRequest(ipnsRecord); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; canPublishIpnsRecordOk = idOk && statusOk; // Step 5 Acceptance bool step5Ok = canPublishIpnsRecordOk; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 log.Trace("Step 6"); validityString = DateTime.UtcNow.AddMonths(1).ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", DateTimeFormatInfo.InvariantInfo); ipnsRecord = new CanIpnsEntry() { Value = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(objectPath1)), ValidityType = CanIpnsEntry.Types.ValidityType.Eol, Validity = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(validityString)), Sequence = 1, Ttl = 6000000000, }; ipnsRecord.Signature = ProtocolHelper.ByteArrayToByteString(client.CreateIpnsRecordSignature(ipnsRecord)); requestMessage = mb.CreateCanPublishIpnsRecordRequest(ipnsRecord); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorRejected; detailsOk = !string.IsNullOrEmpty(responseMessage.Response.Details); canPublishIpnsRecordOk = idOk && statusOk && detailsOk; // Step 6 Acceptance bool step6Ok = canPublishIpnsRecordOk; log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED"); // Step 7 log.Trace("Step 7"); validityString = DateTime.UtcNow.AddMonths(1).ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", DateTimeFormatInfo.InvariantInfo); ipnsRecord = new CanIpnsEntry() { Value = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(objectPath1)), ValidityType = CanIpnsEntry.Types.ValidityType.Eol, Validity = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(validityString)), Sequence = 2, Ttl = 6000000000, }; ipnsRecord.Signature = ProtocolHelper.ByteArrayToByteString(new byte[] { 0x40, 0x40, 0x40, 0x40, 0x40 }); requestMessage = mb.CreateCanPublishIpnsRecordRequest(ipnsRecord); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorRejected; detailsOk = !string.IsNullOrEmpty(responseMessage.Response.Details); canPublishIpnsRecordOk = idOk && statusOk && detailsOk; // Step 7 Acceptance bool step7Ok = canPublishIpnsRecordOk; log.Trace("Step 7: {0}", step7Ok ? "PASSED" : "FAILED"); // Step 8 log.Trace("Step 8"); requestMessage = mb.CreateCanStoreDataRequest(null); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; canStoreDataOk = idOk && statusOk; validityString = DateTime.UtcNow.AddMonths(1).ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", DateTimeFormatInfo.InvariantInfo); ipnsRecord = new CanIpnsEntry() { Value = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(objectPath1)), ValidityType = CanIpnsEntry.Types.ValidityType.Eol, Validity = ProtocolHelper.ByteArrayToByteString(Encoding.UTF8.GetBytes(validityString)), Sequence = 3, Ttl = 6000000000, }; ipnsRecord.Signature = ProtocolHelper.ByteArrayToByteString(client.CreateIpnsRecordSignature(ipnsRecord)); requestMessage = mb.CreateCanPublishIpnsRecordRequest(ipnsRecord); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorNotFound; canPublishIpnsRecordOk = idOk && statusOk; // Step 8 Acceptance bool step8Ok = canStoreDataOk && canPublishIpnsRecordOk; 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(); 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 NodeIp = (IPAddress)ArgumentValues["Node IP"]; int ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; int ClCustomerPort = (int)ArgumentValues["clCustomer Port"]; log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1},ClCustomerPort:{2})", NodeIp, ClNonCustomerPort, ClCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); try { MessageBuilder mb = client.MessageBuilder; byte[] testPubKey = client.GetIdentityKeys().PublicKey; byte[] testIdentityId = client.GetIdentityId(); // Step 1 await client.ConnectAsync(NodeIp, ClNonCustomerPort, true); bool establishHomeNodeOk = await client.EstablishHomeNodeAsync(); // Step 1 Acceptance bool step1Ok = establishHomeNodeOk; client.CloseConnection(); // Step 2 await client.ConnectAsync(NodeIp, ClCustomerPort, true); bool checkInOk = await client.CheckInAsync(); Message requestMessage = mb.CreateUpdateProfileRequest(new byte[] { 1, 0, 0 }, "Test Identity", null, 0x12345678, null); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool updateProfileOk = idOk && statusOk; List <string> asList = new List <string>() { "a", "b", "c", "d", "a" }; requestMessage = mb.CreateApplicationServiceAddRequest(asList); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool appServiceAddOk1 = idOk && statusOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId, false, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted; bool isOnlineOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsOnline; byte[] receivedPubKey = responseMessage.Response.SingleResponse.GetIdentityInformation.IdentityPublicKey.ToByteArray(); bool pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, testPubKey) == 0; HashSet <string> expectedAsList = new HashSet <string>() { "a", "b", "c", "d" }; HashSet <string> receivedAsList = new HashSet <string>(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); bool appServicesOk = expectedAsList.SetEquals(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); bool getIdentityInfoOk1 = idOk && statusOk && isHostedOk && isOnlineOk && pubKeyOk && appServicesOk; asList = new List <string>() { "c", "d", "a", "e" }; requestMessage = mb.CreateApplicationServiceAddRequest(asList); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool appServiceAddOk2 = idOk && statusOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId, false, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted; isOnlineOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsOnline; receivedPubKey = responseMessage.Response.SingleResponse.GetIdentityInformation.IdentityPublicKey.ToByteArray(); pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, testPubKey) == 0; expectedAsList = new HashSet <string>() { "a", "b", "c", "d", "e" }; receivedAsList = new HashSet <string>(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); appServicesOk = expectedAsList.SetEquals(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); bool getIdentityInfoOk2 = idOk && statusOk && isHostedOk && isOnlineOk && pubKeyOk && appServicesOk; requestMessage = mb.CreateApplicationServiceRemoveRequest("a"); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool appServiceRemoveOk3 = idOk && statusOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId, false, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted; isOnlineOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsOnline; receivedPubKey = responseMessage.Response.SingleResponse.GetIdentityInformation.IdentityPublicKey.ToByteArray(); pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, testPubKey) == 0; expectedAsList = new HashSet <string>() { "b", "c", "d", "e" }; receivedAsList = new HashSet <string>(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); appServicesOk = expectedAsList.SetEquals(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); bool getIdentityInfoOk3 = idOk && statusOk && isHostedOk && isOnlineOk && pubKeyOk && appServicesOk; requestMessage = mb.CreateApplicationServiceRemoveRequest("a"); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorNotFound; bool appServiceRemoveOk4 = idOk && statusOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId, false, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted; isOnlineOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsOnline; receivedPubKey = responseMessage.Response.SingleResponse.GetIdentityInformation.IdentityPublicKey.ToByteArray(); pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, testPubKey) == 0; expectedAsList = new HashSet <string>() { "b", "c", "d", "e" }; receivedAsList = new HashSet <string>(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); appServicesOk = expectedAsList.SetEquals(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); bool getIdentityInfoOk4 = idOk && statusOk && isHostedOk && isOnlineOk && pubKeyOk && appServicesOk; asList = new List <string>() { "d", "1234567890-1234567890-1234567890-1234567890", "a", "e" }; requestMessage = mb.CreateApplicationServiceAddRequest(asList); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; bool detailsOk = responseMessage.Response.Details == "serviceNames[1]"; bool appServiceAddOk5 = idOk && statusOk && detailsOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId, false, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted; isOnlineOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsOnline; receivedPubKey = responseMessage.Response.SingleResponse.GetIdentityInformation.IdentityPublicKey.ToByteArray(); pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, testPubKey) == 0; expectedAsList = new HashSet <string>() { "b", "c", "d", "e" }; receivedAsList = new HashSet <string>(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); appServicesOk = expectedAsList.SetEquals(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); bool getIdentityInfoOk5 = idOk && statusOk && isHostedOk && isOnlineOk && pubKeyOk && appServicesOk; asList = new List <string>() { "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10" }; requestMessage = mb.CreateApplicationServiceAddRequest(asList); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool appServiceAddOk6 = idOk && statusOk; asList = new List <string>() { "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10" }; requestMessage = mb.CreateApplicationServiceAddRequest(asList); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool appServiceAddOk7 = idOk && statusOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId, false, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted; isOnlineOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsOnline; receivedPubKey = responseMessage.Response.SingleResponse.GetIdentityInformation.IdentityPublicKey.ToByteArray(); pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, testPubKey) == 0; expectedAsList = new HashSet <string>() { "b", "c", "d", "e", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10" }; receivedAsList = new HashSet <string>(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); appServicesOk = expectedAsList.SetEquals(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); bool getIdentityInfoOk7 = idOk && statusOk && isHostedOk && isOnlineOk && pubKeyOk && appServicesOk; asList = new List <string>() { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "e10" }; requestMessage = mb.CreateApplicationServiceAddRequest(asList); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorQuotaExceeded; bool appServiceAddOk8 = idOk && statusOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId, false, false, true); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted; isOnlineOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsOnline; receivedPubKey = responseMessage.Response.SingleResponse.GetIdentityInformation.IdentityPublicKey.ToByteArray(); pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, testPubKey) == 0; expectedAsList = new HashSet <string>() { "b", "c", "d", "e", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10" }; receivedAsList = new HashSet <string>(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); appServicesOk = expectedAsList.SetEquals(responseMessage.Response.SingleResponse.GetIdentityInformation.ApplicationServices); bool getIdentityInfoOk8 = idOk && statusOk && isHostedOk && isOnlineOk && pubKeyOk && appServicesOk; // Step 2 Acceptance bool step2Ok = checkInOk && updateProfileOk && appServiceAddOk1 && getIdentityInfoOk1 && appServiceAddOk2 && getIdentityInfoOk2 && appServiceRemoveOk3 && getIdentityInfoOk3 && appServiceRemoveOk4 && getIdentityInfoOk4 && appServiceAddOk5 && getIdentityInfoOk5 && appServiceAddOk6 && appServiceAddOk7 && getIdentityInfoOk7 && appServiceAddOk8 && getIdentityInfoOk8; Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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 ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1})", ServerIp, ClNonCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); List <ProtocolClient> testIdentities = new List <ProtocolClient>(); for (int i = 0; i < IdentityTypes.Count; i++) { testIdentities.Add(new ProtocolClient()); } try { MessageBuilder mb = client.MessageBuilder; // Step 1 log.Trace("Step 1"); bool error = false; for (int i = 0; i < IdentityTypes.Count - 2; i++) { ProtocolClient cl = testIdentities[i]; await cl.ConnectAsync(ServerIp, ClNonCustomerPort, true); if (!await cl.EstablishHostingAsync(IdentityTypes[i])) { error = true; break; } cl.CloseConnection(); } bool hostingOk = !error; await client.ConnectAsync(ServerIp, ClNonCustomerPort, true); Message requestMessage = mb.CreateProfileStatsRequest(); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool countOk = responseMessage.Response.SingleResponse.ProfileStats.Stats.Count == 0; // Step 1 Acceptance bool step1Ok = idOk && statusOk && countOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); for (int i = IdentityTypes.Count - 2; i < IdentityTypes.Count; i++) { ProtocolClient cl = testIdentities[i]; await cl.ConnectAsync(ServerIp, ClNonCustomerPort, true); if (!await cl.EstablishHostingAsync(IdentityTypes[i])) { error = true; break; } cl.CloseConnection(); } hostingOk = !error; requestMessage = mb.CreateProfileStatsRequest(); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; countOk = responseMessage.Response.SingleResponse.ProfileStats.Stats.Count == 0; // Step 2 Acceptance bool step2Ok = idOk && statusOk && countOk; log.Trace("Step 2: {0}", step1Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } foreach (ProtocolClient cl in testIdentities) { cl.Dispose(); } client.Dispose(); 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 ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; int ClCustomerPort = (int)ArgumentValues["clCustomer Port"]; log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1},ClCustomerPort:{2})", ServerIp, ClNonCustomerPort, ClCustomerPort); bool res = false; Passed = false; ProtocolClient client1 = new ProtocolClient(); ProtocolClient client2 = new ProtocolClient(0, SemVer.V100, client1.GetIdentityKeys()); try { MessageBuilder mb1 = client1.MessageBuilder; // Step 1 await client1.ConnectAsync(ServerIp, ClNonCustomerPort, true); bool establishHostingOk = await client1.EstablishHostingAsync(); // Step 1 Acceptance bool step1Ok = establishHostingOk; client1.CloseConnection(); // Step 2 await client1.ConnectAsync(ServerIp, ClCustomerPort, true); bool checkInOk = await client1.CheckInAsync(); // Step 2 Acceptance bool step2Ok = checkInOk; // Step 3 await client2.ConnectAsync(ServerIp, ClCustomerPort, true); checkInOk = await client2.CheckInAsync(); // Step 3 Acceptance bool step3Ok = checkInOk; // Step 4 byte[] payload = Encoding.UTF8.GetBytes("test"); Message requestMessage = mb1.CreatePingRequest(payload); bool disconnectedOk = false; // We should be disconnected by now, so sending or receiving should throw. try { await client1.SendMessageAsync(requestMessage); await client1.ReceiveMessageAsync(); } catch { log.Trace("Expected exception occurred."); disconnectedOk = true; } // Step 4 Acceptance bool step4Ok = disconnectedOk; Passed = step1Ok && step2Ok && step3Ok && step4Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client1.Dispose(); client2.Dispose(); 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 NodeIp = (IPAddress)ArgumentValues["Node IP"]; int ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; int ClCustomerPort = (int)ArgumentValues["clCustomer Port"]; log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1},ClCustomerPort:{2})", NodeIp, ClNonCustomerPort, ClCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); try { MessageBuilder mb = client.MessageBuilder; byte[] testPubKey = client.GetIdentityKeys().PublicKey; byte[] testIdentityId = client.GetIdentityId(); // Step 1 await client.ConnectAsync(NodeIp, ClNonCustomerPort, true); bool establishHomeNodeOk = await client.EstablishHomeNodeAsync(); // Step 1 Acceptance bool step1Ok = establishHomeNodeOk; client.CloseConnection(); // Step 2 await client.ConnectAsync(NodeIp, ClCustomerPort, true); bool checkInOk = await client.CheckInAsync(); Message requestMessage = mb.CreateUpdateProfileRequest(new byte[] { 1, 0, 0 }, "Test Identity", null, 0x12345678, null); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool updateProfileOk = idOk && statusOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted; bool isOnlineOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsOnline; byte[] receivedPubKey = responseMessage.Response.SingleResponse.GetIdentityInformation.IdentityPublicKey.ToByteArray(); bool pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, testPubKey) == 0; bool nameOk = responseMessage.Response.SingleResponse.GetIdentityInformation.Name == "Test Identity"; bool extraDataOk = responseMessage.Response.SingleResponse.GetIdentityInformation.ExtraData == ""; bool getIdentityInfoOk = idOk && statusOk && isHostedOk && isOnlineOk && pubKeyOk && nameOk && extraDataOk; byte[] imageData = File.ReadAllBytes(string.Format("images{0}HN04006.jpg", Path.DirectorySeparatorChar)); requestMessage = mb.CreateUpdateProfileRequest(null, "Test Identity Renamed", imageData, 0x12345678, "a=b"); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool updateProfileOk2 = idOk && statusOk; requestMessage = mb.CreateGetIdentityInformationRequest(testIdentityId, true, true, false); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; isHostedOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsHosted; isOnlineOk = responseMessage.Response.SingleResponse.GetIdentityInformation.IsOnline; receivedPubKey = responseMessage.Response.SingleResponse.GetIdentityInformation.IdentityPublicKey.ToByteArray(); pubKeyOk = StructuralComparisons.StructuralComparer.Compare(testPubKey, receivedPubKey) == 0; nameOk = responseMessage.Response.SingleResponse.GetIdentityInformation.Name == "Test Identity Renamed"; extraDataOk = responseMessage.Response.SingleResponse.GetIdentityInformation.ExtraData == "a=b"; byte[] receivedProfileImage = responseMessage.Response.SingleResponse.GetIdentityInformation.ProfileImage.ToByteArray(); bool profileImageOk = StructuralComparisons.StructuralComparer.Compare(receivedProfileImage, imageData) == 0; byte[] receivedThumbnailImage = responseMessage.Response.SingleResponse.GetIdentityInformation.ThumbnailImage.ToByteArray(); bool thumbnailImageOk = receivedThumbnailImage.Length > 0; bool getIdentityInfoOk2 = idOk && statusOk && isHostedOk && isOnlineOk && pubKeyOk && nameOk && extraDataOk && profileImageOk && thumbnailImageOk; // Step 2 Acceptance bool step2Ok = checkInOk && updateProfileOk && getIdentityInfoOk && updateProfileOk2 && getIdentityInfoOk2; Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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 NodeIp = (IPAddress)ArgumentValues["Node IP"]; int PrimaryPort = (int)ArgumentValues["primary Port"]; log.Trace("(NodeIp:'{0}',PrimaryPort:{1})", NodeIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient clientCallee = new ProtocolClient(); ProtocolClient clientCalleeAppService = new ProtocolClient(0, new byte[] { 1, 0, 0 }, clientCallee.GetIdentityKeys()); ProtocolClient clientCaller = new ProtocolClient(); ProtocolClient clientCallerAppService = new ProtocolClient(0, new byte[] { 1, 0, 0 }, clientCaller.GetIdentityKeys()); try { MessageBuilder mbCallee = clientCallee.MessageBuilder; MessageBuilder mbCalleeAppService = clientCalleeAppService.MessageBuilder; MessageBuilder mbCaller = clientCaller.MessageBuilder; MessageBuilder mbCallerAppService = clientCallerAppService.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. byte[] pubKeyCallee = clientCallee.GetIdentityKeys().PublicKey; byte[] identityIdCallee = clientCallee.GetIdentityId(); byte[] pubKeyCaller = clientCaller.GetIdentityKeys().PublicKey; byte[] identityIdCaller = clientCaller.GetIdentityId(); await clientCallee.ConnectAsync(NodeIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await clientCallee.ListNodePorts(rolePorts); clientCallee.CloseConnection(); // Establish home node for identity 1. await clientCallee.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool establishHomeNodeOk = await clientCallee.EstablishHomeNodeAsync(); clientCallee.CloseConnection(); // Check-in and initialize the profile of identity 1. await clientCallee.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClCustomer], true); bool checkInOk = await clientCallee.CheckInAsync(); bool initializeProfileOk = await clientCallee.InitializeProfileAsync("Test Identity", null, 0x12345678, null); // Add application service to the current session. string serviceName = "Test Service"; bool addAppServiceOk = await clientCallee.AddApplicationServicesAsync(new List <string>() { serviceName }); // Step 1 Acceptance bool step1Ok = listPortsOk && establishHomeNodeOk && checkInOk && initializeProfileOk && addAppServiceOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await clientCaller.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool verifyIdentityOk = await clientCaller.VerifyIdentityAsync(); Message requestMessage = mbCaller.CreateCallIdentityApplicationServiceRequest(identityIdCallee, serviceName); await clientCaller.SendMessageAsync(requestMessage); // Step 2 Acceptance bool step2Ok = verifyIdentityOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); Message nodeRequestMessage = await clientCallee.ReceiveMessageAsync(); byte[] receivedPubKey = nodeRequestMessage.Request.ConversationRequest.IncomingCallNotification.CallerPublicKey.ToByteArray(); bool pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, pubKeyCaller) == 0; bool serviceNameOk = nodeRequestMessage.Request.ConversationRequest.IncomingCallNotification.ServiceName == serviceName; bool incomingCallNotificationOk = pubKeyOk && serviceNameOk; byte[] calleeToken = nodeRequestMessage.Request.ConversationRequest.IncomingCallNotification.CalleeToken.ToByteArray(); Message nodeResponseMessage = mbCallee.CreateIncomingCallNotificationResponse(nodeRequestMessage); await clientCallee.SendMessageAsync(nodeResponseMessage); // Step 3 Acceptance bool step3Ok = incomingCallNotificationOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); Message responseMessage = await clientCaller.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; byte[] callerToken = responseMessage.Response.ConversationResponse.CallIdentityApplicationService.CallerToken.ToByteArray(); bool callIdentityOk = idOk && statusOk; // Step 4 Acceptance bool step4Ok = callIdentityOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 // Connect to clAppService and send initialization message. await clientCalleeAppService.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClAppService], true); await Task.Delay(35 * 1000); Message requestMessageAppServiceCallee = mbCalleeAppService.CreateApplicationServiceSendMessageRequest(calleeToken, null); await clientCalleeAppService.SendMessageAsync(requestMessageAppServiceCallee); // Step 5 Acceptance bool step5Ok = true; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 // Connect to clAppService and send initialization message. await clientCallerAppService.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClAppService], true); Message requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(callerToken, null); await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); Message responseMessageAppServiceCaller = await clientCallerAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCaller.Id == requestMessageAppServiceCaller.Id; statusOk = responseMessageAppServiceCaller.Response.Status == Status.ErrorNotFound; bool initAppServiceMessageOk = idOk && statusOk; // Step 6 Acceptance bool step6Ok = initAppServiceMessageOk; log.Trace("Step 6: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 7 log.Trace("Step 7"); Message responseMessageAppServiceCallee = await clientCalleeAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCallee.Id == requestMessageAppServiceCallee.Id; statusOk = responseMessageAppServiceCallee.Response.Status == Status.ErrorNotFound; bool appServiceSendOk = idOk && statusOk; // Step 7 Acceptance bool step7Ok = appServiceSendOk; log.Trace("Step 7: {0}", step7Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok && step7Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } clientCallee.Dispose(); clientCalleeAppService.Dispose(); clientCaller.Dispose(); clientCallerAppService.Dispose(); 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); 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(); // Start conversation. await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool startConversationOk = await client.StartConversationAsync(); // Search profile request. Message requestMessage = mb.CreateProfileSearchRequest(null, null, null); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool totalRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == 0; bool maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100; bool profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == 0; // Step 1 Acceptance bool step1Ok = listPortsOk && startConversationOk && idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); Passed = step1Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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 ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; log.Trace("(ServerIp:'{0}',ClNonCustomerPort:{1})", ServerIp, ClNonCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); try { MessageBuilder mb = client.MessageBuilder; // Step 1 await client.ConnectAsync(ServerIp, ClNonCustomerPort, true); bool startConversationOk = await client.StartConversationAsync(); Message requestMessage = mb.CreateRegisterHostingRequest(null); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool registerHostingOk = idOk && statusOk; // Step 1 Acceptance bool step1Ok = startConversationOk & registerHostingOk; // Step 2 client.CloseConnection(); await client.ConnectAsync(ServerIp, ClNonCustomerPort, true); startConversationOk = await client.StartConversationAsync(); requestMessage = mb.CreateRegisterHostingRequest(null); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorAlreadyExists; registerHostingOk = idOk && statusOk; // Step 2 Acceptance bool step2Ok = startConversationOk && registerHostingOk; Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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 NodeIp = (IPAddress)ArgumentValues["Node IP"]; int PrimaryPort = (int)ArgumentValues["primary Port"]; log.Trace("(NodeIp:'{0}',PrimaryPort:{1})", NodeIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient clientCallee = new ProtocolClient(); ProtocolClient clientCalleeAppService = new ProtocolClient(0, new byte[] { 1, 0, 0 }, clientCallee.GetIdentityKeys()); ProtocolClient clientCaller = new ProtocolClient(); ProtocolClient clientCallerAppService = new ProtocolClient(0, new byte[] { 1, 0, 0 }, clientCaller.GetIdentityKeys()); try { MessageBuilder mbCallee = clientCallee.MessageBuilder; MessageBuilder mbCalleeAppService = clientCalleeAppService.MessageBuilder; MessageBuilder mbCaller = clientCaller.MessageBuilder; MessageBuilder mbCallerAppService = clientCallerAppService.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. byte[] pubKeyCallee = clientCallee.GetIdentityKeys().PublicKey; byte[] identityIdCallee = clientCallee.GetIdentityId(); byte[] pubKeyCaller = clientCaller.GetIdentityKeys().PublicKey; byte[] identityIdCaller = clientCaller.GetIdentityId(); await clientCallee.ConnectAsync(NodeIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await clientCallee.ListNodePorts(rolePorts); clientCallee.CloseConnection(); // Establish home node for identity 1. await clientCallee.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool establishHomeNodeOk = await clientCallee.EstablishHomeNodeAsync(); clientCallee.CloseConnection(); // Check-in and initialize the profile of identity 1. await clientCallee.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClCustomer], true); bool checkInOk = await clientCallee.CheckInAsync(); bool initializeProfileOk = await clientCallee.InitializeProfileAsync("Test Identity", null, 0x12345678, null); // Add application service to the current session. string serviceName = "Test Service"; bool addAppServiceOk = await clientCallee.AddApplicationServicesAsync(new List <string>() { serviceName }); // Step 1 Acceptance bool step1Ok = listPortsOk && establishHomeNodeOk && checkInOk && initializeProfileOk && addAppServiceOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await clientCaller.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool verifyIdentityOk = await clientCaller.VerifyIdentityAsync(); Message requestMessage = mbCaller.CreateCallIdentityApplicationServiceRequest(identityIdCallee, serviceName); await clientCaller.SendMessageAsync(requestMessage); // Step 2 Acceptance bool step2Ok = verifyIdentityOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); Message nodeRequestMessage = await clientCallee.ReceiveMessageAsync(); byte[] receivedPubKey = nodeRequestMessage.Request.ConversationRequest.IncomingCallNotification.CallerPublicKey.ToByteArray(); bool pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, pubKeyCaller) == 0; bool serviceNameOk = nodeRequestMessage.Request.ConversationRequest.IncomingCallNotification.ServiceName == serviceName; bool incomingCallNotificationOk = pubKeyOk && serviceNameOk; byte[] calleeToken = nodeRequestMessage.Request.ConversationRequest.IncomingCallNotification.CalleeToken.ToByteArray(); Message nodeResponseMessage = mbCallee.CreateIncomingCallNotificationResponse(nodeRequestMessage); await clientCallee.SendMessageAsync(nodeResponseMessage); // Connect to clAppService and send initialization message. await clientCalleeAppService.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClAppService], true); Message requestMessageAppServiceCallee = mbCalleeAppService.CreateApplicationServiceSendMessageRequest(calleeToken, null); await clientCalleeAppService.SendMessageAsync(requestMessageAppServiceCallee); // Step 3 Acceptance bool step3Ok = incomingCallNotificationOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); Message responseMessage = await clientCaller.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; byte[] callerToken = responseMessage.Response.ConversationResponse.CallIdentityApplicationService.CallerToken.ToByteArray(); bool callIdentityOk = idOk && statusOk; // Connect to clAppService and send initialization message. await clientCallerAppService.ConnectAsync(NodeIp, (int)rolePorts[ServerRoleType.ClAppService], true); Message requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(callerToken, null); await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); Message responseMessageAppServiceCaller = await clientCallerAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCaller.Id == requestMessageAppServiceCaller.Id; statusOk = responseMessageAppServiceCaller.Response.Status == Status.Ok; bool initAppServiceMessageOk = idOk && statusOk; // And close connection to clNonCustomer port. clientCaller.CloseConnection(); // Step 4 Acceptance bool step4Ok = callIdentityOk && initAppServiceMessageOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); Message responseMessageAppServiceCallee = await clientCalleeAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCallee.Id == requestMessageAppServiceCallee.Id; statusOk = responseMessageAppServiceCallee.Response.Status == Status.Ok; bool typeOk = (responseMessageAppServiceCallee.MessageTypeCase == Message.MessageTypeOneofCase.Response) && (responseMessageAppServiceCallee.Response.ConversationTypeCase == Response.ConversationTypeOneofCase.SingleResponse) && (responseMessageAppServiceCallee.Response.SingleResponse.ResponseTypeCase == SingleResponse.ResponseTypeOneofCase.ApplicationServiceSendMessage); bool appServiceSendOk = idOk && statusOk && typeOk; // Step 5 Acceptance bool step5Ok = appServiceSendOk; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 log.Trace("Step 6"); string callerMessage1 = "Message #1 to callee."; byte[] messageBytes = Encoding.UTF8.GetBytes(callerMessage1); requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(callerToken, messageBytes); uint callerMessage1Id = requestMessageAppServiceCaller.Id; await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); // Step 6 Acceptance bool step6Ok = true; log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED"); // Step 7 log.Trace("Step 7"); // Receive message #1. Message nodeRequestAppServiceCallee = await clientCalleeAppService.ReceiveMessageAsync(); byte[] receivedVersion = nodeRequestAppServiceCallee.Request.SingleRequest.Version.ToByteArray(); bool versionOk = StructuralComparisons.StructuralComparer.Compare(receivedVersion, new byte[] { 1, 0, 0 }) == 0; typeOk = (nodeRequestAppServiceCallee.MessageTypeCase == Message.MessageTypeOneofCase.Request) && (nodeRequestAppServiceCallee.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.SingleRequest) && (nodeRequestAppServiceCallee.Request.SingleRequest.RequestTypeCase == SingleRequest.RequestTypeOneofCase.ApplicationServiceReceiveMessageNotification); string receivedMessage = Encoding.UTF8.GetString(nodeRequestAppServiceCallee.Request.SingleRequest.ApplicationServiceReceiveMessageNotification.Message.ToByteArray()); bool messageOk = receivedMessage == callerMessage1; bool receiveMessageOk = versionOk && typeOk && messageOk; // ACK message #1. Message nodeResponseAppServiceCallee = mbCalleeAppService.CreateApplicationServiceReceiveMessageNotificationResponse(nodeRequestAppServiceCallee); await clientCalleeAppService.SendMessageAsync(nodeResponseAppServiceCallee); // Send our message #1. string calleeMessage1 = "Message #1 to CALLER."; messageBytes = Encoding.UTF8.GetBytes(calleeMessage1); requestMessageAppServiceCallee = mbCalleeAppService.CreateApplicationServiceSendMessageRequest(calleeToken, messageBytes); uint calleeMessage1Id = requestMessageAppServiceCallee.Id; await clientCalleeAppService.SendMessageAsync(requestMessageAppServiceCallee); // Step 7 Acceptance bool step7Ok = receiveMessageOk; log.Trace("Step 7: {0}", step7Ok ? "PASSED" : "FAILED"); // Step 8 log.Trace("Step 8"); // Receive ACK message #1. responseMessageAppServiceCaller = await clientCallerAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCaller.Id == callerMessage1Id; statusOk = responseMessageAppServiceCaller.Response.Status == Status.Ok; receivedVersion = responseMessageAppServiceCaller.Response.SingleResponse.Version.ToByteArray(); versionOk = StructuralComparisons.StructuralComparer.Compare(receivedVersion, new byte[] { 1, 0, 0 }) == 0; bool receiveAckOk = idOk && statusOk && versionOk; // Receive message #1 from callee. Message nodeRequestAppServiceCaller = await clientCallerAppService.ReceiveMessageAsync(); receivedVersion = nodeRequestAppServiceCaller.Request.SingleRequest.Version.ToByteArray(); versionOk = StructuralComparisons.StructuralComparer.Compare(receivedVersion, new byte[] { 1, 0, 0 }) == 0; typeOk = (nodeRequestAppServiceCaller.MessageTypeCase == Message.MessageTypeOneofCase.Request) && (nodeRequestAppServiceCaller.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.SingleRequest) && (nodeRequestAppServiceCaller.Request.SingleRequest.RequestTypeCase == SingleRequest.RequestTypeOneofCase.ApplicationServiceReceiveMessageNotification); receivedMessage = Encoding.UTF8.GetString(nodeRequestAppServiceCaller.Request.SingleRequest.ApplicationServiceReceiveMessageNotification.Message.ToByteArray()); messageOk = receivedMessage == calleeMessage1; receiveMessageOk = versionOk && typeOk && messageOk; // ACK message #1 from callee. Message nodeResponseAppServiceCaller = mbCallerAppService.CreateApplicationServiceReceiveMessageNotificationResponse(nodeRequestAppServiceCaller); await clientCallerAppService.SendMessageAsync(nodeResponseAppServiceCaller); // Step 8 Acceptance bool step8Ok = receiveAckOk && receiveMessageOk; log.Trace("Step 8: {0}", step8Ok ? "PASSED" : "FAILED"); // Step 9 log.Trace("Step 9"); // Receive ACK message #1. responseMessageAppServiceCallee = await clientCalleeAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCallee.Id == calleeMessage1Id; statusOk = responseMessageAppServiceCallee.Response.Status == Status.Ok; receivedVersion = responseMessageAppServiceCallee.Response.SingleResponse.Version.ToByteArray(); versionOk = StructuralComparisons.StructuralComparer.Compare(receivedVersion, new byte[] { 1, 0, 0 }) == 0; receiveAckOk = idOk && statusOk && versionOk; log.Trace("Going to wait for 3 minutes..."); await Task.Delay(180 * 1000); log.Trace("Waiting done."); // Step 9 Acceptance bool step9Ok = receiveAckOk; log.Trace("Step 9: {0}", step9Ok ? "PASSED" : "FAILED"); // Step 10 string callerMessage2 = "Message #1 to callee."; messageBytes = Encoding.UTF8.GetBytes(callerMessage2); requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(callerToken, messageBytes); // We should be disconnected now, send or receive should throw. bool disconnectedOk = false; try { await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); await clientCallerAppService.ReceiveMessageAsync(); } catch { log.Trace("Expected exception occurred."); disconnectedOk = true; } // Step 10 Acceptance bool step10Ok = disconnectedOk; log.Trace("Step 10: {0}", step10Ok ? "PASSED" : "FAILED"); // Step 11 string calleeMessage2 = "Message #1 to CALLER."; messageBytes = Encoding.UTF8.GetBytes(calleeMessage2); requestMessageAppServiceCallee = mbCalleeAppService.CreateApplicationServiceSendMessageRequest(calleeToken, messageBytes); // We should be disconnected now, send or receive should throw. disconnectedOk = false; try { await clientCalleeAppService.SendMessageAsync(requestMessageAppServiceCallee); await clientCalleeAppService.ReceiveMessageAsync(); } catch { log.Trace("Expected exception occurred."); disconnectedOk = true; } // Step 11 Acceptance bool step11Ok = disconnectedOk; log.Trace("Step 11: {0}", step11Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok && step7Ok && step8Ok && step9Ok && step10Ok && step11Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } clientCallee.Dispose(); clientCalleeAppService.Dispose(); clientCaller.Dispose(); clientCallerAppService.Dispose(); 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); 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(); await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true); bool verifyIdentityOk = await client.VerifyIdentityAsync(); bool step1Ok = listPortsOk && verifyIdentityOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); Message requestMessage = mb.CreateStartNeighborhoodInitializationRequest(1, 1); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool startNeighborhoodInitializationOk = idOk && statusOk; Message serverRequestMessage = await client.ReceiveMessageAsync(); bool typeOk = serverRequestMessage.MessageTypeCase == Message.MessageTypeOneofCase.Request && serverRequestMessage.Request.ConversationTypeCase == Request.ConversationTypeOneofCase.ConversationRequest && serverRequestMessage.Request.ConversationRequest.RequestTypeCase == ConversationRequest.RequestTypeOneofCase.FinishNeighborhoodInitialization; Message clientResponseMessage = mb.CreateFinishNeighborhoodInitializationResponse(serverRequestMessage); await client.SendMessageAsync(clientResponseMessage); // Step 2 Acceptance bool step2Ok = startNeighborhoodInitializationOk && typeOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient clientCallee = new ProtocolClient(); ProtocolClient clientCalleeAppService = new ProtocolClient(0, SemVer.V100, clientCallee.GetIdentityKeys()); ProtocolClient clientCaller = new ProtocolClient(); ProtocolClient clientCallerAppService = new ProtocolClient(0, SemVer.V100, clientCaller.GetIdentityKeys()); try { MessageBuilder mbCallee = clientCallee.MessageBuilder; MessageBuilder mbCalleeAppService = clientCalleeAppService.MessageBuilder; MessageBuilder mbCaller = clientCaller.MessageBuilder; MessageBuilder mbCallerAppService = clientCallerAppService.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. byte[] pubKeyCallee = clientCallee.GetIdentityKeys().PublicKey; byte[] identityIdCallee = clientCallee.GetIdentityId(); byte[] pubKeyCaller = clientCaller.GetIdentityKeys().PublicKey; byte[] identityIdCaller = clientCaller.GetIdentityId(); await clientCallee.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await clientCallee.ListServerPorts(rolePorts); clientCallee.CloseConnection(); // Establish hosting agreement for identity 1. await clientCallee.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool establishHostingOk = await clientCallee.EstablishHostingAsync(); clientCallee.CloseConnection(); // Check-in and initialize the profile of identity 1. await clientCallee.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClCustomer], true); bool checkInOk = await clientCallee.CheckInAsync(); bool initializeProfileOk = await clientCallee.InitializeProfileAsync("Test Identity", null, new GpsLocation(0, 0), null); // Add application service to the current session. string serviceName = "Test Service"; bool addAppServiceOk = await clientCallee.AddApplicationServicesAsync(new List <string>() { serviceName }); // Step 1 Acceptance bool step1Ok = listPortsOk && establishHostingOk && checkInOk && initializeProfileOk && addAppServiceOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await clientCaller.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool verifyIdentityOk = await clientCaller.VerifyIdentityAsync(); Message requestMessage = mbCaller.CreateCallIdentityApplicationServiceRequest(identityIdCallee, "Test Service Invalid"); await clientCaller.SendMessageAsync(requestMessage); Message responseMessage = await clientCaller.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue; bool detailsOk = responseMessage.Response.Details == "serviceName"; bool callIdentityOk = idOk && statusOk && detailsOk; // Step 2 Acceptance bool step2Ok = verifyIdentityOk && callIdentityOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } clientCallee.Dispose(); clientCalleeAppService.Dispose(); clientCaller.Dispose(); clientCallerAppService.Dispose(); log.Trace("(-):{0}", res); return(res); }
/// <summary> /// Implementation of the test itself. /// </summary> /// <returns>true if the test passes, false otherwise.</returns> public async Task <bool> RunAsyncInternal(int Index) { IPAddress ServerIp = (IPAddress)ArgumentValues["Server IP"]; int PrimaryPort = (int)ArgumentValues["primary Port"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1},Index:{2})", ServerIp, PrimaryPort, Index); bool res = false; PassedArray[Index] = false; ProtocolClient clientCallee = new ProtocolClient(); ProtocolClient clientCalleeAppService = new ProtocolClient(0, SemVer.V100, clientCallee.GetIdentityKeys()); ProtocolClient clientCaller = new ProtocolClient(); ProtocolClient clientCallerAppService = new ProtocolClient(0, SemVer.V100, clientCaller.GetIdentityKeys()); try { MessageBuilder mbCallee = clientCallee.MessageBuilder; MessageBuilder mbCalleeAppService = clientCalleeAppService.MessageBuilder; MessageBuilder mbCaller = clientCaller.MessageBuilder; MessageBuilder mbCallerAppService = clientCallerAppService.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. byte[] pubKeyCallee = clientCallee.GetIdentityKeys().PublicKey; byte[] identityIdCallee = clientCallee.GetIdentityId(); byte[] pubKeyCaller = clientCaller.GetIdentityKeys().PublicKey; byte[] identityIdCaller = clientCaller.GetIdentityId(); await clientCallee.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await clientCallee.ListServerPorts(rolePorts); clientCallee.CloseConnection(); // Establish hosting agreement for identity 1. await clientCallee.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool establishHostingOk = await clientCallee.EstablishHostingAsync(); clientCallee.CloseConnection(); // Check-in and initialize the profile of identity 1. await clientCallee.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClCustomer], true); bool checkInOk = await clientCallee.CheckInAsync(); bool initializeProfileOk = await clientCallee.InitializeProfileAsync("Test Identity", null, new GpsLocation(0, 0), null); // Add application service to the current session. string serviceName = "Test Service"; bool addAppServiceOk = await clientCallee.AddApplicationServicesAsync(new List <string>() { serviceName }); // Step 1 Acceptance bool step1Ok = listPortsOk && establishHostingOk && checkInOk && initializeProfileOk && addAppServiceOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await clientCaller.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool verifyIdentityOk = await clientCaller.VerifyIdentityAsync(); Message requestMessage = mbCaller.CreateCallIdentityApplicationServiceRequest(identityIdCallee, serviceName); await clientCaller.SendMessageAsync(requestMessage); // Step 2 Acceptance bool step2Ok = verifyIdentityOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); Message serverRequestMessage = await clientCallee.ReceiveMessageAsync(); byte[] receivedPubKey = serverRequestMessage.Request.ConversationRequest.IncomingCallNotification.CallerPublicKey.ToByteArray(); bool pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, pubKeyCaller) == 0; bool serviceNameOk = serverRequestMessage.Request.ConversationRequest.IncomingCallNotification.ServiceName == serviceName; bool incomingCallNotificationOk = pubKeyOk && serviceNameOk; byte[] calleeToken = serverRequestMessage.Request.ConversationRequest.IncomingCallNotification.CalleeToken.ToByteArray(); Message serverResponseMessage = mbCallee.CreateIncomingCallNotificationResponse(serverRequestMessage); await clientCallee.SendMessageAsync(serverResponseMessage); // Connect to clAppService and send initialization message. await clientCalleeAppService.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClAppService], true); Message requestMessageAppServiceCallee = mbCalleeAppService.CreateApplicationServiceSendMessageRequest(calleeToken, null); await clientCalleeAppService.SendMessageAsync(requestMessageAppServiceCallee); // Step 3 Acceptance bool step3Ok = incomingCallNotificationOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); Message responseMessage = await clientCaller.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; byte[] callerToken = responseMessage.Response.ConversationResponse.CallIdentityApplicationService.CallerToken.ToByteArray(); bool callIdentityOk = idOk && statusOk; // Connect to clAppService and send initialization message. await clientCallerAppService.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClAppService], true); Message requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(callerToken, null); await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); Message responseMessageAppServiceCaller = await clientCallerAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCaller.Id == requestMessageAppServiceCaller.Id; statusOk = responseMessageAppServiceCaller.Response.Status == Status.Ok; bool initAppServiceMessageOk = idOk && statusOk; // And close connection to clNonCustomer port. clientCaller.CloseConnection(); // Step 4 Acceptance bool step4Ok = callIdentityOk && initAppServiceMessageOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); Message responseMessageAppServiceCallee = await clientCalleeAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCallee.Id == requestMessageAppServiceCallee.Id; statusOk = responseMessageAppServiceCallee.Response.Status == Status.Ok; bool typeOk = (responseMessageAppServiceCallee.MessageTypeCase == Message.MessageTypeOneofCase.Response) && (responseMessageAppServiceCallee.Response.ConversationTypeCase == Response.ConversationTypeOneofCase.SingleResponse) && (responseMessageAppServiceCallee.Response.SingleResponse.ResponseTypeCase == SingleResponse.ResponseTypeOneofCase.ApplicationServiceSendMessage); bool appServiceSendOk = idOk && statusOk && typeOk; // Step 5 Acceptance bool step5Ok = appServiceSendOk; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 UnfinishedRequestCounter callerCounter = new UnfinishedRequestCounter() { Name = string.Format("Caller-{0}", Index) }; UnfinishedRequestCounter calleeCounter = new UnfinishedRequestCounter() { Name = string.Format("Callee-{0}", Index) }; SemaphoreSlim callerWriteLock = new SemaphoreSlim(1); SemaphoreSlim calleeWriteLock = new SemaphoreSlim(1); Task <byte[]> messageReceivingTaskCaller = MessageReceivingLoop(clientCallerAppService, mbCallerAppService, "CallerReceiving", callerWriteLock, callerCounter); Task <byte[]> messageReceivingTaskCallee = MessageReceivingLoop(clientCalleeAppService, mbCalleeAppService, "CalleeReceiving", calleeWriteLock, calleeCounter); Task <byte[]> messageSendingTaskCaller = MessageSendingLoop(clientCallerAppService, mbCallerAppService, "CallerSending", callerToken, callerWriteLock, callerCounter); Task <byte[]> messageSendingTaskCallee = MessageSendingLoop(clientCalleeAppService, mbCalleeAppService, "CalleeSending", calleeToken, calleeWriteLock, calleeCounter); byte[] callerSendMessageHash = messageSendingTaskCaller.Result; byte[] calleeSendMessageHash = messageSendingTaskCallee.Result; byte[] callerReceiveMessageHash = messageReceivingTaskCaller.Result; byte[] calleeReceiveMessageHash = messageReceivingTaskCallee.Result; bool callerMessageHashOk = StructuralComparisons.StructuralComparer.Compare(callerSendMessageHash, calleeReceiveMessageHash) == 0; bool calleeMessageHashOk = StructuralComparisons.StructuralComparer.Compare(calleeSendMessageHash, callerReceiveMessageHash) == 0; // Step 6 Acceptance bool step6Ok = callerMessageHashOk && calleeMessageHashOk; log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED"); PassedArray[Index] = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok; log.Trace("PassedArray[{0}] = {1}", Index, PassedArray[Index]); res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } clientCallee.Dispose(); clientCalleeAppService.Dispose(); clientCaller.Dispose(); clientCallerAppService.Dispose(); 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"]; log.Trace("(ServerIp:'{0}',PrimaryPort:{1})", ServerIp, PrimaryPort); bool res = false; Passed = false; ProtocolClient clientCallee = new ProtocolClient(); ProtocolClient clientCalleeAppService = new ProtocolClient(0, SemVer.V100, clientCallee.GetIdentityKeys()); ProtocolClient clientCaller = new ProtocolClient(); ProtocolClient clientCallerAppService = new ProtocolClient(0, SemVer.V100, clientCaller.GetIdentityKeys()); try { MessageBuilder mbCallee = clientCallee.MessageBuilder; MessageBuilder mbCalleeAppService = clientCalleeAppService.MessageBuilder; MessageBuilder mbCaller = clientCaller.MessageBuilder; MessageBuilder mbCallerAppService = clientCallerAppService.MessageBuilder; // Step 1 log.Trace("Step 1"); // Get port list. byte[] pubKeyCallee = clientCallee.GetIdentityKeys().PublicKey; byte[] identityIdCallee = clientCallee.GetIdentityId(); byte[] pubKeyCaller = clientCaller.GetIdentityKeys().PublicKey; byte[] identityIdCaller = clientCaller.GetIdentityId(); await clientCallee.ConnectAsync(ServerIp, PrimaryPort, false); Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>(); bool listPortsOk = await clientCallee.ListServerPorts(rolePorts); clientCallee.CloseConnection(); // Establish hosting agreement for identity 1. await clientCallee.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool establishHostingOk = await clientCallee.EstablishHostingAsync(); clientCallee.CloseConnection(); // Check-in and initialize the profile of identity 1. await clientCallee.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClCustomer], true); bool checkInOk = await clientCallee.CheckInAsync(); bool initializeProfileOk = await clientCallee.InitializeProfileAsync("Test Identity", null, new GpsLocation(0, 0), null); // Add application service to the current session. string serviceName = "Test Service"; bool addAppServiceOk = await clientCallee.AddApplicationServicesAsync(new List <string>() { serviceName }); // Step 1 Acceptance bool step1Ok = listPortsOk && establishHostingOk && checkInOk && initializeProfileOk && addAppServiceOk; log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED"); // Step 2 log.Trace("Step 2"); await clientCaller.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true); bool verifyIdentityOk = await clientCaller.VerifyIdentityAsync(); Message requestMessage = mbCaller.CreateCallIdentityApplicationServiceRequest(identityIdCallee, serviceName); await clientCaller.SendMessageAsync(requestMessage); // Step 2 Acceptance bool step2Ok = verifyIdentityOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); Message serverRequestMessage = await clientCallee.ReceiveMessageAsync(); byte[] receivedPubKey = serverRequestMessage.Request.ConversationRequest.IncomingCallNotification.CallerPublicKey.ToByteArray(); bool pubKeyOk = StructuralComparisons.StructuralComparer.Compare(receivedPubKey, pubKeyCaller) == 0; bool serviceNameOk = serverRequestMessage.Request.ConversationRequest.IncomingCallNotification.ServiceName == serviceName; bool incomingCallNotificationOk = pubKeyOk && serviceNameOk; byte[] calleeToken = serverRequestMessage.Request.ConversationRequest.IncomingCallNotification.CalleeToken.ToByteArray(); Message serverResponseMessage = mbCallee.CreateIncomingCallNotificationResponse(serverRequestMessage); await clientCallee.SendMessageAsync(serverResponseMessage); // Connect to clAppService and send initialization message. await clientCalleeAppService.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClAppService], true); Message requestMessageAppServiceCallee = mbCalleeAppService.CreateApplicationServiceSendMessageRequest(calleeToken, null); await clientCalleeAppService.SendMessageAsync(requestMessageAppServiceCallee); // Step 3 Acceptance bool step3Ok = incomingCallNotificationOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); // Step 4 log.Trace("Step 4"); Message responseMessage = await clientCaller.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; byte[] callerToken = responseMessage.Response.ConversationResponse.CallIdentityApplicationService.CallerToken.ToByteArray(); bool callIdentityOk = idOk && statusOk; // Connect to clAppService and send initialization message. await clientCallerAppService.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClAppService], true); Message requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(callerToken, null); await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); Message responseMessageAppServiceCaller = await clientCallerAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCaller.Id == requestMessageAppServiceCaller.Id; statusOk = responseMessageAppServiceCaller.Response.Status == Status.Ok; bool initAppServiceMessageOk = idOk && statusOk; // And close connection to clNonCustomer port. clientCaller.CloseConnection(); // Step 4 Acceptance bool step4Ok = callIdentityOk && initAppServiceMessageOk; log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED"); // Step 5 log.Trace("Step 5"); Message responseMessageAppServiceCallee = await clientCalleeAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCallee.Id == requestMessageAppServiceCallee.Id; statusOk = responseMessageAppServiceCallee.Response.Status == Status.Ok; bool typeOk = (responseMessageAppServiceCallee.MessageTypeCase == Message.MessageTypeOneofCase.Response) && (responseMessageAppServiceCallee.Response.ConversationTypeCase == Response.ConversationTypeOneofCase.SingleResponse) && (responseMessageAppServiceCallee.Response.SingleResponse.ResponseTypeCase == SingleResponse.ResponseTypeOneofCase.ApplicationServiceSendMessage); bool appServiceSendOk = idOk && statusOk && typeOk; // Step 5 Acceptance bool step5Ok = appServiceSendOk; log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED"); // Step 6 log.Trace("Step 6"); string callerMessage1 = "Message #1 to callee."; byte[] messageBytes = Encoding.UTF8.GetBytes(callerMessage1); string testStr = "test"; byte[] invalidCallerToken = Encoding.UTF8.GetBytes(testStr); requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(invalidCallerToken, messageBytes); uint callerMessage1Id = requestMessageAppServiceCaller.Id; await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); responseMessageAppServiceCaller = await clientCallerAppService.ReceiveMessageAsync(); idOk = responseMessageAppServiceCaller.Id == callerMessage1Id; statusOk = responseMessageAppServiceCaller.Response.Status == Status.ErrorNotFound; bool sendMessageOk = idOk && statusOk; // The caller should be disconnected by now, send or receive should throw. string callerMessage2 = "Message #2 to callee."; messageBytes = Encoding.UTF8.GetBytes(callerMessage2); requestMessageAppServiceCaller = mbCallerAppService.CreateApplicationServiceSendMessageRequest(callerToken, messageBytes); bool disconnectedOk = false; try { await clientCallerAppService.SendMessageAsync(requestMessageAppServiceCaller); await clientCallerAppService.ReceiveMessageAsync(); } catch { log.Trace("Expected exception occurred."); disconnectedOk = true; } // Step 6 Acceptance bool step6Ok = sendMessageOk && disconnectedOk; log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED"); // Step 7 log.Trace("Step 7"); string calleeMessage1 = "Message #1 to CALLER."; messageBytes = Encoding.UTF8.GetBytes(calleeMessage1); requestMessageAppServiceCallee = mbCalleeAppService.CreateApplicationServiceSendMessageRequest(calleeToken, messageBytes); disconnectedOk = false; try { await clientCalleeAppService.SendMessageAsync(requestMessageAppServiceCallee); await clientCalleeAppService.ReceiveMessageAsync(); } catch { log.Trace("Expected exception occurred."); disconnectedOk = true; } // Step 7 Acceptance bool step7Ok = sendMessageOk && disconnectedOk; log.Trace("Step 7: {0}", step7Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok && step7Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } clientCallee.Dispose(); clientCalleeAppService.Dispose(); clientCaller.Dispose(); clientCallerAppService.Dispose(); 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 NodeIp = (IPAddress)ArgumentValues["Node IP"]; int ClNonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; int ClCustomerPort = (int)ArgumentValues["clCustomer Port"]; log.Trace("(NodeIp:'{0}',ClNonCustomerPort:{1},ClCustomerPort:{2})", NodeIp, ClNonCustomerPort, ClCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); try { MessageBuilder mb = client.MessageBuilder; // Step 1 await client.ConnectAsync(NodeIp, ClNonCustomerPort, true); bool establishHomeNodeOk = await client.EstablishHomeNodeAsync(); // Step 1 Acceptance bool step1Ok = establishHomeNodeOk; client.CloseConnection(); // Step 2 await client.ConnectAsync(NodeIp, ClCustomerPort, true); bool checkInOk = await client.CheckInAsync(); Message requestMessage = mb.CreateCancelHomeNodeAgreementRequest(null); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; bool statusOk = responseMessage.Response.Status == Status.Ok; bool cancelHomeNodeAgreementOk = idOk && statusOk; // Step 2 Acceptance bool step2Ok = checkInOk && cancelHomeNodeAgreementOk; client.CloseConnection(); // Step 3 await client.ConnectAsync(NodeIp, ClCustomerPort, true); bool startConversationOk = await client.StartConversationAsync(); requestMessage = mb.CreateCheckInRequest(client.Challenge); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.ErrorNotFound; checkInOk = idOk && statusOk; // Step 3 Acceptance bool step3Ok = startConversationOk && checkInOk; client.CloseConnection(); // Step 4 await client.ConnectAsync(NodeIp, ClNonCustomerPort, true); establishHomeNodeOk = await client.EstablishHomeNodeAsync(); // Step 4 Acceptance bool step4Ok = establishHomeNodeOk; client.CloseConnection(); // Step 5 await client.ConnectAsync(NodeIp, ClCustomerPort, true); checkInOk = await client.CheckInAsync(); // Step 5 Acceptance bool step5Ok = checkInOk; Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); 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(); // Radius generation. R2 = (uint)Rng.Next(R2Min, R2Max); R1 = (uint)Rng.Next(R1Min, (int)(R1R2RatioMax * R2)); R3 = (uint)Rng.Next((int)(R3R2RatioMax * R2), R3Max); log.Trace("R1: {0,8} m", R1); log.Trace("R2: {0,8} m", R2); log.Trace("R3: {0,8} m", R3); // Location generation for (int i = 0; i < LocationCount; i++) { if (PredefinedLocations.Count > i) { GeneratedLocations.Add(GenerateLocation(PredefinedLocations[i], R2)); } else { int lat = Rng.Next((int)(GpsLocation.LatitudeMin * GpsLocation.LocationTypeFactor), (int)(GpsLocation.LatitudeMax * GpsLocation.LocationTypeFactor) + 1); int lon = Rng.Next((int)(GpsLocation.LongitudeMin * GpsLocation.LocationTypeFactor) + 1, (int)(GpsLocation.LongitudeMax * GpsLocation.LocationTypeFactor) + 1); GeneratedLocations.Add(new GpsLocation(lat, lon)); } } log.Trace("Generated locations:"); for (int i = 0; i < LocationCount; i++) { log.Trace(" #{0:00}: {1:US}", i, GeneratedLocations[i]); } // Create identities. int profileNumber = 0; byte[] imageData = File.ReadAllBytes(Path.Combine("images", TestName + ".png")); uint[] rads = new uint[] { R1, R2, R3 }; for (int locIndex = 0; locIndex < LocationCount; locIndex++) { for (uint radIndex = 0; radIndex < rads.Length; radIndex++) { for (int idIndex = 0; idIndex < RadiusIdentityCount; idIndex++) { GpsLocation basePoint = GeneratedLocations[locIndex]; uint radius = rads[radIndex]; GpsLocation location = GenerateLocation(basePoint, radius); ProfileLocations.Add(location); ProtocolClient profileClient = new ProtocolClient(); profileClient.InitializeRandomProfile(profileNumber, imageData); profileNumber++; profileClient.Profile.Location = location; TestProfiles.Add(profileClient.Profile.Name, profileClient); ProfileNames.Add(profileClient.Profile.Name); } } } // 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; List <ProtocolClient> profilesToSend = new List <ProtocolClient>(TestProfiles.Values); while (profilesToSend.Count > 0) { int batchSize = Rng.Next(1, Math.Min(100, profilesToSend.Count) + 1); 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); 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"); // 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. Message requestMessage = mb.CreateProfileSearchRequest(null, null, null, null, 0, 1000, 1000, false, false); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool totalRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == ProfileNames.Count; bool maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 1000; bool profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == ProfileNames.Count; HashSet <byte[]> realCoveredServers = new HashSet <byte[]>(StructuralEqualityComparer <byte[]> .Default); foreach (ByteString csId in responseMessage.Response.ConversationResponse.ProfileSearch.CoveredServers) { realCoveredServers.Add(csId.ToByteArray()); } bool coveredServersOk = expectedCoveredServers.SetEquals(realCoveredServers); bool queryRespOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk; bool resultsOk = client.CheckProfileListMatchSearchResultItems(TestProfiles, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.ToList(), false, false, client.GetIdentityId(), false); bool query1Ok = queryRespOk && resultsOk; bool queriesOk = true; // Search queries around target locations. for (int locIndex = 0; locIndex < LocationCount; locIndex++) { for (uint radIndex = 0; radIndex < rads.Length + 1; radIndex++) { uint radius = radIndex < rads.Length ? rads[radIndex] : (uint)Rng.Next(1000000, 10000000); GpsLocation targetLocation = GeneratedLocations[locIndex]; requestMessage = mb.CreateProfileSearchRequest(null, null, null, targetLocation, radius, 1000, 1000, false, false); await client.SendMessageAsync(requestMessage); responseMessage = await client.ReceiveMessageAsync(); idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; Dictionary <string, ProtocolClient> expectedClients = GetClientsInLocation(targetLocation, radius); totalRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == expectedClients.Count; maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 1000; profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == expectedClients.Count; queryRespOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk; resultsOk = client.CheckProfileListMatchSearchResultItems(expectedClients, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.ToList(), false, false, client.GetIdentityId(), false); queriesOk = queryRespOk && resultsOk; if (!queriesOk) { log.Trace("Search query location {0} with radius {1} should produce {2} profiles, but produced {3} profiles.", targetLocation, radius, expectedClients.Count, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count); log.Trace("Expected names list:"); foreach (string name in expectedClients.Keys) { log.Trace(" {0}", name); } List <string> resultNames = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Select(r => r.Name).OrderBy(r => r).ToList(); log.Trace("Query result names list:"); foreach (string name in resultNames) { log.Trace(" {0}", name); } break; } log.Trace("Search query location {0} with radius {1} produced {2} correct profiles.", targetLocation, radius, expectedClients.Count); } if (!queriesOk) { break; } } // Step 3 Acceptance bool step3Ok = startConversationOk && query1Ok && queriesOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok; 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. int profileNumber = 0; byte[] imageData = File.ReadAllBytes(Path.Combine("images", TestName + ".png")); for (int i = 0; i < 20500; i++) { ProtocolClient profileClient = new ProtocolClient(); profileClient.InitializeRandomProfile(profileNumber, imageData); profileNumber++; TestProfiles.Add(profileClient.Profile.Name, profileClient); } // 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> profilesToSend = new List <ProtocolClient>(TestProfiles.Values); 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); if (profilesSent <= 20000) { statusOk = incomingServerMessage.IncomingMessage.Response.Status == Status.Ok; bool batchOk = (updateRequest != null) && statusOk; if (!batchOk) { updateOk = false; break; } } else { statusOk = incomingServerMessage.IncomingMessage.Response.Status == Status.ErrorInvalidValue; int badIndex = 20000 - (profilesSent - batchSize); string expectedDetails = badIndex.ToString() + ".add"; log.Trace("Expected details are '{0}'.", expectedDetails); bool detailsOk = incomingServerMessage.IncomingMessage.Response.Details == expectedDetails; bool batchOk = (updateRequest != null) && statusOk && detailsOk; if (!batchOk) { updateOk = false; } break; } } bool step2Ok = changeNotificationOk && updateOk; log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED"); // Step 3 log.Trace("Step 3"); // 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. Message requestMessage = mb.CreateProfileSearchRequest(null, null, null, null, 0, 100, 100); await client.SendMessageAsync(requestMessage); Message responseMessage = await client.ReceiveMessageAsync(); bool idOk = responseMessage.Id == requestMessage.Id; statusOk = responseMessage.Response.Status == Status.Ok; bool totalRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == 0; bool maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100; bool profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == 0; bool queryOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk; // Step 3 Acceptance bool step3Ok = startConversationOk && queryOk; log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED"); Passed = step1Ok && step2Ok && step3Ok; 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); }