public virtual void TestGetPrincipalNamesMissingKeytab()
 {
     try
     {
         KerberosUtil.GetPrincipalNames(testKeytab);
         NUnit.Framework.Assert.Fail("Exception should have been thrown");
     }
     catch (IOException)
     {
     }
 }
 public virtual void TestGetPrincipalNamesMissingPattern()
 {
     CreateKeyTab(testKeytab, new string[] { "test/testhost@testRealm" });
     try
     {
         KerberosUtil.GetPrincipalNames(testKeytab, null);
         NUnit.Framework.Assert.Fail("Exception should have been thrown");
     }
     catch (Exception)
     {
     }
 }
        public virtual void TestGetPrincipalNamesFromKeytab()
        {
            CreateKeyTab(testKeytab, testPrincipals);
            // read all principals in the keytab file
            string[] principals = KerberosUtil.GetPrincipalNames(testKeytab);
            NUnit.Framework.Assert.IsNotNull("principals cannot be null", principals);
            int            expectedSize  = 0;
            IList <string> principalList = Arrays.AsList(principals);

            foreach (string principal in testPrincipals)
            {
                Assert.True("missing principal " + principal, principalList.Contains
                                (principal));
                expectedSize++;
            }
            Assert.Equal(expectedSize, principals.Length);
        }
        public virtual void TestGetPrincipalNamesFromKeytabWithPattern()
        {
            CreateKeyTab(testKeytab, testPrincipals);
            // read the keytab file
            // look for principals with HTTP as the first part
            Pattern httpPattern = Pattern.Compile("HTTP/.*");

            string[] httpPrincipals = KerberosUtil.GetPrincipalNames(testKeytab, httpPattern);
            NUnit.Framework.Assert.IsNotNull("principals cannot be null", httpPrincipals);
            int            expectedSize      = 0;
            IList <string> httpPrincipalList = Arrays.AsList(httpPrincipals);

            foreach (string principal in testPrincipals)
            {
                if (httpPattern.Matcher(principal).Matches())
                {
                    Assert.True("missing principal " + principal, httpPrincipalList
                                .Contains(principal));
                    expectedSize++;
                }
            }
            Assert.Equal(expectedSize, httpPrincipals.Length);
        }