Unit test for delete endpoint.

Add options winrm_http_port and winrm_https_port to virtual machine.
This commit is contained in:
Ranjan Kumar 2014-04-11 15:28:38 +05:30
Родитель 4b0be73964
Коммит 1f60ba31bc
4 изменённых файлов: 102 добавлений и 2 удалений

Просмотреть файл

@ -33,7 +33,9 @@ Puppet::Face.define :azure_vm, '1.0.0' do
virtual_network_name: options[:virtual_network_name],
subnet_name: options[:virtual_network_subnet],
affinity_group_name: options[:affinity_group_name],
availability_set_name: options[:availability_set_name]
availability_set_name: options[:availability_set_name],
winrm_http_port: options[:winrm_http_port],
winrm_https_port: options[:winrm_https_port],
}
others.merge!(winrm_transport: options[:winrm_transport]) unless options[:winrm_transport].nil?
server = virtual_machine_service.create_virtual_machine(params, others, options[:add_role])

Просмотреть файл

@ -81,6 +81,8 @@ module Puppet
add_location_option(action)
add_vm_size_option(action)
add_ssh_port_option(action)
add_winrm_http_port_option(action)
add_winrm_https_port_option(action)
add_certificate_file_option(action)
add_private_key_file_option(action)
add_winrm_transport_option(action)
@ -586,6 +588,20 @@ module Puppet
EOT
end
end
def add_winrm_http_port_option(action)
action.option '--winrm-http-port=' do
summary 'Specifies the WinRM HTTP port number.'
description 'Specifies the WinRM HTTP port number.'
end
end
def add_winrm_https_port_option(action)
action.option '--winrm-https-port=' do
summary 'Specifies the WinRM HTTPS port number.'
description 'Specifies the WinRM HTTPS port number.'
end
end
end
end
end

Просмотреть файл

@ -46,7 +46,9 @@ describe Puppet::Face[:azure_vm, :current] do
virtual_network_subnet: 'Subnet-1',
winrm_transport: 'http',
vm_size: 'Small',
availability_set_name: 'availabiity-set-name'
availability_set_name: 'availabiity-set-name',
winrm_http_port: '5985',
winrm_https_port: '5986'
}
Azure.configure do |config|
config.management_certificate = @options[:management_certificate]
@ -387,4 +389,17 @@ describe Puppet::Face[:azure_vm, :current] do
end
end
describe '(winrm_http_port)' do
it 'winrm_http_port should be optional' do
@options.delete(:winrm_http_port)
expect { subject.create(@options) }.to_not raise_error
end
end
describe '(winrm_https_port)' do
it 'winrm_https_port should be optional' do
@options.delete(:winrm_https_port)
expect { subject.create(@options) }.to_not raise_error
end
end
end

Просмотреть файл

@ -0,0 +1,67 @@
# encoding: UTF-8
require 'spec_helper'
describe Puppet::Face[:azure_vm, :current] do
let(:vms) { Azure::VirtualMachineManagementService }
before :each do
mgmtcertfile = File.expand_path('spec/fixtures/management_certificate.pem')
@options = {
management_certificate: mgmtcertfile,
azure_subscription_id: 'Subscription-id',
vm_name: 'test-vm',
cloud_service_name: 'cloud-name',
endpoint_name: 'endpoint_name'
}
Azure.configure do |config|
config.management_certificate = @options[:management_certificate]
config.subscription_id = @options[:azure_subscription_id]
end
vms.any_instance.stubs(:delete_endpoint).with(
anything,
anything,
anything
)
end
describe 'option validation' do
describe 'valid options' do
it 'should not raise any exception' do
expect { subject.delete_endpoint(@options) }.to_not raise_error
end
end
describe '(vm_name)' do
it 'should require a vm name' do
@options.delete(:vm_name)
expect { subject.delete_endpoint(@options) }.to raise_error(
ArgumentError,
/required: vm_name/
)
end
end
describe '(cloud_service_name)' do
it 'should require a cloud service name' do
@options.delete(:cloud_service_name)
expect { subject.delete_endpoint(@options) }.to raise_error(
ArgumentError,
/required: cloud_service_name/
)
end
end
describe '(endpoint_name)' do
it 'should require endpoint name' do
@options.delete(:endpoint_name)
expect { subject.delete_endpoint(@options) }.to raise_error(
ArgumentError,
/required: endpoint_name/
)
end
end
it_behaves_like 'validate authentication credential', :delete_endpoint
end
end