// dynamic configuration of HTTP principals /// <exception cref="System.Exception"/> public virtual void TestDynamicPrincipalDiscovery() { string[] keytabUsers = new string[] { "HTTP/host1", "HTTP/host2", "HTTP2/host1", "XHTTP/host" }; string keytab = KerberosTestUtils.GetKeytabFile(); GetKdc().CreatePrincipal(new FilePath(keytab), keytabUsers); // destroy handler created in setUp() handler.Destroy(); Properties props = new Properties(); props.SetProperty(KerberosAuthenticationHandler.Keytab, keytab); props.SetProperty(KerberosAuthenticationHandler.Principal, "*"); handler = GetNewAuthenticationHandler(); handler.Init(props); Assert.Equal(KerberosTestUtils.GetKeytabFile(), handler.GetKeytab ()); ICollection <KerberosPrincipal> loginPrincipals = handler.GetPrincipals(); foreach (string user in keytabUsers) { Principal principal = new KerberosPrincipal(user + "@" + KerberosTestUtils.GetRealm ()); bool expected = user.StartsWith("HTTP/"); Assert.Equal("checking for " + user, expected, loginPrincipals .Contains(principal)); } }
/// <exception cref="System.Exception"/> public virtual void TestInit() { Assert.Equal(KerberosTestUtils.GetKeytabFile(), handler.GetKeytab ()); ICollection <KerberosPrincipal> principals = handler.GetPrincipals(); Principal expectedPrincipal = new KerberosPrincipal(KerberosTestUtils.GetServerPrincipal ()); Assert.True(principals.Contains(expectedPrincipal)); Assert.Equal(1, principals.Count); }