Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <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.CreateVerifyIdentityRequest(client.Challenge);

                // Invalidate signature.
                byte[] signature = requestMessage.Request.ConversationRequest.Signature.ToByteArray();
                signature[0] ^= 0x12;
                requestMessage.Request.ConversationRequest.Signature = ProtocolHelper.ByteArrayToByteString(signature);

                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk             = responseMessage.Id == requestMessage.Id;
                bool statusOk         = responseMessage.Response.Status == Status.ErrorInvalidSignature;
                bool verifyIdentityOk = idOk && statusOk;

                // Step 1 Acceptance
                Passed = startConversationOk && verifyIdentityOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Beispiel #3
0
        /// <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 startConversationOk = await client.StartConversationAsync();

                // Invalidate challenge.
                byte[] challenge = new byte[client.Challenge.Length];
                Array.Copy(client.Challenge, challenge, challenge.Length);
                challenge[0] ^= 0x12;

                Message requestMessage = mb.CreateVerifyIdentityRequest(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 verifyIdentityOk = idOk && statusOk && detailsOk;

                // Step 1 Acceptance
                Passed = startConversationOk && verifyIdentityOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Beispiel #4
0
        /// <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 startConversationOk = await client.StartConversationAsync();

                byte[]  data           = Encoding.UTF8.GetBytes("test");
                byte[]  fakeId         = Crypto.Sha1(data);
                Message requestMessage = mb.CreateCallIdentityApplicationServiceRequest(fakeId, "Test Service");

                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.ErrorUnauthorized;

                // Step 1 Acceptance
                Passed = startConversationOk && idOk && statusOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Beispiel #5
0
        /// <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
                Passed = startConversationOk && registerHostingOk;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Beispiel #6
0
        /// <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);
        }
Beispiel #7
0
        /// <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);
        }
Beispiel #8
0
        /// <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);
        }
Beispiel #9
0
        /// <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);
        }
