summaryrefslogtreecommitdiff
path: root/test/integration/api/cert_test.rb
blob: 772901d1d392afd1222e049ea5af043a1a17f978 (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
30
31
require 'test_helper'

class CertTest < ApiIntegrationTest


  test "retrieve eip cert" do
    login
    get '/1/cert', {}, RACK_ENV
    assert_text_response
    assert_response_includes "BEGIN RSA PRIVATE KEY"
    assert_response_includes "END RSA PRIVATE KEY"
    assert_response_includes "BEGIN CERTIFICATE"
    assert_response_includes "END CERTIFICATE"
  end

  test "fetching certs requires login by default" do
    get '/1/cert', {}, RACK_ENV
    assert_login_required
  end

  test "retrieve anonymous eip cert" do
    with_config allow_anonymous_certs: true do
      get '/1/cert', {}, RACK_ENV
      assert_text_response
      assert_response_includes "BEGIN RSA PRIVATE KEY"
      assert_response_includes "END RSA PRIVATE KEY"
      assert_response_includes "BEGIN CERTIFICATE"
      assert_response_includes "END CERTIFICATE"
    end
  end
end