Beispiel #1
0
        public void Should_rebuild_OktaClient()
        {
            var client = new OktaClient(new Uri("https://isobar.okta.com"), "dentsuaegis")
            {
                ServiceCredential = "DARWIN.OKTA.local",
            };
            var orgArgs = client.GetClientArgs();
            var args    = JsonSerializer.Deserialize <Args>(JsonSerializer.Serialize(orgArgs, Default.JsonOptions));

            Check.That(args.Count > 0).IsTrue();
            var newClient = AutomaClient.Parse(args);

            Check.That(newClient).IsNotNull();
        }
            /// <summary>
            /// Executes the asynchronous.
            /// </summary>
            /// <param name="client">The client.</param>
            /// <param name="param">The parameter.</param>
            /// <param name="tag">The tag.</param>
            /// <returns></returns>
            public Task <object> ExecuteAsync(AutomaClient client, object param = null, object tag = null, CancellationToken?cancellationToken = null)
            {
                var p            = param as Param;
                var sourceFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).Replace("Documents", "Downloads");
                var filePath     = Path.Combine(sourceFolder, "TransactionReport.xls");

                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                var driver = client.GetWebDriver();

                driver.Navigate().GoToUrl($"{(client as UmbClient).UmbUri}/Reports/report2_1010c.asp");
                try
                {
                    driver.FindElement(By.Name("xs_bi")).SendKeys($"[All Account Issuers]{Keys.Enter}"); // Statement Issuer
                    driver.FindElement(By.Name("xs_pi")).SendKeys(Keys.Enter);                           // Statement Period
                    driver.FindElement(By.Name("xs_l_ct")).SendKeys($"[All Types]{Keys.Enter}");         // Account Type
                    if (p.BeginDate != null)
                    {
                        driver.FindElement(By.Name("xs_start")).SendKeys(p.BeginDate.Value.ToShortDateString());                      // Start Date
                    }
                    if (p.EndDate != null)
                    {
                        driver.FindElement(By.Name("xs_end")).SendKeys(p.EndDate.Value.ToShortDateString()); // End Date
                    }
                    ElementSelect(driver.FindElement(By.Name("xs_umt")), true);                              // Include Unmapped Transactions
                    ElementSelect(driver.FindElement(By.Name("xs_m_f")), false);                             // Group Results
                    ElementSelect(driver.FindElement(By.Id("xs_m_s_4")), true);                              // Transaction List

                    // additional fields
                    var additionalFields = driver.FindElements(By.ClassName("accordion")).First(x => x.Text == "Additional Fields");
                    additionalFields.Click(); Thread.Sleep(500);                              // Additional Fields
                    ElementSelect(driver.FindElement(By.Id("i91")), true); Thread.Sleep(500); // Issuer Reference
                    driver.FindElement(By.ClassName("two")).Click(); Thread.Sleep(500);       // page 2
                    ElementSelect(driver.FindElement(By.Id("i85")), true); Thread.Sleep(500); // Authorization Number

                    // submit
                    driver.FindElement(By.Name("xs_filename")).SendKeys("TransactionReport");  // Export File Name
                    driver.FindElement(By.Name("xs_filetype")).SendKeys($"Excel{Keys.Enter}"); // Export File Type
                    driver.FindElement(By.ClassName("search")).Click();
                }
                catch { return(Task.FromResult <object>(false)); }
                var i = 0; while (!File.Exists(filePath) && i++ < 10)

                {
                    Thread.Sleep(500);
                }
                return(Task.FromResult <object>(File.Exists(filePath)));
            }
Beispiel #3
0
        public void Should_rebuild_UnanetClient()
        {
            var client = new UnanetClient(new RoundarchUnanetOptions())
            {
                DriverType        = typeof(ChromeDriver),
                ServiceCredential = "DARWIN.UNANET.local",
            };
            var orgArgs = client.GetClientArgs();
            var args    = JsonSerializer.Deserialize <Args>(JsonSerializer.Serialize(orgArgs, Default.JsonOptions));

            Check.That(args.Count > 0).IsTrue();
            var newClient = AutomaClient.Parse(args);

            Check.That(newClient).IsNotNull();
        }
