forked from spring-projects/spring-security-kerberos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests for result of ticket validation with subject
- Loading branch information
Showing
3 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...va/org/springframework/security/kerberos/authentication/KerberosTicketValidationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |