Skip to content

Commit

Permalink
Fix travis (#30)
Browse files Browse the repository at this point in the history
* Test more Elixir/Erlang versions

* Recognize TLS alerts on newer OTP versions

* Make extension value assertions work with older ExUnit
  • Loading branch information
voltone authored Jul 15, 2019
1 parent bf34492 commit 1058f5d
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 83 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ sudo: false
script: mix test --include openssl
matrix:
include:
- elixir: '1.9.0'
otp_release: '22.0'
- elixir: '1.8.2'
otp_release: '21.3'
- elixir: '1.7.3'
otp_release: '21.1'
- elixir: '1.6.6'
Expand Down
87 changes: 48 additions & 39 deletions test/x509/certificate/extension_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,69 +22,78 @@ defmodule X509.Certificate.ExtensionTest do

describe "find (through Certificate.extension/2)" do
test "basic_constraints", %{certs: certs} do
assert extension(extnValue: {:BasicConstraints, true, :asn1_NOVALUE}) =
X509.Certificate.extension(certs.root_ca, :basic_constraints)
assert certs.root_ca
|> X509.Certificate.extension(:basic_constraints)
|> extension(:extnValue) ==
{:BasicConstraints, true, :asn1_NOVALUE}
end

test "key_usage", %{certs: certs} do
assert extension(extnValue: [:keyCertSign, :cRLSign]) =
X509.Certificate.extension(certs.root_ca, :key_usage)
assert certs.root_ca
|> X509.Certificate.extension(:key_usage)
|> extension(:extnValue) ==
[:keyCertSign, :cRLSign]
end

test "ext_key_usage", %{certs: certs} do
assert extension(extnValue: [{1, 3, 6, 1, 5, 5, 7, 3, 1}, {1, 3, 6, 1, 5, 5, 7, 3, 2}]) =
X509.Certificate.extension(certs.server, :ext_key_usage)
assert certs.server
|> X509.Certificate.extension(:ext_key_usage)
|> extension(:extnValue) ==
[{1, 3, 6, 1, 5, 5, 7, 3, 1}, {1, 3, 6, 1, 5, 5, 7, 3, 2}]
end

test "subject_key_identifier", %{certs: certs} do
assert extension(
extnValue:
<<37, 69, 129, 104, 80, 38, 56, 61, 59, 45, 44, 190, 205, 106, 217, 182, 61, 179,
102, 99>>
) = X509.Certificate.extension(certs.int_ca, :subject_key_identifier)
assert certs.int_ca
|> X509.Certificate.extension(:subject_key_identifier)
|> extension(:extnValue) ==
<<37, 69, 129, 104, 80, 38, 56, 61, 59, 45, 44, 190, 205, 106, 217, 182, 61, 179,
102, 99>>
end

test "authority_key_identifier", %{certs: certs} do
assert extension(
extnValue:
{:AuthorityKeyIdentifier,
<<124, 12, 50, 31, 167, 217, 48, 127, 196, 125, 104, 163, 98, 168, 161, 206,
171, 7, 91, 39>>, :asn1_NOVALUE, :asn1_NOVALUE}
) = X509.Certificate.extension(certs.int_ca, :authority_key_identifier)
assert certs.int_ca
|> X509.Certificate.extension(:authority_key_identifier)
|> extension(:extnValue) ==
{:AuthorityKeyIdentifier,
<<124, 12, 50, 31, 167, 217, 48, 127, 196, 125, 104, 163, 98, 168, 161, 206, 171,
7, 91, 39>>, :asn1_NOVALUE, :asn1_NOVALUE}
end

test "subject_alt_name", %{certs: certs} do
assert extension(extnValue: [dNSName: '*.tools.ietf.org', dNSName: 'tools.ietf.org']) =
X509.Certificate.extension(certs.server, :subject_alt_name)
assert certs.server
|> X509.Certificate.extension(:subject_alt_name)
|> extension(:extnValue) ==
[dNSName: '*.tools.ietf.org', dNSName: 'tools.ietf.org']
end

test "crl_distribution_points", %{certs: certs} do
assert extension(
extnValue: [
{:DistributionPoint,
{:fullName,
[
uniformResourceIdentifier: 'http://crl.starfieldtech.com/sfig2s1-128.crl'
]}, :asn1_NOVALUE, :asn1_NOVALUE}
]
) = X509.Certificate.extension(certs.server, :crl_distribution_points)
assert certs.server
|> X509.Certificate.extension(:crl_distribution_points)
|> extension(:extnValue) == [
{:DistributionPoint,
{:fullName,
[
uniformResourceIdentifier: 'http://crl.starfieldtech.com/sfig2s1-128.crl'
]}, :asn1_NOVALUE, :asn1_NOVALUE}
]
end

test "authority_info_access", %{certs: certs} do
assert extension(
extnValue: [
{:AccessDescription, {1, 3, 6, 1, 5, 5, 7, 48, 1},
{:uniformResourceIdentifier, 'http://ocsp.starfieldtech.com/'}},
{:AccessDescription, {1, 3, 6, 1, 5, 5, 7, 48, 2},
{:uniformResourceIdentifier,
'http://certificates.starfieldtech.com/repository/sfig2.crt'}}
]
) = X509.Certificate.extension(certs.server, :authority_info_access)
assert certs.server
|> X509.Certificate.extension(:authority_info_access)
|> extension(:extnValue) == [
{:AccessDescription, {1, 3, 6, 1, 5, 5, 7, 48, 1},
{:uniformResourceIdentifier, 'http://ocsp.starfieldtech.com/'}},
{:AccessDescription, {1, 3, 6, 1, 5, 5, 7, 48, 2},
{:uniformResourceIdentifier,
'http://certificates.starfieldtech.com/repository/sfig2.crt'}}
]
end

test "ocsp_nocheck", %{certs: certs} do
assert extension(extnValue: <<5, 0>>) =
X509.Certificate.extension(certs.ocsp_responder, :ocsp_nocheck)
assert certs.ocsp_responder
|> X509.Certificate.extension(:ocsp_nocheck)
|> extension(:extnValue) == <<5, 0>>
end
end
end
Loading

0 comments on commit 1058f5d

Please sign in to comment.