<commit_before>package org.fiteagle.core.aaa;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.sql.SQLException;

import org.fiteagle.core.aaa.AuthenticationHandler.KeyDoesNotMatchException;
import org.fiteagle.core.userdatabase.UserPersistable.RecordNotFoundException;
import org.junit.Before;
import org.junit.Test;

public class AuthenticationHandlerTest {
  X509Certificate testCertificate;
  X509Certificate[] testCertificateArray;
  AuthenticationHandler authHandler;
  String knowUserCertPath = "/org/fiteagle/core/certificates/userCert.pem";
  String unknownUserCertPath = "/org/fiteagle/core/certificates/testCertUnknownUser.pem";
  String wrongPkeyCertPath =   "/org/fiteagle/core/certificates/testCertWrongPKey.pem";
  String signedByFiteagleCertPath = "/org/fiteagle/core/certificates/testCertSignedByFiteagle.pem";
  String certChainPath = "/org/fiteagle/core/certificates/chain.gid";
  String dummyPublicKey;
  
  @Before
  public void setUp() throws Exception {
   
    testCertificateArray = loadTestCert(certChainPath);
    authHandler = AuthenticationHandler.getInstance();
    dummyPublicKey = "<KEY>";
  
  }
  
 
  
 // @Test
  public void testAuthenticateCertificates() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, InvalidAlgorithmParameterException, CertPathValidatorException, SQLException {
    
    authHandler.authenticateCertificates(testCertificateArray);
    
  }
  
  @Test
  public void testAuthenticateChain() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, InvalidAlgorithmParameterException, CertPathValidatorException, IOException, SQLException{
    authHandler.authenticateCertificates(testCertificateArray);
  }
 // @Test(expected = RecordNotFoundException.class)
  public void testAuthWithUnstoredPkeyAndUntrustedCert() throws CertificateException, KeyStoreException, NoSuchAlgorithmException, IOException, InvalidAlgorithmParameterException, CertPathValidatorException, SQLException {
    <commit_msg>changed test to use cert existent not only locally :/<commit_after>package org.fiteagle.core.aaa;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.sql.SQLException;

import org.fiteagle.core.aaa.AuthenticationHandler.KeyDoesNotMatchException;
import org.fiteagle.core.userdatabase.UserPersistable.RecordNotFoundException;
import org.junit.Before;
import org.junit.Test;

public class AuthenticationHandlerTest {
  X509Certificate testCertificate;
  X509Certificate[] testCertificateArray;
  AuthenticationHandler authHandler;
  String knowUserCertPath = "/org/fiteagle/core/certificates/userCert.pem";
  String unknownUserCertPath = "/org/fiteagle/core/certificates/testCertUnknownUser.pem";
  String wrongPkeyCertPath =   "/org/fiteagle/core/certificates/testCertWrongPKey.pem";
  String signedByFiteagleCertPath = "/org/fiteagle/core/certificates/testCertSignedByFiteagle.pem";
  String certChainPath = "/org/fiteagle/core/certificates/chain.gid";
  String dummyPublicKey;
  
  @Before
  public void setUp() throws Exception {
   
    testCertificateArray = loadTestCert(signedByFiteagleCertPath);
    authHandler = AuthenticationHandler.getInstance();
    dummyPublicKey = "<KEY>";
  
  }
  
 
  
 // @Test
  public void testAuthenticateCertificates() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, InvalidAlgorithmParameterException, CertPathValidatorException, SQLException {
    
    authHandler.authenticateCertificates(testCertificateArray);
    
  }
  
  @Test
  public void testAuthenticateChain() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, InvalidAlgorithmParameterException, CertPathValidatorException, IOException, SQLException{
    authHandler.authenticateCertificates(testCertificateArray);
  }
 // @Test(expected = RecordNotFoundException.class)
  public void testAuthWithUnstoredPkeyAndUntrustedCert() throws CertificateException, KeyStoreException, NoSuchAlgorithmException, IOException, InvalidAlgorithmParameterException, CertPathValidatorException, SQLException {
    
{'fraction_non_alphanumeric': 0.07750979179550609, 'fraction_numerical': 0.0037105751391465678, 'mean_word_length': 6.788121990369182, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7060898', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1267, 'n_words': 227}