static void Main(string[] args)
 {
     ClientAuthentication.baseWebAddress = "http://*****:*****@itsligo.ie", "LBowles$1"))
     {
         Console.WriteLine("Successful login Token acquired {0} user status is {1}", ClientAuthentication.AuthToken, ClientAuthentication.AuthStatus.ToString());
         try
         {
             AccountUserViewModel acuvm = ClientAuthentication.getItem <AccountUserViewModel>("api/AccountManager/getAccounts");
             if (acuvm != null)
             {
                 Console.WriteLine("Got {0} accounts for current logged in user {1}", acuvm.accounts.Count(), acuvm.AccountManagerName);
                 // Get account list using current UserID
                 List <Account> accounts = ClientAuthentication.getList <Account>("api/AccountManager/getAccountsForCurrentManager/" + acuvm.AccountManagerID);
                 foreach (var item in accounts)
                 {
                     Console.WriteLine("Account Name {0}", item.AccountName);
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error {0} --> {1}", ex.Message, ex.InnerException.Message);
         }
         Console.ReadKey();
     }
 }
예제 #2
0
        public void Ctor_PartialSuccessLimit_MaxValue()
        {
            const int partialSuccessLimit = int.MaxValue;

            var clientAuthentication = new ClientAuthentication(partialSuccessLimit);

            Assert.AreEqual(partialSuccessLimit, clientAuthentication.PartialSuccessLimit);
        }
예제 #3
0
 static void Main(string[] args)
 {
     ClientAuthentication.baseWebAddress = "http://*****:*****@itsligo.ie", "LBowles$1"))
     {
         Console.WriteLine("Successful login Token acquired {0} user status is {1}", ClientAuthentication.AuthToken, ClientAuthentication.AuthStatus.ToString());
     }
     Console.ReadKey();
 }
예제 #4
0
        public BAuthentication getAuthentication()
        {
            BAuthentication auth = getTransport().authentication;

            if (auth != null)
            {
                ClientAuthentication clientAuth = (ClientAuthentication)auth;
                auth = clientAuth.innerAuth;
            }
            return(auth);
        }
예제 #5
0
        public void TestRateLimitInitalization()
        {
            var settings = VariousFunctions.LoadTestSettings();

            // Create a new Client Authentication based off of the ClientId
            var clientAuthentication = new ClientAuthentication(settings.ClientId, true);

            // Validate rate limit data is correct
            Assert.IsTrue(clientAuthentication.RateLimit.ClientLimit > 0);
            Assert.IsTrue(clientAuthentication.RateLimit.UserLimit > 0);
        }
예제 #6
0
        static void Main(string[] args)
        {
            ClientAuthentication.baseWebAddress = "http://*****:*****@itsligo.ie", "LBowles$1"))
            {
                Console.WriteLine("Successful login Token acquired {0} user status is {1}", ClientAuthentication.AuthToken, ClientAuthentication.AuthStatus.ToString());
                try
                {
                    OrderViewModel acuvm = ClientAuthentication.getItem <OrderViewModel>("api/OrderManager/getOrders");
                    if (acuvm != null)
                    {
                        Console.WriteLine("Got {0} orders for current logged in user {1}", acuvm.orders.Count(), acuvm.CustomerName);
                        // Get account list using current UserID
                        List <Order> orders = ClientAuthentication.getList <Order>("api/OrderManager/getOrdersForCurrentCustomer/" + acuvm.OrderedBy);
                        foreach (var item in orders)
                        {
                            Console.WriteLine("Order ID {0}", item.OrderID);

                            OrderDetailViewModel odvm = ClientAuthentication.getItem <OrderDetailViewModel>("api/OrderManager/getOrderDetailsForOrder/" + item.OrderID);

                            Console.WriteLine("Got {0} order details for order with id {1}", odvm.details.Count(), item.OrderID);
                            Console.WriteLine("Order placed by: {0}", odvm.CustomerName);
                            foreach (var oDetail in odvm.details)
                            {
                                Console.WriteLine("Order ID: {0}, Order Detail ID: {1}, Product Ordered: {2}, Quantity Ordered: {3}", oDetail.OrderID, oDetail.OrderDetailID, oDetail.ProductOdered, oDetail.Qauntity);
                            }
                        }
                    }

                    Console.ReadKey();
                    Console.Clear();
                    Order newOrder = new Order();
                    Console.WriteLine("Enter total: ");
                    newOrder.Total = double.Parse(Console.ReadLine());

                    bool created = ClientAuthentication.PostItem <Order>(newOrder, "api/OrderManager/createOrder");

                    if (created == true)
                    {
                        Console.WriteLine("Created Order!");
                    }
                    else
                    {
                        Console.WriteLine("Something went wrong!");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error {0} --> {1}", ex.Message, ex.InnerException.Message);
                }
                Console.ReadKey();
            }
        }
        protected override void OnInit()
        {
            base.OnInit();

            // Arrange
            CreateMocks();
            SetupMocks();
            ClientAuthentication = new ClientAuthentication();

            // Act
            Act();
        }
