Added some missing files from earlier commits caused by -R stuff in mtn.

This commit is contained in:
meeh
2018-04-22 23:48:44 +00:00
parent 38e109db2b
commit e8ac24bedd
6 changed files with 104 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package net.i2p.crypto
import java.io.File
import java.security.cert.X509Certificate
import org.scalatest.FunSpec
import org.scalatest.Matchers
class CertUtilSpec extends FunSpec with Matchers {
describe("CertUtil") {
// For some stupid gradle issues, it don't copies reosurces. So hacky way.
// When added to junit directory, it get copied. Until a better way is found,
// this is the non-optimal solution.
val certFileUrl = getClass.getResource("/resources/meeh_at_mail.i2p.crt")
val certFile = new File(certFileUrl.toURI)
it("should be able to read a certificate") {
val cert: X509Certificate = CertUtil.loadCert(certFile)
assert(cert.getSubjectDN.toString === "CN=meeh@mail.i2p, OU=I2P, O=I2P Anonymous Network, L=XX, ST=XX, C=XX")
}
it("should be able to tell if it's revoked or not") {
val cert: X509Certificate = CertUtil.loadCert(certFile)
assert(CertUtil.isRevoked(cert) === false)
}
}
}

View File

@ -0,0 +1,30 @@
package net.i2p.crypto
import java.io.File
import org.scalatest.FunSpec
import org.scalatest.Matchers
class SU3FileSpec extends FunSpec with Matchers {
def cheater(methodName : String, parameters: (AnyRef,Class[_])*): AnyRef = {
val parameterValues = parameters.map(_._1)
val parameterTypes = parameters.map(_._2)
val method = classOf[SU3File].getDeclaredMethod(methodName, parameterTypes:_*)
method.setAccessible(true)
method.invoke(classOf[SU3File], parameterValues:_*)
}
describe("SU3File") {
val certFileUrl = getClass.getResource("/resources/meeh_at_mail.i2p.crt")
val certFile = new File(certFileUrl.toURI)
val seedFileUrl = getClass.getResource("/resources/i2pseeds.su3")
val seedFile = new File(seedFileUrl.toURI)
it("should be able to verify a valid file") {
cheater("verifySigCLI", (seedFile.getAbsolutePath, classOf[String]), (certFile.getAbsolutePath, classOf[String]))
}
}
}