From 29e07f27b2057293f35dc00c0c4eb8e016556e41 Mon Sep 17 00:00:00 2001 From: Jens Harbott Date: Mon, 6 May 2019 08:52:00 +0000 Subject: [PATCH] Clean up URI handling The two functions auth_uri_transform() and identity_uri_transform() implicitly assume that the identity endpoint has no path component other than 'v2.0'. This blocks modern deployment designs, so drop these functions. Probably will need some dependencies to clean up consumers of these functions. Change-Id: I711ff0c0f8d35c581d2a419debe50425ec0d51c2 --- libraries/uri.rb | 25 ------------------------- spec/uri_spec.rb | 15 --------------- 2 files changed, 40 deletions(-) diff --git a/libraries/uri.rb b/libraries/uri.rb index 7473f59d..b7cc4a0f 100644 --- a/libraries/uri.rb +++ b/libraries/uri.rb @@ -49,29 +49,4 @@ module ::Openstack paths.map! { |path| path.sub(%r{^\/+}, '').sub(%r{\/+$}, '') } leadingslash + paths.join('/') + trailingslash end - - def auth_uri_transform(auth_uri, auth_version) - case auth_version - when 'v2.0' - auth_uri - when 'v3.0' - # The auth_uri should contain /v2.0 in most cases, but if the - # auth_version is v3.0, we set it to v3. This is only necessary - # for environments that need to support V3 non-default-domain - # tokens, which is really the only reason to set version to - # something other than v2.0 (the default) - auth_uri.gsub('/v2.0', '/v3') - end - end - - # Helper for creating identity_uri value for the auth_token section - # of component config files. - # The definition of identity is: the unversioned root - # identity endpoint e.g. https://localhost:5000/ - # This method will make sure the path is removed from the uri. - def identity_uri_transform(identity_uri) - uri = ::URI.parse ::URI.encode(identity_uri.to_s) - uri.path = '/' - uri.to_s - end end diff --git a/spec/uri_spec.rb b/spec/uri_spec.rb index b5409e53..20a08944 100644 --- a/spec/uri_spec.rb +++ b/spec/uri_spec.rb @@ -88,19 +88,4 @@ describe 'Openstack uri' do ).to eq(expected) end end - - describe '#identity_uri_transform' do - it 'removes the path segment from identity endpoint' do - expect( - subject.identity_uri_transform('http://localhost:5000/v3') - ).to eq('http://localhost:5000/') - end - - it 'does not effect a valid identity endpoint' do - identity_uri = 'http://localhost:5000/' - expect( - subject.identity_uri_transform(identity_uri) - ).to eq(identity_uri) - end - end end