Class: Fog::KeyVault::AzureRM::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/azurerm/key_vault.rb,
lib/fog/azurerm/requests/key_vault/get_vault.rb,
lib/fog/azurerm/requests/key_vault/list_vaults.rb,
lib/fog/azurerm/requests/key_vault/delete_vault.rb,
lib/fog/azurerm/requests/key_vault/check_vault_exists.rb,
lib/fog/azurerm/requests/key_vault/create_or_update_vault.rb

Overview

This class provides the mock implementation for unit tests.

Instance Method Summary collapse

Constructor Details

#initialize(_options = {}) ⇒ Mock

Returns a new instance of Mock.



24
25
26
27
28
29
30
31
# File 'lib/fog/azurerm/key_vault.rb', line 24

def initialize(_options = {})
  begin
    require 'azure_mgmt_key_vault'
  rescue LoadError => e
    retry if require('rubygems')
    raise e.message
  end
end

Instance Method Details

#check_vault_existsObject



25
26
27
# File 'lib/fog/azurerm/requests/key_vault/check_vault_exists.rb', line 25

def check_vault_exists(*)
  true
end

#create_or_update_vaultObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/fog/azurerm/requests/key_vault/create_or_update_vault.rb', line 73

def create_or_update_vault(*)
  vault = {
    'id' => '/subscriptions/<AZURE_SUBSCRIPTION_ID>/resourceGroups/RubySDKTest_azure_mgmt_kv/providers/Microsoft.KeyVault/vaults/sampleVault758347',
    'name' => 'sampleVault758347',
    'type' => 'Microsoft.KeyVault/vaults',
    'location' => 'westus',
    'tags' => {},
    'properties' => {
      'sku' => {
        'family' => 'A',
        'name' => 'standard'
      },
      'tenantId' => '<AZURE_TENANT_ID>',
      'accessPolicies' => [
        {
          'tenantId' => '<AZURE_TENANT_ID>',
          'objectId' => '<AZURE_OBJECT_ID>',
          'permissions' => {
            'keys' => ['all'],
            'secrets' => ['all']
          }
        }
      ],
      'enabledForDeployment' => false,
      'vaultUri' => 'https =>//samplevault758347.vault.azure.net/'
    }
  }
  vault_mapper = Azure::ARM::KeyVault::Models::Vault.mapper
  @key_vault_client.deserialize(vault_mapper, vault, 'result.body')
end

#delete_vault(resource_group, vault_name) ⇒ Object



21
22
23
24
# File 'lib/fog/azurerm/requests/key_vault/delete_vault.rb', line 21

def delete_vault(resource_group, vault_name)
  Fog::Logger.debug "Vault #{vault_name} from Resource group #{resource_group} deleted successfully."
  true
end

#get_vaultObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/azurerm/requests/key_vault/get_vault.rb', line 21

def get_vault(*)
  vault = {
    'id' => '/subscriptions/<AZURE_SUBSCRIPTION_ID>/resourceGroups/RubySDKTest_azure_mgmt_kv/providers/Microsoft.KeyVault/vaults/sampleVault758347',
    'name' => 'sampleVault758347',
    'type' => 'Microsoft.KeyVault/vaults',
    'location' => 'westus',
    'tags' => {},
    'properties' => {
      'sku' => {
        'family' => 'A',
        'name' => 'standard'
      },
      'tenantId' => '<AZURE_TENANT_ID>',
      'accessPolicies' => [
        {
          'tenantId' => '<AZURE_TENANT_ID>',
          'objectId' => '<AZURE_OBJECT_ID>',
          'permissions' => {
            'keys' => ['all'],
            'secrets' => ['all']
          }
        }
      ],
      'enabledForDeployment' => false,
      'vaultUri' => 'https =>//samplevault758347.vault.azure.net/'
    }
  }
  vault_mapper = Azure::ARM::KeyVault::Models::Vault.mapper
  @key_vault_client.deserialize(vault_mapper, vault, 'result.body')
end

#list_vaultsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/azurerm/requests/key_vault/list_vaults.rb', line 21

def list_vaults(*)
  vaults = [
    {
      'id' => '/subscriptions/<AZURE_SUBSCRIPTION_ID>/resourceGroups/RubySDKTest_azure_mgmt_kv/providers/Microsoft.KeyVault/vaults/sampleVault758347',
      'name' => 'sampleVault758347',
      'type' => 'Microsoft.KeyVault/vaults',
      'location' => 'westus',
      'tags' => {},
      'properties' => {
        'sku' => {
          'family' => 'A',
          'name' => 'standard'
        },
        'tenantId' => '<AZURE_TENANT_ID>',
        'accessPolicies' => [
          {
            'tenantId' => '<AZURE_TENANT_ID>',
            'objectId' => '<AZURE_OBJECT_ID>',
            'permissions' => {
              'keys' => ['all'],
              'secrets' => ['all']
            }
          }
        ],
        'enabledForDeployment' => false,
        'vaultUri' => 'https =>//samplevault758347.vault.azure.net/'
      }
    }
  ]
  vaults_mapper = Azure::ARM::KeyVault::Models::VaultListResult.mapper
  @key_vault_client.deserialize(vaults_mapper, vaults, 'result.body').value
end