Beispiel #10
0
        /// <summary>
        /// Implementation of the test itself.
        /// </summary>
        /// <returns>true if the test passes, false otherwise.</returns>
        public override async Task <bool> RunAsync()
        {
            IPAddress ServerIp    = (IPAddress)ArgumentValues["Server IP"];
            int       PrimaryPort = (int)ArgumentValues["primary Port"];
            int       BasePort    = (int)ArgumentValues["Base Port"];
            int       LocPort     = (int)ArgumentValues["LOC Port"];

            log.Trace("(ServerIp:'{0}',PrimaryPort:{1},BasePort:{2},LocPort:{3})", ServerIp, PrimaryPort, BasePort, LocPort);

            bool res = false;

            Passed = false;

            ProtocolClient client        = new ProtocolClient();
            ProfileServer  profileServer = null;
            LocServer      locServer     = null;

            try
            {
                MessageBuilder mb = client.MessageBuilder;

                // Step 1
                log.Trace("Step 1");

                // Get port list.
                await client.ConnectAsync(ServerIp, PrimaryPort, false);

                Dictionary <ServerRoleType, uint> rolePorts = new Dictionary <ServerRoleType, uint>();
                bool listPortsOk = await client.ListServerPorts(rolePorts);

                client.CloseConnection();

                // Create identities.
                int    profileNumber = 0;
                byte[] imageData     = File.ReadAllBytes(Path.Combine("images", TestName + ".png"));

                Dictionary <string, ProtocolClient> expectedLastClients = new Dictionary <string, ProtocolClient>(StringComparer.Ordinal);
                List <string> excessClientNames = new List <string>();
                for (int i = 0; i < 20050; i++)
                {
                    ProtocolClient protocolClient = new ProtocolClient();
                    protocolClient.InitializeRandomProfile(profileNumber, imageData);
                    profileNumber++;
                    if (i >= 19990)
                    {
                        protocolClient.Profile.Type = "last";
                        if (i < 20000)
                        {
                            expectedLastClients.Add(protocolClient.Profile.Name, protocolClient);
                        }
                        else
                        {
                            excessClientNames.Add(protocolClient.Profile.Name);
                        }
                    }
                    TestProfiles.Add(protocolClient.Profile.Name, protocolClient);
                }


                // Start simulated profile server.
                profileServer = new ProfileServer("TestProfileServer", ServerIp, BasePort, client.GetIdentityKeys(), new GpsLocation(1, 2));
                bool profileServerStartOk = profileServer.Start();

                // Start simulated LOC server.
                locServer = new LocServer("TestLocServer", ServerIp, LocPort);
                bool locServerStartOk = locServer.Start();

                await locServer.WaitForProfileServerConnectionAsync();

                bool step1Ok = profileServerStartOk && locServerStartOk;
                log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED");


                // Step 2
                log.Trace("Step 2");

                // Announce new neighbor.
                Iop.Locnet.NeighbourhoodChange change = new Iop.Locnet.NeighbourhoodChange()
                {
                    AddedNodeInfo = profileServer.GetNodeInfo(LocPort)
                };

                bool changeNotificationOk = await locServer.SendChangeNotification(change);

                // Wait for start of neighborhood initialization process.
                IncomingServerMessage incomingServerMessage = await profileServer.WaitForConversationRequest(ServerRole.ServerNeighbor, ConversationRequest.RequestTypeOneofCase.StartNeighborhoodInitialization);


                // Send update.
                bool statusOk     = false;
                bool updateOk     = true;
                int  profilesSent = 0;
                List <ProtocolClient> allProfiles    = new List <ProtocolClient>(TestProfiles.Values);
                List <ProtocolClient> profilesToSend = allProfiles.GetRange(0, 19990);
                while (profilesToSend.Count > 0)
                {
                    int batchSize = Math.Min(Rng.Next(100, 150), profilesToSend.Count);

                    List <SharedProfileUpdateItem> updateItems = new List <SharedProfileUpdateItem>();
                    foreach (ProtocolClient pc in profilesToSend.GetRange(0, batchSize))
                    {
                        updateItems.Add(pc.GetSharedProfileUpdateAddItem());
                    }

                    profilesToSend.RemoveRange(0, batchSize);

                    Message updateRequest = await profileServer.SendNeighborhoodSharedProfileUpdateRequest(incomingServerMessage.Client, updateItems);

                    profilesSent         += batchSize;
                    incomingServerMessage = await profileServer.WaitForResponse(ServerRole.ServerNeighbor, updateRequest);

                    statusOk = incomingServerMessage.IncomingMessage.Response.Status == Status.Ok;
                    bool batchOk = (updateRequest != null) && statusOk;
                    if (!batchOk)
                    {
                        updateOk = false;
                        break;
                    }
                }


                // Finish neighborhood initialization process.
                Message finishRequest = await profileServer.SendFinishNeighborhoodInitializationRequest(incomingServerMessage.Client);

                incomingServerMessage = await profileServer.WaitForResponse(ServerRole.ServerNeighbor, finishRequest);

                statusOk = incomingServerMessage.IncomingMessage.Response.Status == Status.Ok;
                bool finishOk = (finishRequest != null) && statusOk;


                bool step2Ok = changeNotificationOk && updateOk && finishOk;
                log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED");



                // Step 3
                log.Trace("Step 3");

                await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true);

                bool verifyIdentityOk = await client.VerifyIdentityAsync();

                List <SharedProfileUpdateItem> badUpdateItems = new List <SharedProfileUpdateItem>();
                foreach (ProtocolClient pc in allProfiles.GetRange(19990, 60))
                {
                    badUpdateItems.Add(pc.GetSharedProfileUpdateAddItem());
                }


                Message requestMessage = mb.CreateNeighborhoodSharedProfileUpdateRequest(badUpdateItems);
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue;
                bool detailsOk = responseMessage.Response.Details == "10.add";

                bool badUpdateOk = idOk && statusOk && detailsOk;
                client.CloseConnection();

                // Step 3 Acceptance
                bool step3Ok = verifyIdentityOk && badUpdateOk;

                log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED");



                // Step 4
                log.Trace("Step 4");

                // Start conversation.
                await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true);

                bool startConversationOk = await client.StartConversationAsync();

                HashSet <byte[]> expectedCoveredServers = new HashSet <byte[]>(StructuralEqualityComparer <byte[]> .Default)
                {
                    client.GetIdentityId(), Crypto.Sha256(client.ServerKey)
                };

                // Search all profiles with type "last".
                requestMessage = mb.CreateProfileSearchRequest("last", null, null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                bool totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == 10;
                bool maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                bool profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == 10;
                bool resultsOk = client.CheckProfileListMatchSearchResultItems(expectedLastClients, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.ToList(), false, false, client.GetIdentityId(), true);

                bool queryOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && resultsOk;

                client.CloseConnection();

                // Step 4 Acceptance
                bool step4Ok = startConversationOk && queryOk;

                log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED");



                // Step 5
                log.Trace("Step 5");

                // Make TestProfiles reflect the status on the target profile server.
                foreach (string excessClientName in excessClientNames)
                {
                    TestProfiles[excessClientName].Dispose();
                    TestProfiles.Remove(excessClientName);
                }

                await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true);

                verifyIdentityOk = await client.VerifyIdentityAsync();

                // Select 140 profiles for deletion.
                List <SharedProfileUpdateItem> deleteUpdateItems = new List <SharedProfileUpdateItem>();
                while (deleteUpdateItems.Count < 140)
                {
                    int            index = Rng.Next(TestProfiles.Count);
                    ProtocolClient pc    = TestProfiles.ElementAt(index).Value;
                    deleteUpdateItems.Add(pc.GetSharedProfileUpdateDeleteItem());

                    if (expectedLastClients.ContainsKey(pc.Profile.Name))
                    {
                        expectedLastClients.Remove(pc.Profile.Name);
                    }

                    TestProfiles.Remove(pc.Profile.Name);
                    pc.Dispose();
                }

                // Send delete update.
                requestMessage = mb.CreateNeighborhoodSharedProfileUpdateRequest(deleteUpdateItems);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;

                bool deleteUpdateOk = idOk && statusOk;


                // Generate 160 new identities.
                badUpdateItems.Clear();
                excessClientNames.Clear();
                for (int i = 0; i < 160; i++)
                {
                    ProtocolClient protocolClient = new ProtocolClient();
                    protocolClient.InitializeRandomProfile(profileNumber, imageData);
                    profileNumber++;
                    protocolClient.Profile.Type = "last";

                    if (TestProfiles.Count < 20000)
                    {
                        expectedLastClients.Add(protocolClient.Profile.Name, protocolClient);
                    }
                    else
                    {
                        excessClientNames.Add(protocolClient.Profile.Name);
                    }

                    TestProfiles.Add(protocolClient.Profile.Name, protocolClient);
                    badUpdateItems.Add(protocolClient.GetSharedProfileUpdateAddItem());
                }


                // Add the new profiles to the profile server.
                requestMessage = mb.CreateNeighborhoodSharedProfileUpdateRequest(badUpdateItems);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk      = responseMessage.Id == requestMessage.Id;
                statusOk  = responseMessage.Response.Status == Status.ErrorInvalidValue;
                detailsOk = responseMessage.Response.Details == "140.add";

                badUpdateOk = idOk && statusOk && detailsOk;
                client.CloseConnection();

                // Step 5 Acceptance
                bool step5Ok = verifyIdentityOk && deleteUpdateOk && badUpdateOk;

                log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED");



                // Step 6
                log.Trace("Step 6");

                // Make TestProfiles reflect the status on the target profile server.
                foreach (string excessClientName in excessClientNames)
                {
                    TestProfiles[excessClientName].Dispose();
                    TestProfiles.Remove(excessClientName);
                }

                // Start conversation.
                await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true);

                startConversationOk = await client.StartConversationAsync();

                // Search all profiles with type "last".
                requestMessage = mb.CreateProfileSearchRequest("last", null, null, null, 0, 1000, 1000, false, false);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == expectedLastClients.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 1000;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == expectedLastClients.Count;
                resultsOk = client.CheckProfileListMatchSearchResultItems(expectedLastClients, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.ToList(), false, false, client.GetIdentityId(), false);

                queryOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && resultsOk;

                client.CloseConnection();

                // Step 6 Acceptance
                bool step6Ok = startConversationOk && queryOk;

                log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED");



                // Step 7
                log.Trace("Step 7");

                await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.SrNeighbor], true);

                verifyIdentityOk = await client.VerifyIdentityAsync();

                // Select 40 profiles for deletion.
                deleteUpdateItems = new List <SharedProfileUpdateItem>();
                while (deleteUpdateItems.Count < 40)
                {
                    int            index = Rng.Next(TestProfiles.Count);
                    ProtocolClient pc    = TestProfiles.ElementAt(index).Value;
                    deleteUpdateItems.Add(pc.GetSharedProfileUpdateDeleteItem());

                    if (expectedLastClients.ContainsKey(pc.Profile.Name))
                    {
                        expectedLastClients.Remove(pc.Profile.Name);
                    }

                    TestProfiles.Remove(pc.Profile.Name);
                    pc.Dispose();
                }

                // Select 40 profiles for change, but avoid updating one profile twice in a single update message, which is forbidden.
                HashSet <int> usedIndexes = new HashSet <int>();
                List <SharedProfileUpdateItem> changeUpdateItems = new List <SharedProfileUpdateItem>();
                while (changeUpdateItems.Count < 40)
                {
                    int index = Rng.Next(TestProfiles.Count);

                    if (usedIndexes.Contains(index))
                    {
                        continue;
                    }
                    usedIndexes.Add(index);

                    ProtocolClient pc = TestProfiles.ElementAt(index).Value;
                    pc.Profile.ExtraData = "1234567890";
                    SharedProfileUpdateItem changeUpdateItem = new SharedProfileUpdateItem()
                    {
                        Change = new SharedProfileChangeItem()
                        {
                            IdentityNetworkId = ProtocolHelper.ByteArrayToByteString(pc.GetIdentityId()),
                            SetExtraData      = true,
                            ExtraData         = pc.Profile.ExtraData
                        }
                    };
                    changeUpdateItems.Add(changeUpdateItem);
                }

                // Generate 40 new identities.
                List <SharedProfileUpdateItem> addUpdateItems = new List <SharedProfileUpdateItem>();
                for (int i = 0; i < 40; i++)
                {
                    ProtocolClient protocolClient = new ProtocolClient();
                    protocolClient.InitializeRandomProfile(profileNumber, imageData);
                    profileNumber++;
                    protocolClient.Profile.Type = "last";

                    expectedLastClients.Add(protocolClient.Profile.Name, protocolClient);

                    TestProfiles.Add(protocolClient.Profile.Name, protocolClient);
                    addUpdateItems.Add(protocolClient.GetSharedProfileUpdateAddItem());
                }


                // Send all the updates as one.
                List <SharedProfileUpdateItem> newUpdateItems = new List <SharedProfileUpdateItem>();
                newUpdateItems.AddRange(deleteUpdateItems);
                newUpdateItems.AddRange(changeUpdateItems);
                newUpdateItems.AddRange(addUpdateItems);
                requestMessage = mb.CreateNeighborhoodSharedProfileUpdateRequest(newUpdateItems);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;

                bool newUpdateOk = idOk && statusOk;
                client.CloseConnection();

                // Step 7 Acceptance
                bool step7Ok = verifyIdentityOk && newUpdateOk;

                log.Trace("Step 7: {0}", step7Ok ? "PASSED" : "FAILED");



                // Step 8
                log.Trace("Step 8");

                // Start conversation.
                await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true);

                startConversationOk = await client.StartConversationAsync();

                // Search all profiles with type "last".
                requestMessage = mb.CreateProfileSearchRequest("last", null, null, null, 0, 1000, 1000, false, false);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;

                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == expectedLastClients.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 1000;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == expectedLastClients.Count;
                resultsOk = client.CheckProfileListMatchSearchResultItems(expectedLastClients, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.ToList(), false, false, client.GetIdentityId(), false);

                queryOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && resultsOk;

                client.CloseConnection();

                // Step 8 Acceptance
                bool step8Ok = startConversationOk && queryOk;

                log.Trace("Step 8: {0}", step8Ok ? "PASSED" : "FAILED");


                Passed = step1Ok && step2Ok && step3Ok && step4Ok && step5Ok && step6Ok && step7Ok && step8Ok;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            foreach (ProtocolClient protocolClient in TestProfiles.Values)
            {
                protocolClient.Dispose();
            }

            if (profileServer != null)
            {
                profileServer.Shutdown();
            }
            if (locServer != null)
            {
                locServer.Shutdown();
            }

            log.Trace("(-):{0}", res);
            return(res);
        }
