Sha256: 040d342d8e2fdfe7b9f0fcfe2f3e6a78e3252d690e3dcb0a8b7c2ed178d48037

Contents?: true

Size: 1.51 KB

Versions: 19

Compression:

Stored size: 1.51 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

19 entries across 19 versions & 3 rubygems

Version Path
fog-azure-rm-temp-0.0.4 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-temp-0.0.3 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.3.3 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-temp-0.0.2 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-temp-0.0.1 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.3.2 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-downgraded-0.3.1 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.3.1 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-downgraded-0.3.0 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.3.0 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.2.7 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.2.6 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.2.5 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.2.4 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.2.3 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.2.2 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.2.1 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.2.0 test/requests/network/test_create_or_update_network_security_group.rb
fog-azure-rm-0.1.2 test/requests/network/test_create_or_update_network_security_group.rb