From c90d30621e042cc3e52ffc87e3491ab110a57e9e Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 24 Sep 2012 12:16:14 +0200 Subject: ported over proper ways of creating certs Will now use .txt as the extention Returns the actual content on .zipped With tests. --- test/test_helper.rb | 3 +++ test/unit/cert_test.rb | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test_helper.rb b/test/test_helper.rb index 742e462..d78cc96 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,6 @@ require 'rubygems' require 'minitest/autorun' +LEAP_CA_ROOT = File.expand_path('../..', __FILE__) +$:.unshift File.expand_path('lib', LEAP_CA_ROOT) + require 'mocha' diff --git a/test/unit/cert_test.rb b/test/unit/cert_test.rb index 3f4c01f..761e5a9 100644 --- a/test/unit/cert_test.rb +++ b/test/unit/cert_test.rb @@ -1,5 +1,5 @@ require 'test_helper' -require 'lib/cert' +require 'leap_ca/cert' class CertTest < MiniTest::Unit::TestCase @@ -10,21 +10,29 @@ class CertTest < MiniTest::Unit::TestCase end def test_certs_come_with_attachments - assert @sample.has_attachment? "cert.zip" + assert @sample.has_attachment? "cert.txt" end def test_zipper_returns_zip_attachement - assert_equal "application/zip", @sample.zipped["content_type"] + assert_equal "text/plain", @sample.zip_attachment["content_type"] end def test_zipname_returns_name_of_zip_file - assert_equal "cert.zip", @sample.zipname + assert_equal "cert.txt", @sample.zipname end def test_test_data assert @sample.valid? end + def test_zipped_returns_actual_data + @sample.save # This is required! + lines = @sample.zipped.split("\n") + assert_equal 56, lines.count + assert_equal "-----BEGIN RSA PRIVATE KEY-----", lines.first.chomp + assert_equal "-----END CERTIFICATE-----", lines.last.chomp + end + def test_validation_of_random @sample.stubs(:set_random) [0, 1, nil, "asdf"].each do |invalid| -- cgit v1.2.3