Sha256: c99190b69f1d78aaa83287f7f46ce3baa469e1738f6ef80ede2f4e62f3679433

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 KB

Contents

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

# Test class for Create Network Security Group
class TestCreateOrUpdateNetworkSecurityGroup < Minitest::Test
  def setup
    @service = Fog::Network::AzureRM.new(credentials)
    @client = @service.instance_variable_get(:@network_client)
    @network_security_groups = @client.network_security_groups
  end

  def test_create_or_update_network_security_group_success
    mocked_response = ApiStub::Requests::Network::NetworkSecurityGroup.create_network_security_group_response(@client)
    security_rule = {
      name: 'testRule',
      protocol: 'tcp',
      source_port_range: '22',
      destination_port_range: '22',
      source_address_prefix: '0.0.0.0/0',
      destination_address_prefix: '0.0.0.0/0',
      access: 'Allow',
      priority: '100',
      direction: 'Inbound',
      description: 'This is a test rule'
    }
    @network_security_groups.stub :begin_create_or_update, mocked_response do
      assert_equal @service.create_or_update_network_security_group('fog-test-rg', 'fog-test-nsg', 'West US', [security_rule]), mocked_response
    end
  end

  def test_create_or_update_network_security_group_failure
    response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
    @network_security_groups.stub :begin_create_or_update, response do
      assert_raises RuntimeError do
        @service.create_or_update_network_security_group('fog-test-rg', 'fog-test-nsg', 'West US', [])
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fog-azure-rm-0.1.1 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.1.0 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.0.9 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.0.8 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.0.6 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.0.5 test/requests/network/test_create_or_update_network_security_group.rb