Beispiel #11
0
        /// <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 client1 = new ProtocolClient();
            ProtocolClient client2 = new ProtocolClient();

            try
            {
                MessageBuilder mb1 = client1.MessageBuilder;
                MessageBuilder mb2 = client2.MessageBuilder;

                // Step 1
                log.Trace("Step 1");
                await client1.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                bool startConversationOk = await client1.StartConversationAsync();

                Message requestMessage = mb1.CreateRegisterHostingRequest(null);
                await client1.SendMessageAsync(requestMessage);

                Message responseMessage = await client1.ReceiveMessageAsync();

                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.Ok;

                // Step 1 Acceptance
                bool step1Ok = idOk && statusOk;

                log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED");

                client1.CloseConnection();


                // Step 2
                log.Trace("Step 2");
                await client2.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                startConversationOk = await client2.StartConversationAsync();

                requestMessage = mb2.CreateRegisterHostingRequest(null);
                await client2.SendMessageAsync(requestMessage);

                responseMessage = await client2.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.ErrorQuotaExceeded;

                // Step 2 Acceptance
                bool step2Ok = idOk && statusOk;

                log.Trace("Step 2: {0}", step1Ok ? "PASSED" : "FAILED");

                Passed = step1Ok && step2Ok;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            if (client1 != null)
            {
                client1.Dispose();
            }
            if (client2 != null)
            {
                client2.Dispose();
            }

            log.Trace("(-):{0}", res);
            return(res);
        }
