Sha256: e0a3dc32f3a78e2cc4d3d9cb1e18bc58116d6ed126974a1de323f42b0de689c1

Contents?: true

Size: 1.58 KB

Versions: 8

Compression:

Stored size: 1.58 KB

Contents

require "helpers/integration_test_helper"
require "integration/factories/sql_v1_certs_factory"

class TestSQLV1Certs < FogIntegrationTest
  # This test doesn't include TestCollection as certs are not an independent resource.

  def setup
    @subject = Fog::Google[:sql].ssl_certs
    @factory = SqlV1CertsFactory.new(namespaced_name)
    @client  = Fog::Google::SQL.new
  end

  def teardown
    @factory.cleanup
  end

  def test_ssl_certs
    # Create an instance and an SSL cert
    ssl_cert = @factory.create
    instance_name = ssl_cert.instance

    # Create a second cert and attach to the same instance
    ssl_cert2 = @subject.new(:common_name => "#{ssl_cert.common_name}-2",
                             :instance => instance_name)
    ssl_cert2.save

    # Verify it can be retrieved
    @subject.get(instance_name, ssl_cert2.sha1_fingerprint).tap do |result|
      assert_equal(ssl_cert2.common_name, result.common_name)
      assert_equal("sql#sslCert", result.kind)
    end

    # Verify instance returns 2 certs
    list_result = @subject.all(instance_name)
    assert_equal(2, list_result.size,
                 "expected 2 SSL certs")

    # Delete one cert
    ssl_cert2.destroy(:async => false)
    list_result = @subject.all(instance_name)
    assert_equal(1, list_result.size,
                 "expected one less SSL cert after deletion")

    # Test if SSL config is reset correctly
    instance = @client.instances.get(instance_name)
    instance.reset_ssl_config(:async => false)
    assert_equal(0, @subject.all(instance_name).size,
                 "expected no SSL certs after reset")
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fog-google-1.9.1 test/integration/sql/sqlv1/test_v1_certs.rb
fog-google-1.9.0 test/integration/sql/sqlv1/test_v1_certs.rb
fog-google-1.8.2 test/integration/sql/sqlv1/test_v1_certs.rb
fog-google-1.8.1 test/integration/sql/sqlv1/test_v1_certs.rb
fog-google-1.8.0 test/integration/sql/sqlv1/test_v1_certs.rb
fog-google-1.7.1 test/integration/sql/sqlv1/test_v1_certs.rb
fog-google-1.7.0 test/integration/sql/sqlv1/test_v1_certs.rb
fog-google-1.6.0 test/integration/sql/test_v1_certs.rb