public void Should_fail_on_wrong_token()
        {
            tokenSource         = new CancellationTokenSource();
            swiftConnectionData = KeystoneData.GetKeystoneToken();

            //Uri endpoint, string token, string tenant
            swiftclient = new Swift(swiftConnectionData.Item1, "$$wrong_token", KeystoneData.keystoneTenant);

            Assert.Throws(typeof(AggregateException), () =>
            {
                var tsk = swiftclient.GetAccountDetails(tokenSource.Token);
                tsk.Wait();
            });

            try
            {
                var tsk = swiftclient.GetAccountDetails(tokenSource.Token);
                tsk.Wait();
            }
            catch (AggregateException exp_agr)
            {
                AggregateException exp2 = exp_agr.Flatten();

                //
                // Find System.UnauthorizedAccessException in inner exceptions
                bool found = false;

                foreach (var exp in exp2.InnerExceptions)
                {
                    if (exp.GetType().Equals(typeof(System.UnauthorizedAccessException)))
                    {
                        found = true;
                    }
                }

                Assert.True(found);
            }
        }
        public void Work_normally()
        {
            swiftConnectionData = KeystoneData.GetKeystoneToken();
            tokenSource         = new CancellationTokenSource();

            swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant);

            AccountDetails accountDetails = null;

            Assert.DoesNotThrow(() => {
                var tsk        = swiftclient.GetAccountDetails(tokenSource.Token);
                accountDetails = tsk.Result;
                Assert.NotNull(accountDetails);
            });
        }
        public void Should_throw_on_wrong_endpoint()
        {
            tokenSource         = new CancellationTokenSource();
            swiftConnectionData = GetKeystoneToken();

            //Uri endpoint, string token, string tenant
            Uri wrongUri = new Uri("http://1.1.1.1");

            swiftclient = new Swift(wrongUri, swiftConnectionData.Item2, KeystoneData.keystoneTenant);

            Assert.Throws(typeof(AggregateException), () => {
                var tsk = swiftclient.GetAccountDetails(tokenSource.Token);
                tsk.Wait();
            });
        }
示例#4
0
        public void TestConnection(string token, Uri swiftEndpoint)
        {
            swiftclient = new Swift(swiftEndpoint, token, realTenant);

            if (swiftEndpoint != null)
            {
                Assert.DoesNotThrow(() =>
                {
                    var tsk = swiftclient.GetAccountDetails(tokenSource.Token);
                    AccountDetails accountDetails = tsk.Result;
                    System.Diagnostics.Trace.WriteLine("Result is: " + accountDetails.BytesUsed);
                });
            }
            else
            {
                Assert.Throws(typeof(System.AggregateException), () => {
                    //var tsk = provider.GetAccountData(swiftEndpoint, username, password, tokenSource.Token);
                    //var rawData = tsk.Result;

                    //System.Diagnostics.Trace.WriteLine("Result is: " + rawData);
                });
            }
        }
示例#5
0
        public void TestConnection(string token, Uri swiftEndpoint)
        {
            swiftclient = new Swift(swiftEndpoint, token, realTenant);

            if (swiftEndpoint != null)
            {
                Assert.DoesNotThrow(() =>
                {
                    var tsk = swiftclient.GetAccountDetails(tokenSource.Token);
                    AccountDetails accountDetails = tsk.Result;
                    System.Diagnostics.Trace.WriteLine("Result is: " + accountDetails.BytesUsed);
                });
            }
            else
            {
                Assert.Throws(typeof(System.AggregateException), () => {
                    //var tsk = provider.GetAccountData(swiftEndpoint, username, password, tokenSource.Token);
                    //var rawData = tsk.Result;

                    //System.Diagnostics.Trace.WriteLine("Result is: " + rawData);
                });
            }
            
        }