summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2012-09-24 12:16:14 +0200
committerAzul <azul@riseup.net>2012-09-24 12:16:14 +0200
commitc90d30621e042cc3e52ffc87e3491ab110a57e9e (patch)
tree9ebb5b3026dddd4c3c56f4eb333201327a2641aa /test
parent06b8d8c971a07df3f96fdfd0e753a8284d0dac5a (diff)
ported over proper ways of creating certs
Will now use .txt as the extention Returns the actual content on .zipped With tests.
Diffstat (limited to 'test')
-rw-r--r--test/test_helper.rb3
-rw-r--r--test/unit/cert_test.rb16
2 files changed, 15 insertions, 4 deletions
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|