protected IBaseIdentityService CreateService()
        {
            BaseIdentityClient client;

            switch (Vendor)
            {
            case "HP":
                // currently HP does not have a vendor-specific IBaseIdentityService
                goto default;

            case "Rackspace":
                client = new RackspaceIdentityClient(BaseAddress);
                break;

            case "OpenStack":
            default:
                client = new BaseIdentityClient(BaseAddress);
                break;
            }

            TestProxy.ConfigureService(client, Proxy);
            client.BeforeAsyncWebRequest += TestHelpers.HandleBeforeAsyncWebRequest;
            client.AfterAsyncWebResponse += TestHelpers.HandleAfterAsyncWebResponse;

            return(client);
        }
Esempio n. 2
0
        internal static IIdentityService CreateService(TestCredentials credentials, bool logRequests = true)
        {
            if (credentials == null)
            {
                throw new ArgumentNullException("credentials");
            }

            IdentityClient client;

            switch (credentials.Vendor)
            {
            case "HP":
                // currently HP does not have a vendor-specific IIdentityService
                goto default;

            case "Rackspace":
                client = new RackspaceIdentityClient(credentials.BaseAddress);
                break;

            case "OpenStack":
            default:
                client = new IdentityClient(credentials.BaseAddress);
                break;
            }

            TestProxy.ConfigureService(client, credentials.Proxy);
            if (logRequests)
            {
                client.BeforeAsyncWebRequest += TestHelpers.HandleBeforeAsyncWebRequest;
                client.AfterAsyncWebResponse += TestHelpers.HandleAfterAsyncWebResponse;
            }

            return(client);
        }
Esempio n. 3
0
        protected IIdentityService CreateService(IAuthenticationService authenticationService, bool logRequests = true)
        {
            IdentityClient client;

            switch (Vendor)
            {
            case "HP":
                // currently HP does not have a vendor-specific IIdentityService
                goto default;

            case "Rackspace":
                client = new RackspaceIdentityClient(authenticationService, BaseAddress);
                break;

            case "OpenStack":
            default:
                client = new IdentityClient(authenticationService, BaseAddress);
                break;
            }

            TestProxy.ConfigureService(client, Proxy);
            if (logRequests)
            {
                client.BeforeAsyncWebRequest += TestHelpers.HandleBeforeAsyncWebRequest;
                client.AfterAsyncWebResponse += TestHelpers.HandleAfterAsyncWebResponse;
            }

            return(client);
        }
Esempio n. 4
0
        public static void ConfigureService(ServiceClient service, TestProxy proxy)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            if (proxy != null)
            {
                HttpClientHandler handler = new HttpClientHandler();
                if (proxy.Address != null)
                {
                    handler.Proxy = new WebProxy(proxy.Address);
                }
                else if (!string.IsNullOrEmpty(proxy.Host) && proxy.Port.HasValue)
                {
                    handler.Proxy = new WebProxy(proxy.Host, proxy.Port.Value);
                }
                else
                {
                    throw new InvalidOperationException();
                }

                service.HttpClient = new HttpClient(handler);
            }
        }
Esempio n. 5
0
        public static void ConfigureService(ServiceClient service, TestProxy proxy)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            if (proxy != null)
            {
                HttpClientHandler handler = new HttpClientHandler();
                if (proxy.Address != null)
                    handler.Proxy = new WebProxy(proxy.Address);
                else if (!string.IsNullOrEmpty(proxy.Host) && proxy.Port.HasValue)
                    handler.Proxy = new WebProxy(proxy.Host, proxy.Port.Value);
                else
                    throw new InvalidOperationException();

                service.HttpClient = new HttpClient(handler);
            }
        }