Beispiel #12
0
        /// <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[] chal16 = new byte[16];
                Array.Copy(client.Challenge, chal16, chal16.Length);
                Message requestMessage = mb.CreateCheckInRequest(chal16);
                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);
        }
Beispiel #13
0
        /// <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();

                // 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]);
                }


                bool profileInitializationOk = true;

                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);

                            string name = string.Format("{0:00}-{1:00}-{2:00} [{3:US}]", locIndex, idIndex, radIndex, location);
                            ProfileNames.Add(name);

                            ProtocolClient profileClient = new ProtocolClient();

                            await profileClient.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true);

                            bool establishHostingOk = await profileClient.EstablishHostingAsync("test");

                            profileClient.CloseConnection();

                            await profileClient.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClCustomer], true);

                            bool checkInOk = await profileClient.CheckInAsync();

                            bool initializeProfileOk = await profileClient.InitializeProfileAsync(name, null, location, null);

                            profileInitializationOk = establishHostingOk && checkInOk && initializeProfileOk;
                            profileClient.Dispose();

                            if (!profileInitializationOk)
                            {
                                break;
                            }
                        }
                    }
                }


                log.Trace("Generated profile names:");
                for (int i = 0; i < ProfileNames.Count; i++)
                {
                    log.Trace(" {0}", ProfileNames[i]);
                }


                // Step 1 Acceptance
                bool step1Ok = listPortsOk && profileInitializationOk;

                log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED");


                // Step 2
                log.Trace("Step 2");

                // Start conversation.
                await client.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true);

                bool startConversationOk = await client.StartConversationAsync();

                // 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;
                bool 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;

                bool queryRespOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk;
                bool resultsOk   = CompareResults(ProfileNames, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                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;

                        List <string> expectedNames = GetProfileNamesInLocation(targetLocation, radius);
                        totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == expectedNames.Count;
                        maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 1000;
                        profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == expectedNames.Count;

                        queryRespOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk;
                        resultsOk   = CompareResults(expectedNames, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                        queriesOk = queryRespOk && resultsOk;
                        if (!queriesOk)
                        {
                            log.Trace("Search query location {0} with radius {1} should produce {2} profiles, but produced {3} profiles.", targetLocation, radius, expectedNames.Count, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count);
                            log.Trace("Expected names list:");
                            foreach (string name in expectedNames)
                            {
                                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, expectedNames.Count);
                    }

                    if (!queriesOk)
                    {
                        break;
                    }
                }

                // Step 2 Acceptance
                bool step2Ok = startConversationOk && query1Ok && queriesOk;

                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);
        }
