summaryrefslogtreecommitdiff
path: root/certs/test/unit/cert_test.rb
blob: e41edd7bc3d2e2d2a29e41b400f060cc85f0964c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'test_helper'

class CertTest < ActiveSupport::TestCase

  setup do
    @sample = LeapCA::Cert.new LeapCA::Cert.valid_attributes_hash
  end

  test "stub cert for testing is valid" do
    assert @sample.valid?
  end

  test "validates random" do
    [-1, 1, nil, "asdf"].each do |invalid|
      @sample.random = invalid
      assert !@sample.valid?, "#{invalid} should not be a valid value for random"
    end
  end

  test "validates key" do
    @sample.key = nil
    assert !@sample.valid?, "Cert should require key"
  end

  test "validates cert" do
    @sample.cert = nil
    assert !@sample.valid?, "Cert should require cert"
  end
end