Beispiel #4
0
        public void Should_rebuild_GoogleAdwordsClient()
        {
            var client = new GoogleAdwordsClient()
            {
                ServiceCredential = "DARWIN.GoogleAdwords.local",
                AppId             = "",
                AppSecret         = "",
                DeveloperToken    = "",
            };
            var orgArgs = client.GetClientArgs();
            var args    = JsonSerializer.Deserialize <Args>(JsonSerializer.Serialize(orgArgs, Default.JsonOptions));

            Check.That(args.Count > 0).IsTrue();
            var newClient = AutomaClient.Parse(args);

            Check.That(newClient).IsNotNull();
        }
Beispiel #5
0
        public void Should_rebuild_FacebookClient()
        {
            var client = new FacebookClient()
            {
                ServiceCredential = "DEGSVC.Facebook.local",
                RequestedScope    = "manage_pages,ads_management",
                AppId             = "",
                AppSecret         = "",
                ClientToken       = "",
            };
            var orgArgs = client.GetClientArgs();
            var args    = JsonSerializer.Deserialize <Args>(JsonSerializer.Serialize(orgArgs, Default.JsonOptions));

            Check.That(args.Count > 0).IsTrue();
            var newClient = AutomaClient.Parse(args);

            Check.That(newClient).IsNotNull();
        }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GoogleAdwordsAutomation" /> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="automa">The automa.</param>
 public GoogleAdwordsAutomation(AutomaClient client, IAutoma automa) : base(client, automa)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkdayAutomation"/> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="automa">The automa.</param>
 public WorkdayAutomation(AutomaClient client, IAutoma automa) : base(client, automa)
 {
 }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnanetAutomation" /> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="automa">The automa.</param>
 /// <param name="options">The options.</param>
 public UnanetAutomation(AutomaClient client, IAutoma automa, IUnanetOptions options) : base(client, automa) => _options = options;
 /// <summary>
 /// Initializes a new instance of the <see cref="FacebookAutomation" /> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="automa">The automa.</param>
 public FacebookAutomation(AutomaClient client, IAutoma automa) : base(client, automa)
 {
 }
