Exemplo n.º 1
0
        public async Task Api_1_Test()
        {
            var locator = new WebApiLocator(); // {ServiceDomain = "dev-test.rnd.ipzo.net"};

            Console.WriteLine("Testing in {0}", locator.ServiceDomain);

            WebApiService svc = await locator.Locate("api1");

            Assert.IsNotNull(svc);

            svc.Decryptor.KeyPhrase = "dev";

            Uri[] uriArray = svc.Uris.ToArray();
            Assert.IsTrue(uriArray.Length > 0);

            foreach (Uri u in uriArray)
            {
                Console.WriteLine(u.ToString());
            }

            Assert.AreEqual(
                "https://[email protected]/api",
                uriArray[0].ToString()
                );

            Assert.IsTrue(svc.Headers.Count > 0);
            Assert.AreEqual("Banana", svc.Headers["X-Custom-Header"]);
        }
Exemplo n.º 2
0
        public async Task Public_Web_Test()
        {
            var locator = new WebApiLocator();

            Console.WriteLine("Testing in {0}", locator.ServiceDomain);

            WebApiService svc = await locator.Locate("@dialer-ivr-pub".Substring(1));

            Assert.IsNotNull(svc);

            Uri[] uriArray = svc.Uris.ToArray();
            Assert.IsTrue(uriArray.Length == 1);

            foreach (Uri u in uriArray)
            {
                Console.WriteLine(u.ToString());
            }
        }
Exemplo n.º 3
0
        public async Task Api_RR_Test()
        {
            var locator = new WebApiLocator(); // {ServiceDomain = "dev-test.rnd.ipzo.net"};

            Console.WriteLine("Testing in {0}", locator.ServiceDomain);

            WebApiService svc = await locator.Locate("rr-api");

            Assert.IsNotNull(svc);

            Uri[] uriArray = svc.Uris.ToArray();
            Assert.IsTrue(uriArray.Length == 3);

            foreach (Uri u in uriArray)
            {
                Console.WriteLine(u.ToString());
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: ue.exe <grpc|http|sql|mongodb|dns|tcp|udp> <service-idenitifier> [dns-type]");
                Console.WriteLine("       OR");
                Console.WriteLine("       ue.exe <enc|dec> <string> [pepper]");
                return;
            }

            try
            {
                Console.WriteLine("Service Domain = '{0}'", _generic.ServiceDomain);

                switch (args[0].ToLowerInvariant())
                {
                case "enc":
                case "dec":
                    var aes = new AesCrypto();
                    if (args.Length > 2)
                    {
                        aes.KeyPhrase = args[2];
                    }
                    Console.WriteLine("Pepper = '{0}'", aes.KeyPhrase);
                    if (args[0].ToLowerInvariant() == "enc")
                    {
                        Console.WriteLine("\nEncrypted = \"{aes:" + aes.Encrypt(args[1]) + "}\"");
                    }
                    else
                    {
                        string cipherText = args[1].Replace("{aes:", "").Replace("}", "");
                        Console.WriteLine("\nDecrypted = \"" + aes.Decrypt(cipherText) + "\"");
                    }

                    break;

                case "dns":
                    if (Enum.TryParse(args[2], out DnsRecordType recordType))
                    {
                        var        query   = new DnsQuery(args[1], recordType);
                        DnsEntry[] records = query.Resolve().Result;

                        foreach (DnsEntry rec in query.AllRecords)
                        {
                            Console.WriteLine($"({rec.Type}) {rec}");
                        }
                    }
                    break;

                case "grpc":
                    var g = _grpc.Locate(args[1]).Result;
                    foreach (GrpcEndpoint ep in g.Endpoints)
                    {
                        Console.WriteLine(ep.ToString());
                    }
                    break;

                case "http":
                    var w = _webapi.Locate(args[1]).Result;
                    foreach (Uri u in w.Uris)
                    {
                        Console.WriteLine(u.ToString());
                    }
                    break;

                case "sql":
                    var sql = _database.Locate(args[1], DatabaseProtocol.Sql).Result;
                    foreach (string sqlConnectionString in sql.ConnectionStrings)
                    {
                        Console.WriteLine(sqlConnectionString);
                    }
                    break;

                case "mongodb":
                    var mongo = _database.Locate(args[1], DatabaseProtocol.MongoDb).Result;
                    foreach (string mConnectionString in mongo.ConnectionStrings)
                    {
                        Console.WriteLine(mConnectionString);
                    }
                    break;

                case "tcp":
                    var tcp = _generic.Locate(args[1], IpProtocol.TCP).Result;
                    foreach (ServiceEndpoint ep in tcp.Endpoints)
                    {
                        Console.WriteLine(ep.ToString());
                    }
                    break;

                case "udp":
                    var udp = _generic.Locate(args[1], IpProtocol.UDP).Result;
                    foreach (ServiceEndpoint ep in udp.Endpoints)
                    {
                        Console.WriteLine(ep.ToString());
                    }
                    break;

                case "long-test":
                    LongTest.RunTest(args[1]);
                    break;
                }
            }
            catch (Exception ex)
            {
                BreakdownExcception(ex);
            }
        }