ServiceClientContext GetValidContext(CancellationToken token)
        {
            var creds = new OpenStackCredential(this.endpoint, "SomeUser", "Password", "SomeTenant", "region-a.geo-1");
            creds.SetAccessTokenId(this.authId);

            return new ServiceClientContext(creds, token, "Nova", endpoint);
        }
        IOpenStackCredential GetValidCreds()
        {
            var authId = "12345";
            var endpoint = "http://teststorageendpoint.com/v1/1234567890";

            var creds = new OpenStackCredential(new Uri(endpoint), "SomeUser", "Password", "SomeTenant");
            creds.SetAccessTokenId(authId);
            return creds;
        }
        public void CannotSetAcessTokenIdWithNullToken()
        {
            var endpoint = new Uri("https://auth.someplace.com/authme");
            var userName = "******";
            var password = "******";
            var tenantId = "12345";

            var cred = new OpenStackCredential(endpoint, userName, password, tenantId);
            cred.SetAccessTokenId(null);
        }
Ejemplo n.º 4
0
        public static async Task<string> EchoMessage(string message, Uri authUri, string userName, string password, string tenantId)
        {
            var credential = new OpenStackCredential(authUri, userName, password, tenantId);
            var client = OpenStackClientFactory.CreateClient(credential);
            
            await client.Connect();

            var echoServiceClient = client.CreateServiceClient<EchoServiceClient>();
            var resp = await echoServiceClient.Echo(message);
            return resp.Message;
        }
        public void CannotSupportVersion1()
        {
            var endpoint = new Uri("https://someidentityendpoint:35357/v1.0/tokens");
            var userName = "******";
            var password = "******";
            var tenantId = "12345";

            var creds = new OpenStackCredential(endpoint, userName, password, tenantId);

            var client = new IdentityServiceClientDefinition();
            
            Assert.IsFalse(client.IsSupported(creds, string.Empty));
        }
        public void CanSetAcessTokenId()
        {
            var endpoint = new Uri("https://auth.someplace.com/authme");
            var userName = "******";
            var password = "******";
            var tenantId = "12345";
            var token = "someToken";

            var cred = new OpenStackCredential(endpoint, userName, password, tenantId);
            cred.SetAccessTokenId(token);

            Assert.AreEqual(token, cred.AccessTokenId);
        }
        IOpenStackCredential GetValidCreds()
        {
            var catalog = new OpenStackServiceCatalog();
            catalog.Add(new OpenStackServiceDefinition("Neutron", "Network Service",
                new List<OpenStackServiceEndpoint>()
                {
                    new OpenStackServiceEndpoint(endpoint, string.Empty, "some version", "some version info", "1,2,3")
                }));

            var creds = new OpenStackCredential(new Uri(this.endpoint), "SomeUser", "Password", "SomeTenant");
            creds.SetAccessTokenId(this.authId);
            creds.SetServiceCatalog(catalog);
            return creds;
        }
        public void CanSetServiceCatalog()
        {
            var endpoint = new Uri("https://auth.someplace.com/authme");
            var userName = "******";
            var password = "******";
            var tenantId = "12345";

            var catalog = new OpenStackServiceCatalog();

            var cred = new OpenStackCredential(endpoint, userName, password, tenantId);
            cred.SetServiceCatalog(catalog);

            Assert.AreEqual(catalog, cred.ServiceCatalog);
        }
        public void CanCreateAnOpenStackCredential()
        {
            var endpoint = new Uri("https://auth.someplace.com/authme");
            var userName = "******";
            var password = "******";
            var tenantId = "12345";

            var cred = new OpenStackCredential(endpoint, userName, password, tenantId);
            
            Assert.IsNotNull(cred);
            Assert.AreEqual(userName, cred.UserName);
            Assert.AreEqual(endpoint, cred.AuthenticationEndpoint);
            Assert.IsNotNull(cred.Password);
            Assert.AreEqual(tenantId, cred.TenantId);
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            //enter your user name, password, tenant Id, and the authorization endpoint
            //for the instance of OpenStack that you want to connect to.
            var authUri = new Uri("https://region.identity.host.com:12345/v2.0/tokens");
            var userName = "******";
            var password = "******";
            var tenantId = "tenant Id"; // e.g. XXXXXXXXXXXXX-Project

            //Construct an OpenStackCredential object that will be used to authenticate.
            //The credential will also be useful later as it contains a reference to the service catalog, and access token.
            var credential = new OpenStackCredential(authUri, userName, password, tenantId);

            //Create a new OpenStackClient object using the credentials you just created.
            var client = OpenStackClientFactory.CreateClient(credential);

            //Connect the client to OpenStack. This will authenticate you, as well as construct the service catalog, 
            //and retrieve the access token that will be used in future calls to OpenStack services.
            var connectTask = client.Connect();

            //Console applications can't do async, so we need to wait on the task, 
            //in other contexts you can use the wait keyword.
            connectTask.Wait();  

            //Once the OpenStackClient has been connected, you can request a service client from it.
            //The service client will be created with the credentials that you have already specified, 
            //and do not need any additional information for you to interact with them.
            var storageClient = client.CreateServiceClient<IStorageServiceClient>();

            //Once we have the storage service client, we can ask it for the details of the current storage account.
            var getAccountTask = storageClient.GetStorageAccount();
            getAccountTask.Wait();
            var account = getAccountTask.Result;

            //Here we will write out the name of the account, and print out the names of each storage container in the account.
            Console.WriteLine("Connected to storage account '{0}'", account.Name);
            Console.WriteLine("Storage account '{0}' has the following containers:", account.Name);
            foreach (var container in account.Containers)
            {
                Console.WriteLine("\t{0}",container.Name);
            }
            Console.WriteLine(string.Empty);
            Console.ReadLine();
        }
        public void CannotCreateAnOpenStackCredentialWithEmptyTenantId()
        {
            var endpoint = new Uri("https://auth.someplace.com/authme");
            var userName = "******";
            var password = "******";

            var cred = new OpenStackCredential(endpoint, userName, password, string.Empty);
        }
        public void CannotCreateAnOpenStackCredentialWithNullPassword()
        {
            var endpoint = new Uri("https://auth.someplace.com/authme");
            var userName = "******";
            var tenantId = "12345";

            var cred = new OpenStackCredential(endpoint, userName, null, tenantId);
        }
        public void CannotCreateAnOpenStackCredentialWithEmptyUserName()
        {
            var endpoint = new Uri("https://auth.someplace.com/authme");
            var password = "******";
            var tenantId = "12345";

            var cred = new OpenStackCredential(endpoint, string.Empty, password, tenantId);
        }
        public void CannotCreateAnOpenStackCredentialWithNullEndpoint()
        {
            var userName = "******";
            var password = "******";
            var tenantId = "12345";

            var cred = new OpenStackCredential(null, userName, password, tenantId);
        }