From 984a42dc07923038edd931aae9360727fe5cab61 Mon Sep 17 00:00:00 2001 From: Daniel Felipe Ochoa Date: Wed, 23 Mar 2022 17:08:29 -0500 Subject: [PATCH] Fix for the URI.escape monkey patch. The monkey patch was not being loaded from lib/cloud/azure.rb on normal execution, so it had to be added to lib/bosh_azure_cpi.rb . This however loads the monkey patch even when running the unit tests so a new condition was required on these tests. [#181531703] [azure cpi] Fix the Docker image that builds the azure CPI --- src/bosh_azure_cpi/lib/cloud/azure.rb | 3 +++ .../spec/unit/monkey_patches/uri_monkey_patch_spec.rb | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/bosh_azure_cpi/lib/cloud/azure.rb b/src/bosh_azure_cpi/lib/cloud/azure.rb index cdf4540c1..784edbbd1 100644 --- a/src/bosh_azure_cpi/lib/cloud/azure.rb +++ b/src/bosh_azure_cpi/lib/cloud/azure.rb @@ -103,6 +103,9 @@ module AzureCloud; end require 'cloud/azure/telemetry/telemetry_event_handler' require 'cloud/azure/telemetry/wire_client' +require 'monkey_patches/uri_monkey_patch' +Bosh::AzureCloud::URIMonkeyPatch.apply_patch + module Bosh module Clouds Azure = Bosh::AzureCloud::Cloud diff --git a/src/bosh_azure_cpi/spec/unit/monkey_patches/uri_monkey_patch_spec.rb b/src/bosh_azure_cpi/spec/unit/monkey_patches/uri_monkey_patch_spec.rb index ab16b5d3c..8c1f2a66b 100644 --- a/src/bosh_azure_cpi/spec/unit/monkey_patches/uri_monkey_patch_spec.rb +++ b/src/bosh_azure_cpi/spec/unit/monkey_patches/uri_monkey_patch_spec.rb @@ -5,6 +5,8 @@ describe Bosh::AzureCloud::URIMonkeyPatch do describe '.apply_patch' do context 'when URI does not have an escape method' do + before { URI.instance_eval { undef :escape } } + it 'should add the escape function' do expect { URI.method(:escape) }.to raise_error(NameError) expect { Bosh::AzureCloud::URIMonkeyPatch.apply_patch }.not_to raise_error