예제 #8
0
        protected override void OnInit()
        {
            base.OnInit();

            // Arrange
            CreateMocks();
            SetupMocks();
            ClientAuthentication = new ClientAuthentication();

            // Act
            Act();
        }
 protected override void Act()
 {
     try
     {
         ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
         Assert.Fail();
     }
     catch (SshAuthenticationException ex)
     {
         _actualException = ex;
     }
 }
예제 #10
0
        public void TestBasicInfo()
        {
            // Create random ClientId
            var clientId = String.Format("Example-clientid-{0}", new Random().Next(0xbeef, 0xdead));

            // Create a new Client Authentication based off of the ClientId
            var clientAuthentication = new ClientAuthentication(clientId, false);

            // Validate data is correct
            Assert.IsNotNull(clientAuthentication);
            Assert.AreEqual(clientAuthentication.ClientId, clientId);
            Assert.AreEqual(clientAuthentication.AuthenticationType, AuthenticationType.ClientId);
        }
예제 #11
0
 static void Main(string[] args)
 {
     ClientAuthentication.baseWebAddress = "http://*****:*****@itsligo.ie", "LBowles$1"))
     {
         Console.WriteLine("Successful login Token acquired {0} user status is {1}", ClientAuthentication.AuthToken, ClientAuthentication.AuthStatus.ToString());
         try
         {
             OrdersViewModel orders = ClientAuthentication.getItem <OrdersViewModel>("api/Orders/GetOrdersByUserID/" + "0ad55e42-0b7e-4ee4-af6b-ddd527fa0144");
             foreach (Orders item in orders.Orders)
             {
                 Console.WriteLine("OrderDate {0}", item.OrderDate);
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error {0} --> {1}", ex.Message, ex.InnerException.Message);
         }
         Console.ReadKey();
     }
 }
예제 #12
0
 private void Awake()
 {
     clientAuthentication = (ClientAuthentication)clientAuthenticationRef.Data;
     Assert.IsNotNull(clientAuthentication);
 }
예제 #13
0
        protected override void Arrange()
        {
            base.Arrange();

            _clientAuthentication = new ClientAuthentication(_partialSuccessLimit);
        }
예제 #14
0
 public void Init()
 {
     _clientAuthentication = new ClientAuthentication();
 }
        private async Task GetTokensUsingRefreshToken(ClientAuthentication authentication)
        {
            var parameters = new Dictionary <string, string>()
            {
                { "grant_type", "refresh_token" },
                { "code", authentication.RefreshToken },
                { "client_id", authentication.AppApiKey }
            };
            var uri = UriHelper.Create(_settings.BaseUri, _settings.TokenUri);

            var client  = new HttpClient();
            var content = new FormUrlEncodedContent(parameters);

            HttpResponseMessage response;

            try
            {
                response = await client.PostAsync(uri, content);
            }
            catch (Exception ex)
            {
                var exception = new HqvException($"{MethodBase.GetCurrentMethod().Name} failed.", ex);
                exception.Data["uri"]             = uri;
                exception.Data["request-content"] = await content.ReadAsStringAsync();

                throw exception;
            }

            if (!response.IsSuccessStatusCode)
            {
                var exception =
                    new HqvException($"{MethodBase.GetCurrentMethod().Name} failed with error code {response.StatusCode}");
                exception.Data["uri"]             = uri;
                exception.Data["request-content"] = await content.ReadAsStringAsync();

                exception.Data["response-content"] = await response.Content.ReadAsStringAsync();

                throw exception;
            }

            try
            {
                var responseContent = await response.Content.ReadAsStringAsync();

                dynamic json             = JsonConvert.DeserializeObject(responseContent);
                var     expiresInSeconds = (int)json.expires_in - _settings.AccessTokenExpirationFuzzyInSeconds;
                authentication.SetAccessToken((string)json.access_token,
                                              DateTime.Now.AddSeconds(expiresInSeconds).ToUniversalTime());
                authentication.SetRefreshToken((string)json.refresh_token,
                                               DateTime.Now.AddYears(1).AddMonths(-_settings.RefreshTokenExpirationFuzzyInMonths).ToUniversalTime());
            }
            catch (Exception ex)
            {
                var exception = new HqvException($"Unable to parse result from Ecobee for {MethodBase.GetCurrentMethod().Name}", ex);
                exception.Data["uri"]             = uri;
                exception.Data["request-content"] = await content.ReadAsStringAsync();

                exception.Data["response-content"] = await response.Content.ReadAsStringAsync();

                throw exception;
            }
        }
 public AuthenticationMessageHandler(ClientAuthentication clientAuthentication)
 {
     _clientAuthentication = clientAuthentication;
 }
 protected override void Act()
 {
     ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
 }
예제 #18
0
 public void Init()
 {
     _clientAuthentication = new ClientAuthentication();
 }