Beispiel #14
0
        /// <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
                log.Trace("Step 1");
                await client.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                bool establishHostingOk = await client.EstablishHostingAsync();

                // Step 1 Acceptance
                bool step1Ok = establishHostingOk;
                log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED");

                client.CloseConnection();


                // Step 2
                log.Trace("Step 2");
                await client.ConnectAsync(ServerIp, ClCustomerPort, true);

                bool startConversationOk = await client.StartConversationAsync();

                Message requestMessage = mb.CreateCheckInRequest(client.Challenge);
                // Invalidate the signature.
                byte[] signature = requestMessage.Request.ConversationRequest.Signature.ToByteArray();
                byte[] sig32     = new byte[32];
                Array.Copy(signature, sig32, sig32.Length);
                requestMessage.Request.ConversationRequest.Signature = ProtocolHelper.ByteArrayToByteString(sig32);

                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk      = responseMessage.Id == requestMessage.Id;
                bool statusOk  = responseMessage.Response.Status == Status.ErrorInvalidSignature;
                bool checkInOk = idOk && statusOk;

                // Step 2 Acceptance
                bool step2Ok = startConversationOk && checkInOk;
                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);
        }
Beispiel #15
0
        /// <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 client1 = new ProtocolClient();
            MessageBuilder mb1     = client1.MessageBuilder;

            // Second client will use the same identity as the first client.
            ProtocolClient client2 = new ProtocolClient(0, SemVer.V100, client1.GetIdentityKeys());
            MessageBuilder mb2     = client2.MessageBuilder;

            try
            {
                // Step 1
                await client1.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                bool startConversationOk = await client1.StartConversationAsync();

                Message requestMessage = mb1.CreateVerifyIdentityRequest(client1.Challenge);
                await client1.SendMessageAsync(requestMessage);

                Message responseMessage = await client1.ReceiveMessageAsync();

                bool idOk             = responseMessage.Id == requestMessage.Id;
                bool statusOk         = responseMessage.Response.Status == Status.Ok;
                bool verifyIdentityOk = idOk && statusOk;

                // Step 1 Acceptance
                bool step1Ok = startConversationOk && verifyIdentityOk;



                // Step 2
                await client2.ConnectAsync(ServerIp, ClNonCustomerPort, true);

                startConversationOk = await client2.StartConversationAsync();

                requestMessage = mb2.CreateVerifyIdentityRequest(client2.Challenge);
                await client2.SendMessageAsync(requestMessage);

                responseMessage = await client2.ReceiveMessageAsync();

                idOk             = responseMessage.Id == requestMessage.Id;
                statusOk         = responseMessage.Response.Status == Status.Ok;
                verifyIdentityOk = idOk && statusOk;

                // Step 2 Acceptance
                bool step2Ok = startConversationOk && verifyIdentityOk;



                // Step 3
                byte[] payload = Encoding.UTF8.GetBytes("test");
                requestMessage = mb1.CreatePingRequest(payload);
                await client1.SendMessageAsync(requestMessage);

                responseMessage = await client1.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;

                byte[] payloadReceived = responseMessage.Response.SingleResponse.Ping.Payload.ToByteArray();
                bool   payloadOk       = StructuralComparisons.StructuralComparer.Compare(payload, payloadReceived) == 0;

                // Step 3 Acceptance
                bool step3Ok = idOk && statusOk && payloadOk;


                Passed = step1Ok && step2Ok && step3Ok;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client1.Dispose();
            client2.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }
