summaryrefslogtreecommitdiff
path: root/test/integration/api/cert_test.rb
blob: 289d3c6511f9800abdbfd7423aa986d4e847f5c8 (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
32
33
34
35
36
require 'test_helper'

class CertTest < ApiIntegrationTest


  test "retrieve eip cert" do
    login
    get cert_url, {}, 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 cert_url, {}, RACK_ENV
    assert_login_required
  end

  test "retrieve anonymous eip cert" do
    with_config allow_anonymous_certs: true do
      get cert_url, {}, 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

  def cert_url
    "/#{api_version}/cert"
  end

end