Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Keystone_XUnit"/> class.
        /// xUnit test start-up code
        /// </summary>
        public Keystone_XUnit()
        {
            keystone = new KeystoneClient();

            // Allow xUnit to trace/debug output to 'Output' window
            System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.DefaultTraceListener());
        }
Exemplo n.º 2
0
        public KeystoneClient CreateClient()
        {
            var ksclient = new KeystoneClient(AuthorityUri);

            // If using password authentication, make sure we have a valid admin token
            // Leave e 30 second margin to perform all keystone-related operations with an
            // already existing token
            if (!String.IsNullOrWhiteSpace(adminPassword) && (DateTime.Now - adminTokenExpiresAt).TotalSeconds > -30)
            {
                lock (this)
                {
                    var project = new Keystone.Project()
                    {
                        Domain = new Keystone.Domain()
                        {
                            Name = domain
                        },
                        Name = adminProject
                    };

                    var token = ksclient.Authenticate(domain, adminUserName, adminPassword, project);

                    adminToken = token.ID;
                    adminTokenExpiresAt = token.ExpiresAt;
                }
            }

            // Set the valid admin token
            ksclient.AdminAuthToken = adminToken;

            return ksclient;
        }