Пример #1
0
        public void HttpService040Test()
        {
            using (var clientChannel = new HttpServiceChannel(new Uri("http://192.168.0.235:5000/api/safevault")))
            {
                clientChannel.CipherLib["rsa-public"]  = RsaCipher.LoadFromPEM($"data\\server\\server.pem");
                clientChannel.CipherLib["rsa-private"] = RsaCipher.LoadFromX509Store("Evgeny Zyuzin SafeVault Client");

                var qm = new QueryMessage {
                    Command = "dbx-Download"
                };
                qm.Params["username"] = "******";
                qm.Params["uuid"]     = "safevault";
                qm.Params["password"] = "******";

                clientChannel.Encrypt();
                clientChannel.WriteObject(qm);
                clientChannel.Post();

                var response = clientChannel.ReadObject <ResponseMessage>();
                Console.WriteLine(response.StatusCode + " " + response.StatusText);
                Assert.AreEqual(200, response.StatusCode);
                Console.WriteLine(response.Header["data"]);

                var data = clientChannel.Read();
                Assert.AreEqual(response.Header["md5"], Security.Hash.MD5(data));
                Console.WriteLine(data.Length);
            }
        }
Пример #2
0
        public void HttpService050Test()
        {
            using (var clientChannel = new HttpServiceChannel(new Uri("http://192.168.0.235:5000/api/safevault")))
            {
                clientChannel.CipherLib["rsa-public"]  = RsaCipher.LoadFromPEM($"data\\server\\server.pem");
                clientChannel.CipherLib["rsa-private"] = RsaCipher.LoadFromPEM($"data\\client\\test-user\\cer.pem", $"data\\client\\test-user\\cer.pem.key");

                var dbxData = Random.Get(3838);

                var qm = new QueryMessage {
                    Command = "dbx-Upload"
                };
                qm.Params["username"]      = "******";
                qm.Params["uuid"]          = "safevault";
                qm.Params["password"]      = "******";
                qm.Params["md5"]           = Security.Hash.MD5(dbxData);
                qm.Params["last-modified"] = "2017-01-01 12:00:00Z";

                clientChannel.Encrypt();
                clientChannel.WriteObject(qm);
                clientChannel.Write(dbxData);
                clientChannel.Post();

                var response = clientChannel.ReadObject <ResponseMessage>();
                Console.WriteLine(response.StatusCode + " " + response.StatusText);
                Assert.AreEqual(200, response.StatusCode);
                Console.WriteLine(response.Header["data"]);
            }
        }
Пример #3
0
        public void HttpService020Test()
        {
            using (var clientChannel = new HttpServiceChannel(new Uri("http://192.168.0.235:5000/api/safevault")))
            {
                clientChannel.CipherLib["rsa-public"]  = RsaCipher.LoadFromPEM("data\\server\\server.pem");
                clientChannel.CipherLib["rsa-private"] = RsaCipher.LoadFromPEM("data\\client\\test-user\\cer.pem", "data\\client\\test-user\\cer.pem.key");

                var queryMessage = new QueryMessage();
                queryMessage.Command = "ping";

                clientChannel.Encrypt();
                clientChannel.WriteObject(queryMessage);
                clientChannel.Post();

                var response = clientChannel.ReadObject <ResponseMessage>();
                Console.WriteLine(response.StatusCode);
                Console.WriteLine(response.StatusText);
                Console.WriteLine(response.Header["data"]);

                Assert.AreEqual(200, response.StatusCode);
                //Console.WriteLine(response.Header["data"]);
            }
        }