summaryrefslogtreecommitdiff
path: root/certs/test/unit/client_certificate_test.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-02-26 07:25:12 -0800
committerazul <azul@riseup.net>2013-02-26 07:25:12 -0800
commit5dbbf733a6abe809a38667e8b3277fd06db24788 (patch)
tree14f60e6facd88dc5d218aec14175a59fdf5834ad /certs/test/unit/client_certificate_test.rb
parent1023cac35016bb1a89864d10ac89acabe86cf227 (diff)
parent2eafc17ea68e75e6b040b6c6677e5eebd3371f0e (diff)
Merge pull request #27 from leapcode/feature/free-certs
Enable free certs
Diffstat (limited to 'certs/test/unit/client_certificate_test.rb')
-rw-r--r--certs/test/unit/client_certificate_test.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/certs/test/unit/client_certificate_test.rb b/certs/test/unit/client_certificate_test.rb
index 71a1d90..bcc61cc 100644
--- a/certs/test/unit/client_certificate_test.rb
+++ b/certs/test/unit/client_certificate_test.rb
@@ -2,17 +2,28 @@ require 'test_helper'
class ClientCertificateTest < ActiveSupport::TestCase
- setup do
- @sample = ClientCertificate.new
+ test "new cert has all we need" do
+ sample = ClientCertificate.new
+ assert sample.key
+ assert sample.cert
+ assert sample.to_s
end
- test "new cert has all we need" do
- assert @sample.key
- assert @sample.cert
+ test "free cert has configured postfix" do
+ sample = ClientCertificate.new(free: true)
+ postfix = APP_CONFIG[:free_cert_postfix]
+ assert sample.cert.subject.common_name.include?(postfix)
+ end
+
+ test "real cert has no free cert postfix" do
+ sample = ClientCertificate.new
+ postfix = APP_CONFIG[:free_cert_postfix]
+ assert !sample.cert.subject.common_name.include?(postfix)
end
test "cert issuer matches ca subject" do
- cert = OpenSSL::X509::Certificate.new(@sample.cert)
+ sample = ClientCertificate.new
+ cert = OpenSSL::X509::Certificate.new(sample.cert.to_pem)
assert_equal ClientCertificate.root_ca.openssl_body.subject, cert.issuer
end