示例#1
0
        /// <summary>
        /// Send a poison pill to the given ringmaster affecting the given path.
        /// </summary>
        /// <param name="ringMaster">Ring master to which the poison pill must be sent</param>
        /// <param name="path">Path affected by the poison pill</param>
        /// <returns>A Task that tracks execution of this method</returns>
        private static async Task SendPoisonPillCommand(RingMasterClient ringMaster, string path)
        {
            await ringMaster.SetAuth(new Id(AuthSchemes.Digest, "commander"));

            string poisonPillCommand = string.Format("break:{0}", path);

            byte[] data = Encoding.UTF8.GetBytes(poisonPillCommand);
            await ringMaster.Create("$/poisonpill", data, null, CreateMode.Persistent);
        }
示例#2
0
        public void TestSetAuth()
        {
            using (var requestHandler = new TestRequestHandler())
                using (var client = new RingMasterClient(requestHandler))
                {
                    string path = this.GetRandomString();
                    var    id   = new Id(AuthSchemes.Digest, this.GetRandomString());

                    requestHandler.Implementation = request =>
                    {
                        Assert.IsTrue(request is RequestSetAuth);
                        var setAuthRequest = (RequestSetAuth)request;
                        Assert.AreEqual($"digest:{id.Identifier}", setAuthRequest.ClientId);

                        return(new RequestResponse()
                        {
                            ResultCode = (int)RingMasterException.Code.Ok
                        });
                    };

                    client.SetAuth(id).Wait();
                }
        }