Beispiel #16
0
        /// <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);
        }
Beispiel #17
0
        /// <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);
        }
Beispiel #18
0
        /// <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();

                ProfilePublicKeys = new List <byte[]>();

                bool profileInitializationOk = true;
                for (int i = 0; i < ProfileNames.Count; i++)
                {
                    ProtocolClient profileClient = new ProtocolClient();
                    ProfilePublicKeys.Add(profileClient.GetIdentityKeys().PublicKey);

                    await profileClient.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true);

                    bool establishHostingOk = await profileClient.EstablishHostingAsync(ProfileTypes[i]);

                    profileClient.CloseConnection();


                    await profileClient.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClCustomer], true);

                    bool checkInOk = await profileClient.CheckInAsync();

                    byte[] imageData = ProfileImages[i] != null?File.ReadAllBytes(ProfileImages[i]) : null;

                    bool initializeProfileOk = await profileClient.InitializeProfileAsync(ProfileNames[i], imageData, ProfileLocations[i], ProfileExtraData[i]);

                    profileInitializationOk = establishHostingOk && checkInOk && initializeProfileOk;
                    profileClient.Dispose();

                    if (!profileInitializationOk)
                    {
                        break;
                    }
                }

                ProtocolClient uninitializedProfileClient = new ProtocolClient();
                await uninitializedProfileClient.ConnectAsync(ServerIp, (int)rolePorts[ServerRoleType.ClNonCustomer], true);

                bool establishHostingUninitializedOk = await uninitializedProfileClient.EstablishHostingAsync("Profile Type B");

                uninitializedProfileClient.CloseConnection();
                uninitializedProfileClient.Dispose();


                bool step1Ok = listPortsOk && profileInitializationOk && establishHostingUninitializedOk;
                log.Trace("Step 1: {0}", step1Ok ? "PASSED" : "FAILED");



                // Step 2
                log.Trace("Step 2");
                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);
                await client.SendMessageAsync(requestMessage);

                Message responseMessage = await client.ReceiveMessageAsync();

                bool idOk     = responseMessage.Id == requestMessage.Id;
                bool statusOk = responseMessage.Response.Status == Status.Ok;


                HashSet <int> numberList = new HashSet <int>()
                {
                    1, 2, 3, 4, 5, 6, 7
                };
                bool totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                bool maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                bool profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                bool profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 2 Acceptance
                bool step2Ok = startConversationOk && idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 2: {0}", step2Ok ? "PASSED" : "FAILED");


                // Step 3
                log.Trace("Step 3");
                requestMessage = mb.CreateProfileSearchRequest("*Type B", null, null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    4, 5
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 3 Acceptance
                bool step3Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 3: {0}", step3Ok ? "PASSED" : "FAILED");


                // Step 4
                log.Trace("Step 4");
                requestMessage = mb.CreateProfileSearchRequest("Profile Type C", null, null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 4 Acceptance
                bool step4Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 4: {0}", step4Ok ? "PASSED" : "FAILED");


                // Step 5
                log.Trace("Step 5");
                requestMessage = mb.CreateProfileSearchRequest(null, "Mumbai *", null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    2, 6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 5 Acceptance
                bool step5Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 5: {0}", step5Ok ? "PASSED" : "FAILED");


                // Step 6
                log.Trace("Step 6");
                requestMessage = mb.CreateProfileSearchRequest(null, "*ai*", null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    1, 2, 4, 5, 6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 6 Acceptance
                bool step6Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 6: {0}", step6Ok ? "PASSED" : "FAILED");


                // Step 7
                log.Trace("Step 7");
                requestMessage = mb.CreateProfileSearchRequest(null, null, null, new GpsLocation(18.961m, 72.82m), 10, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 7 Acceptance
                bool step7Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 7: {0}", step7Ok ? "PASSED" : "FAILED");


                // Step 8
                log.Trace("Step 8");
                requestMessage = mb.CreateProfileSearchRequest(null, null, null, new GpsLocation(18.961m, 72.82m), 5000, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    2, 6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 8 Acceptance
                bool step8Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 8: {0}", step8Ok ? "PASSED" : "FAILED");


                // Step 9
                log.Trace("Step 9");
                requestMessage = mb.CreateProfileSearchRequest(null, null, null, new GpsLocation(-12.345678m, 12.345678m), 5000, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == 0;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == 0;

                // Step 9 Acceptance
                bool step9Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk;


                // Step 10
                log.Trace("Step 10");
                requestMessage = mb.CreateProfileSearchRequest(null, null, "no profiles", null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == 0;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == 0;

                // Step 10 Acceptance
                bool step10Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk;

                log.Trace("Step 10: {0}", step10Ok ? "PASSED" : "FAILED");


                // Step 11
                log.Trace("Step 11");
                requestMessage = mb.CreateProfileSearchRequest(null, null, @"(^|;)t=(|[^=]+,)running([;,]|$)", null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    2, 3, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 11 Acceptance
                bool step11Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 11: {0}", step11Ok ? "PASSED" : "FAILED");


                // Step 12
                log.Trace("Step 12");
                requestMessage = mb.CreateProfileSearchRequest(null, null, @".+", null, 0, 2, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == 5;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 2;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == 2;

                List <IdentityNetworkProfileInformation> setA = new List <IdentityNetworkProfileInformation>(responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                bool firstPartOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk;


                requestMessage = mb.CreateProfileSearchPartRequest(2, 2);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                bool recordIndexOk = responseMessage.Response.ConversationResponse.ProfileSearchPart.RecordIndex == 2;
                bool recordCountOk = responseMessage.Response.ConversationResponse.ProfileSearchPart.RecordCount == 2;
                profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearchPart.Profiles.Count == 2;

                List <IdentityNetworkProfileInformation> setB = new List <IdentityNetworkProfileInformation>(responseMessage.Response.ConversationResponse.ProfileSearchPart.Profiles);

                bool secondPartOk = idOk && statusOk && recordIndexOk && recordCountOk && profilesCountOk;


                requestMessage = mb.CreateProfileSearchPartRequest(4, 1);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                recordIndexOk   = responseMessage.Response.ConversationResponse.ProfileSearchPart.RecordIndex == 4;
                recordCountOk   = responseMessage.Response.ConversationResponse.ProfileSearchPart.RecordCount == 1;
                profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearchPart.Profiles.Count == 1;

                List <IdentityNetworkProfileInformation> setC = new List <IdentityNetworkProfileInformation>(responseMessage.Response.ConversationResponse.ProfileSearchPart.Profiles);

                bool thirdPartOk = idOk && statusOk && recordIndexOk && recordCountOk && profilesCountOk;


                requestMessage = mb.CreateProfileSearchPartRequest(0, 5);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    2, 3, 5, 6, 7
                };
                recordIndexOk   = responseMessage.Response.ConversationResponse.ProfileSearchPart.RecordIndex == 0;
                recordCountOk   = responseMessage.Response.ConversationResponse.ProfileSearchPart.RecordCount == numberList.Count;
                profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearchPart.Profiles.Count == numberList.Count;

                bool fourthPartOk = idOk && statusOk && recordIndexOk && recordCountOk && profilesCountOk;


                List <IdentityNetworkProfileInformation> setAll = new List <IdentityNetworkProfileInformation>(responseMessage.Response.ConversationResponse.ProfileSearchPart.Profiles);
                bool profileListOk1 = CheckProfileList(numberList, setAll);

                List <IdentityNetworkProfileInformation> setParts = new List <IdentityNetworkProfileInformation>(setA);
                setParts.AddRange(setB);
                setParts.AddRange(setC);
                bool profileListOk2 = CheckProfileList(numberList, setParts);


                // Step 12 Acceptance
                bool step12Ok = firstPartOk && secondPartOk && thirdPartOk && fourthPartOk && profileListOk1 && profileListOk2;

                log.Trace("Step 12: {0}", step12Ok ? "PASSED" : "FAILED");



                // Step 13
                log.Trace("Step 13");
                requestMessage = mb.CreateProfileSearchRequest(null, null, @"(^|;)t=(|[^=]+,)running([;,]|$)", null, 0, 2, 2, false, false);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == 2;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 2;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == 2;

                numberList = new HashSet <int>()
                {
                    2
                };
                profileListOk1 = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles, false, true);

                numberList = new HashSet <int>()
                {
                    3
                };
                profileListOk2 = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles, false, true);

                numberList = new HashSet <int>()
                {
                    7
                };
                bool profileListOk3 = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles, false, true);

                profileListOk = (profileListOk1 && profileListOk2 && !profileListOk3) ||
                                (profileListOk1 && !profileListOk2 && profileListOk3) ||
                                (!profileListOk1 && profileListOk2 && profileListOk3);

                // Step 13 Acceptance
                bool step13Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 13: {0}", step13Ok ? "PASSED" : "FAILED");


                // Step 14
                log.Trace("Step 14");
                requestMessage = mb.CreateProfileSearchRequest("profile*", null, null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    1, 2, 3, 4, 5, 6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 14 Acceptance
                bool step14Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 14: {0}", step14Ok ? "PASSED" : "FAILED");


                // Step 15
                log.Trace("Step 15");
                requestMessage = mb.CreateProfileSearchRequest("*file*", null, null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    1, 2, 3, 4, 5, 6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 15 Acceptance
                bool step15Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 15: {0}", step15Ok ? "PASSED" : "FAILED");



                // Step 16
                log.Trace("Step 16");
                requestMessage = mb.CreateProfileSearchRequest("**", null, null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    1, 2, 3, 4, 5, 6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 16 Acceptance
                bool step16Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 16: {0}", step16Ok ? "PASSED" : "FAILED");



                // Step 17
                log.Trace("Step 17");
                requestMessage = mb.CreateProfileSearchRequest("*", null, null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    1, 2, 3, 4, 5, 6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 17 Acceptance
                bool step17Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 17: {0}", step17Ok ? "PASSED" : "FAILED");


                // Step 18
                log.Trace("Step 18");
                requestMessage = mb.CreateProfileSearchRequest(null, "*1", null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    1, 2
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 18 Acceptance
                bool step18Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 18: {0}", step18Ok ? "PASSED" : "FAILED");


                // Step 19
                log.Trace("Step 19");
                requestMessage = mb.CreateProfileSearchRequest(null, "Shanghai 1", null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    1
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 19 Acceptance
                bool step19Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 19: {0}", step19Ok ? "PASSED" : "FAILED");



                // Step 20
                log.Trace("Step 20");
                requestMessage = mb.CreateProfileSearchRequest(null, "**", null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    1, 2, 3, 4, 5, 6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 20 Acceptance
                bool step20Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 20: {0}", step20Ok ? "PASSED" : "FAILED");



                // Step 21
                log.Trace("Step 21");
                requestMessage = mb.CreateProfileSearchRequest(null, "*", null, null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    1, 2, 3, 4, 5, 6, 7
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 21 Acceptance
                bool step21Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 21: {0}", step21Ok ? "PASSED" : "FAILED");


                // Step 22
                log.Trace("Step 22");
                requestMessage = mb.CreateProfileSearchRequest("*Type A", "*ai*", "water", null, 0, 100, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    2
                };
                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == numberList.Count;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 100;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == numberList.Count;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearch.Profiles);

                // Step 22 Acceptance
                bool step22Ok = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk && profileListOk;

                log.Trace("Step 22: {0}", step22Ok ? "PASSED" : "FAILED");



                // Step 23
                log.Trace("Step 23");
                requestMessage = mb.CreateProfileSearchRequest(null, null, @".+", null, 0, 2, 100);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                totalRecordCountOk       = responseMessage.Response.ConversationResponse.ProfileSearch.TotalRecordCount == 5;
                maxResponseRecordCountOk = responseMessage.Response.ConversationResponse.ProfileSearch.MaxResponseRecordCount == 2;
                profilesCountOk          = responseMessage.Response.ConversationResponse.ProfileSearch.Profiles.Count == 2;

                firstPartOk = idOk && statusOk && totalRecordCountOk && maxResponseRecordCountOk && profilesCountOk;

                await Task.Delay(15000);

                requestMessage = mb.CreateProfileSearchPartRequest(8, 2);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.ErrorInvalidValue;
                bool detailsOk = responseMessage.Response.Details == "recordIndex";

                secondPartOk = idOk && statusOk && detailsOk;


                await Task.Delay(15000);

                requestMessage = mb.CreateProfileSearchPartRequest(4, 5);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk      = responseMessage.Id == requestMessage.Id;
                statusOk  = responseMessage.Response.Status == Status.ErrorInvalidValue;
                detailsOk = responseMessage.Response.Details == "recordCount";

                thirdPartOk = idOk && statusOk && detailsOk;



                await Task.Delay(22000);

                requestMessage = mb.CreateProfileSearchPartRequest(0, 500);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk      = responseMessage.Id == requestMessage.Id;
                statusOk  = responseMessage.Response.Status == Status.ErrorInvalidValue;
                detailsOk = responseMessage.Response.Details == "recordCount";

                fourthPartOk = idOk && statusOk && detailsOk;



                requestMessage = mb.CreateProfileSearchPartRequest(0, 5);
                await client.SendMessageAsync(requestMessage);

                responseMessage = await client.ReceiveMessageAsync();

                idOk     = responseMessage.Id == requestMessage.Id;
                statusOk = responseMessage.Response.Status == Status.Ok;


                numberList = new HashSet <int>()
                {
                    2, 3, 5, 6, 7
                };
                recordIndexOk   = responseMessage.Response.ConversationResponse.ProfileSearchPart.RecordIndex == 0;
                recordCountOk   = responseMessage.Response.ConversationResponse.ProfileSearchPart.RecordCount == numberList.Count;
                profilesCountOk = responseMessage.Response.ConversationResponse.ProfileSearchPart.Profiles.Count == numberList.Count;

                bool fifthPartOk = idOk && statusOk && recordIndexOk && recordCountOk && profilesCountOk;

                profileListOk = CheckProfileList(numberList, responseMessage.Response.ConversationResponse.ProfileSearchPart.Profiles);


                // Step 23 Acceptance
                bool step23Ok = firstPartOk && secondPartOk && thirdPartOk && fourthPartOk && fifthPartOk && profileListOk;

                log.Trace("Step 23: {0}", step23Ok ? "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;

                res = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }
            client.Dispose();

            log.Trace("(-):{0}", res);
            return(res);
        }