Sha256: d49155a4f956a9c525e93bec5367b38426f675e60505ae9da9ebac32baa0780d

Contents?: true

Size: 1.6 KB

Versions: 14

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path '../../test_helper', __dir__

# Test class for Check Vault Exists Request
class TestCheckVaultExists < Minitest::Test
  def setup
    @service = Fog::KeyVault::AzureRM.new(credentials)
    @key_vault_client = @service.instance_variable_get(:@key_vault_client)
    @vaults = @key_vault_client.vaults
  end

  def test_check_vault_exists_success
    response = ApiStub::Requests::KeyVault::Vault.create_vault_response(@key_vault_client)
    @vaults.stub :get, response do
      assert @service.check_vault_exists('fog-test-rg', 'fog-test-kv')
    end
  end

  def test_check_vault_exists_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
    @vaults.stub :get, response do
      assert !@service.check_vault_exists('fog-test-rg', 'fog-test-kv')
    end
  end

  def test_check_vault_resource_group_exists_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
    @vaults.stub :get, response do
      assert !@service.check_vault_exists('fog-test-rg', 'fog-test-kv')
    end
  end

  def test_check_vault_exists_exception
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
    @vaults.stub :get, response do
      assert_raises(MsRestAzure::AzureOperationError) { @service.check_vault_exists('fog-test-rg', 'fog-test-kv') }
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
fog-azure-rm-0.6.0 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.5.3 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.5.2 test/requests/key_vault/test_check_vault_exists.rb
far-gem-0.5.6 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.5.1 test/requests/key_vault/test_check_vault_exists.rb
far-gem-0.5.5 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.5.0 test/requests/key_vault/test_check_vault_exists.rb
far-gem-0.5.4 test/requests/key_vault/test_check_vault_exists.rb
far-gem-0.5.3 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.4.9 test/requests/key_vault/test_check_vault_exists.rb
far-gem-0.5.2 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.4.8 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.4.7 test/requests/key_vault/test_check_vault_exists.rb
fog-azure-rm-0.4.6 test/requests/key_vault/test_check_vault_exists.rb