public void WhenClientCertificateSubjectIsConfigured_ItIsPartOfCertificatesCollection()
        {
            /*
             * Note: the AuthTestBase class ensures that the test client cert is installed
             * to the current user's "My" store
             */
            var authConfig = certSubjectOnlyClusterConfig.Authentication;
            var securityManager = new RiakSecurityManager("riak-test", authConfig);
            Assert.True(securityManager.ClientCertificatesConfigured);
            Assert.False(string.IsNullOrWhiteSpace(authConfig.ClientCertificateSubject));

            X509Store x509Store = null;
            try
            {
                x509Store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
                x509Store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
                bool found = false;
                foreach (var cert in x509Store.Certificates)
                {
                    if (cert.Subject == authConfig.ClientCertificateSubject &&
                        securityManager.ClientCertificates.Contains(cert))
                    {
                        found = true;
                        break;
                    }
                }
                Assert.IsTrue(found,
                    "Could not find cert with subject '{0}' in CurrentUser/My store!",
                    authConfig.ClientCertificateSubject);
            }
            finally
            {
                x509Store.Close();
            }
        }
        public void WhenClientCertificateFileIsConfigured_ItIsPartOfCertificatesCollection()
        {
            var authConfig = clusterConfig.Authentication;
            var securityManager = new RiakSecurityManager("riak-test", authConfig);
            Assert.True(securityManager.ClientCertificatesConfigured);

            var certFromFile = new X509Certificate2(authConfig.ClientCertificateFile);
            Assert.Contains(certFromFile, securityManager.ClientCertificates);
        }
 public void WhenSecurityConfiguredInAppConfig_SecurityManagerIndicatesIt()
 {
     var authConfig = clusterConfig.Authentication;
     var securityManager = new RiakSecurityManager("riak-test", authConfig);
     Assert.IsTrue(securityManager.IsSecurityEnabled);
 }