@@ -69,6 +69,42 @@ public void CreateServiceTicket_NullPrincipal()
6969 } ) ;
7070 }
7171
72+ [ TestMethod ]
73+ public void CreateServiceTicket_NullClientRealmName ( )
74+ {
75+ var key = KrbEncryptionKey . Generate ( EncryptionType . AES128_CTS_HMAC_SHA1_96 ) . AsKey ( ) ;
76+
77+ // This should not throw, as ClientRealmName is allowed to be null if CompatibilityFlags.IsolateRealmsConsistently is not set
78+ var tgsRep = KrbKdcRep . GenerateServiceTicket < KrbTgsRep > ( new ServiceTicketRequest
79+ {
80+ EncryptedPartKey = key ,
81+ ServicePrincipal = new FakeKerberosPrincipal ( "blah@blah.com" ) ,
82+ ServicePrincipalKey = key ,
83+ Principal = new FakeKerberosPrincipal ( "blah@blah2.com" ) ,
84+ RealmName = "blah.com" ,
85+ ClientRealmName = null ,
86+ Compatibility = KerberosCompatibilityFlags . NormalizeRealmsUppercase ,
87+ } ) ;
88+ }
89+
90+ [ TestMethod ]
91+ [ ExpectedException ( typeof ( InvalidOperationException ) ) ]
92+ public void CreateServiceTicket_NullClientRealmName_IsolateRealmsConsistently ( )
93+ {
94+ var key = KrbEncryptionKey . Generate ( EncryptionType . AES128_CTS_HMAC_SHA1_96 ) . AsKey ( ) ;
95+
96+ var tgsRep = KrbKdcRep . GenerateServiceTicket < KrbTgsRep > ( new ServiceTicketRequest
97+ {
98+ EncryptedPartKey = key ,
99+ ServicePrincipal = new FakeKerberosPrincipal ( "blah@blah.com" ) ,
100+ ServicePrincipalKey = key ,
101+ Principal = new FakeKerberosPrincipal ( "blah@blah2.com" ) ,
102+ RealmName = "blah.com" ,
103+ ClientRealmName = null ,
104+ Compatibility = KerberosCompatibilityFlags . NormalizeRealmsUppercase | KerberosCompatibilityFlags . IsolateRealmsConsistently ,
105+ } ) ;
106+ }
107+
72108 [ TestMethod ]
73109 public void CreateServiceTicket ( )
74110 {
0 commit comments