Unit tests for result of ticket validation with subject
This commit is contained in:
@@ -35,7 +35,7 @@ public class KerberosTicketValidation {
|
||||
}
|
||||
|
||||
public KerberosTicketValidation(String username, Subject subject, byte[] responseToken, GSSContext gssContext) {
|
||||
this(username, subject, responseToken, gssContext, null)
|
||||
this(username, subject, responseToken, gssContext, null);
|
||||
}
|
||||
|
||||
public KerberosTicketValidation(String username, Subject subject, byte[] responseToken, GSSContext gssContext, GSSCredential delegationCredential) {
|
||||
|
||||
@@ -295,7 +295,7 @@ public class SunJaasKerberosTicketValidator implements KerberosTicketValidator,
|
||||
this.realmName = realmName;
|
||||
this.multiTier = multiTier;
|
||||
this.debug = debug;
|
||||
this.refreshKrb5Config = refreshKrb5Configx
|
||||
this.refreshKrb5Config = refreshKrb5Config;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.springframework.security.kerberos.authentication;
|
||||
|
||||
import org.ietf.jgss.GSSContext;
|
||||
import org.ietf.jgss.GSSCredential;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.security.auth.Subject;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class KerberosTicketValidationTest {
|
||||
|
||||
private String username = "username";
|
||||
private Subject subject = new Subject();
|
||||
private byte[] responseToken = "token".getBytes();
|
||||
private GSSContext gssContext = mock(GSSContext.class);
|
||||
private GSSCredential delegationCredential = mock(GSSCredential.class);
|
||||
|
||||
@Test
|
||||
public void createResultOfTicketValidationWithSubject() {
|
||||
|
||||
KerberosTicketValidation ticketValidation = new KerberosTicketValidation(
|
||||
username,
|
||||
subject,
|
||||
responseToken,
|
||||
gssContext);
|
||||
|
||||
assertEquals(username, ticketValidation.username());
|
||||
assertEquals(responseToken, ticketValidation.responseToken());
|
||||
assertEquals(gssContext, ticketValidation.getGssContext());
|
||||
|
||||
assertNull("With no credential delegation", ticketValidation.getDelegationCredential());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createResultOfTicketValidationWithSubjectAndDelegation() {
|
||||
|
||||
KerberosTicketValidation ticketValidation = new KerberosTicketValidation(
|
||||
username,
|
||||
subject,
|
||||
responseToken,
|
||||
gssContext,
|
||||
delegationCredential);
|
||||
|
||||
assertEquals(username, ticketValidation.username());
|
||||
assertEquals(responseToken, ticketValidation.responseToken());
|
||||
assertEquals(gssContext, ticketValidation.getGssContext());
|
||||
|
||||
assertEquals("With no credential delegation", delegationCredential, ticketValidation.getDelegationCredential());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user