Beispiel #10
0
        /// <summary>
        /// Opens the asynchronous.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="bearerTokenPredicate">The bearer token predicate.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        /// <exception cref="Exception">Invalid Bearer Token</exception>
        /// <exception cref="ArgumentOutOfRangeException">method</exception>
        public async Task OpenAsync(HttpContext context, ILogger logger, Func <string, bool> bearerTokenPredicate = null, CancellationToken?cancellationToken = null)
        {
            var correlation = Guid.NewGuid();
            var webSockets  = context.WebSockets;

            if (!webSockets.IsWebSocketRequest)
            {
                context.Response.StatusCode = 405;
                return;
            }
            context.Response.StatusCode = 101;
            var ws = await _socket.AcceptAsync(webSockets).ConfigureAwait(false);

            AutomaClient client = null;

            try
            {
                var bearerToken = await ws.ReceiveAsync <string>(cancellationToken).ConfigureAwait(false);

                if (!bearerTokenPredicate?.Invoke(bearerToken) ?? true)
                {
                    throw new Exception("Invalid Bearer Token");
                }
                var opened = true;
                while (opened && !context.RequestAborted.IsCancellationRequested)
                {
                    var method = await ws.ReceiveAsync <ProxyMethod>(cancellationToken).ConfigureAwait(false);

                    switch (method)
                    {
                    case ProxyMethod.Open:
                    {
                        var args = await ws.ReceiveObjectAsync <Args>(cancellationToken).ConfigureAwait(false);

                        logger?.LogInformation($"[{correlation}] Open: {((JsonElement)args["_base"]).GetProperty("Type").GetString()}");
                        client = AutomaClient.Parse(args);
                        break;
                    }

                    case ProxyMethod.Custom:
                    {
                        var registration = await ws.ReceiveAsync <Type>(cancellationToken).ConfigureAwait(false);

                        var param = await ws.ReceiveTypedAsync(cancellationToken).ConfigureAwait(false);

                        var tag = await ws.ReceiveTypedAsync(cancellationToken).ConfigureAwait(false);

                        logger?.LogInformation($"[{correlation}] Custom: {registration?.Name}");
                        var(obj, custom) = await client.Automa.CustomAsync(registration, param, tag).ConfigureAwait(false);

                        await ws.SendBarrier(false, cancellationToken).ConfigureAwait(false);

                        if (custom is ICustomWithTransfer customWithTransfer)
                        {
                            await customWithTransfer.SendAsync(ws, param).ConfigureAwait(false);

                            await ws.SendBarrier(false, cancellationToken).ConfigureAwait(false);
                        }
                        await ws.SendTypedAsync(obj, cancellationToken).ConfigureAwait(false);

                        break;
                    }

                    case ProxyMethod.Login:
                    {
                        var credential = await ws.ReceiveObjectAsync <NetworkCredential>(cancellationToken).ConfigureAwait(false);

                        client.ServiceLogin    = credential.UserName;
                        client.ServicePassword = credential.Password;
                        var tag = await ws.ReceiveTypedAsync(cancellationToken).ConfigureAwait(false);

                        logger?.LogInformation($"[{correlation}] Login: {client.ServiceLogin}");
                        await client.Automa.LoginAsync(tag).ConfigureAwait(false);

                        break;
                    }

                    case ProxyMethod.SelectApplication:
                    {
                        var application = await ws.ReceiveAsync <string>(cancellationToken).ConfigureAwait(false);

                        var tag = await ws.ReceiveTypedAsync(cancellationToken).ConfigureAwait(false);

                        logger?.LogInformation($"[{correlation}] SelectApplication: {application}");
                        var obj = await client.Automa.SelectApplicationAsync(application, tag).ConfigureAwait(false);

                        await ws.SendBarrier(false, cancellationToken).ConfigureAwait(false);

                        await ws.SendTypedAsync(obj, cancellationToken).ConfigureAwait(false);

                        break;
                    }

                    case ProxyMethod.SetDeviceAccessToken:
                    {
                        var url = await ws.ReceiveAsync <string>(cancellationToken).ConfigureAwait(false);

                        var code = await ws.ReceiveAsync <string>(cancellationToken).ConfigureAwait(false);

                        var tag = await ws.ReceiveTypedAsync(cancellationToken).ConfigureAwait(false);

                        logger?.LogInformation($"[{correlation}] SetDeviceAccessTokenAsync: {url}, {code}");
                        await client.Automa.SetDeviceAccessTokenAsync(url, code, tag).ConfigureAwait(false);

                        break;
                    }

                    case ProxyMethod.GetCookies:
                    {
                        logger?.LogInformation($"[{correlation}] GetCookies");
                        await ws.SendBarrier(false, cancellationToken).ConfigureAwait(false);

                        await ws.SendObjectAsync(client.Automa.Cookies, cancellationToken).ConfigureAwait(false);

                        break;
                    }

                    case ProxyMethod.Dispose:
                    {
                        logger?.LogInformation($"[{correlation}] Dispose");
                        opened = false;
                        break;
                    }

                    default: throw new ArgumentOutOfRangeException(nameof(method), method.ToString());
                    }
                    await ws.SendBarrier(true, cancellationToken).ConfigureAwait(false);
                }
            }
            catch (Exception e)
            {
                logger?.LogCritical(e, $"{correlation}>Exception");
                await ws.SendExceptionAsync(e, cancellationToken);
            }
            finally
            {
                client?.Dispose();
            }
            logger?.LogInformation($"[{correlation}] Done");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProxyAutomation"/> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="automa">The automa.</param>
 public ProxyAutomation(AutomaClient client, IAutoma automa) : base(client, automa) => _proxyDriver = (ProxyDriver)automa.Driver;
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OktaAutomation" /> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="automa">The automa.</param>
 /// <param name="oktaUri">The okta URI.</param>
 public OktaAutomation(AutomaClient client, IAutoma automa, Uri oktaUri) : base(client, automa) => _oktaUri = oktaUri;
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AdpAutomation" /> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="automa">The automa.</param>
 public AdpAutomation(AutomaClient client, IAutoma automa) : base(client, automa)
 {
 }