Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New bootstraping #413

Merged
merged 16 commits into from
Aug 28, 2018
Merged

New bootstraping #413

merged 16 commits into from
Aug 28, 2018

Conversation

gildub
Copy link
Collaborator

@gildub gildub commented Aug 15, 2018

In short, it removes as much as possible any "path" tempering.

Authentication returns a token and its catalog along with all services endpoints available.
When a specific endpoint (among all candidates) is identified, it must be used as it is, without any changes to its path.

There are 2 types of endpoints:

The difference between those 2 types determines if a prefix is sent along a request.
For example, Nova (https://developer.openstack.org/api-ref/compute/) doesn't prefix any request, beause the endpoint is versionned"

Conversely when a endpoint is "version less" the API provides the version, for example Neutron (https://developer.openstack.org/api-ref/network/v2/)

The default, from now, is to assume a version less endpoint and therefore no prefix is added.
For service with "versioned" endpoint, the service class, for example Fog::Network::OpenStack, will provide the prefix:

   def default_path_prefix
          'v2.0'
    end

Note for reviewers: I'm sorry about this huge Pull Request. I've broken down the effort in multiple commits, although the second one is still big. If that causes too much headache we could eventually use a feature branch.

Note: The new authentication, token and catalog approach is under lib/fog/openstack/auth and takes about 430 lines of code. The respective unit tests under unit/auth are about 845 lines. So altogether we're saving about 200 lines.

'type' => type,
'name' => name }],
'user' => { 'username' => 'admin', 'roles_links' => [], 'id' => 'user_id', 'roles' => [{ 'name' => 'admin' }], 'name' => 'admin' },
'metadata' => { 'is_admin' => 0, 'roles' => ['role_id'] } } }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
Layout/SpaceInsideHashLiteralBraces: Space inside { detected.
Layout/SpaceInsideHashLiteralBraces: Space inside } detected.

'endpoints_links' => [],
'type' => type,
'name' => name }],
'user' => { 'username' => 'admin', 'roles_links' => [], 'id' => 'user_id', 'roles' => [{ 'name' => 'admin' }], 'name' => 'admin' },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
Layout/SpaceInsideHashLiteralBraces: Space inside { detected.
Layout/SpaceInsideHashLiteralBraces: Space inside } detected.
Metrics/LineLength: Line is too long. [137/120]

'publicURL' => 'http://localhost' }],
'endpoints_links' => [],
'type' => type,
'name' => name }],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
Layout/SpaceInsideHashLiteralBraces: Space inside } detected.

'id' => 'id_endpoints',
'publicURL' => 'http://localhost' }],
'endpoints_links' => [],
'type' => type,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

'region' => 'regionOne',
'internalURL' => 'http://localhost',
'id' => 'id_endpoints',
'publicURL' => 'http://localhost' }],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
Layout/SpaceInsideHashLiteralBraces: Space inside } detected.

{ 'issued_at' => '2017-12-05T10:44:31.454741Z',
'expires' => '2017-12-05T11:44:31Z',
'id' => '4ae647d3a5294690a3c29bc658e17e26',
'tenant' => { 'description' => 'admin tenant', 'enabled' => true, 'id' => 'tenant_id', 'name' => 'admin' },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
Layout/SpaceInsideHashLiteralBraces: Space inside { detected.
Layout/SpaceInsideHashLiteralBraces: Space inside } detected.

{ 'token' =>
{ 'issued_at' => '2017-12-05T10:44:31.454741Z',
'expires' => '2017-12-05T11:44:31Z',
'id' => '4ae647d3a5294690a3c29bc658e17e26',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

{ 'access' =>
{ 'token' =>
{ 'issued_at' => '2017-12-05T10:44:31.454741Z',
'expires' => '2017-12-05T11:44:31Z',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

def auth_response_v2(type, name)
{ 'access' =>
{ 'token' =>
{ 'issued_at' => '2017-12-05T10:44:31.454741Z',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceInsideHashLiteralBraces: Space inside { detected.


def auth_response_v2(type, name)
{ 'access' =>
{ 'token' =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceInsideHashLiteralBraces: Space inside { detected.
Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 15, 2018

Build succeeded.

'name' => 'admin'
}], 'name' => 'admin'
},
'metadata' => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

'type' => type,
'name' => name
}],
'user' => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

}],
'endpoints_links' => [],
'type' => type,
'name' => name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

'publicURL' => 'http://localhost'
}],
'endpoints_links' => [],
'type' => type,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

'region' => 'regionOne',
'internalURL' => 'http://localhost',
'id' => 'id_endpoints',
'publicURL' => 'http://localhost'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

'id' => '4ae647d3a5294690a3c29bc658e17e26',
'tenant' => {
'description' => 'admin tenant',
'enabled' => true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

'issued_at' => '2017-12-05T10:44:31.454741Z',
'expires' => '2017-12-05T11:44:31Z',
'id' => '4ae647d3a5294690a3c29bc658e17e26',
'tenant' => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

'token' => {
'issued_at' => '2017-12-05T10:44:31.454741Z',
'expires' => '2017-12-05T11:44:31Z',
'id' => '4ae647d3a5294690a3c29bc658e17e26',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

'access' => {
'token' => {
'issued_at' => '2017-12-05T10:44:31.454741Z',
'expires' => '2017-12-05T11:44:31Z',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

def auth_response_v2(type, name)
{
'access' => {
'token' => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

}
end

def auth_response_v2(type, name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/MethodLength: Method has too many lines. [41/25]

'interface' => 'admin',
'id' => 'id_endpoint_admin'
}
],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/MultilineArrayBraceLayout: Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.

'interface' => 'public',
'id' => 'id_endpoint_public'
},
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignArray: Align the elements of an array literal if they span more than one line.

'interface' => 'internal',
'id' => 'id_endpoint_internal'
},
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignArray: Align the elements of an array literal if they span more than one line.

'region' => 'regionOne',
'interface' => 'internal',
'id' => 'id_endpoint_internal'
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentHash: Indent the right brace the same as the start of the line where the left brace is.

@@ -0,0 +1,101 @@
def auth_response_v3(type, name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/MethodLength: Method has too many lines. [55/25]


it '#get_endpoint_url' do
stub_request(:post, 'http://localhost/identity/v2.0/tokens').
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [144/120]


it '#catalog' do
stub_request(:post, 'http://localhost/identity/v2.0/tokens').
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [150/120]


it 'when token has expired' do
stub_request(:post, 'http://localhost/identity/v2.0/tokens').
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_expired\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [155/120]

describe '#get' do
it 'when token has not expired' do
stub_request(:post, 'http://localhost/identity/v2.0/tokens').
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_not_expired\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [159/120]

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 16, 2018

Build succeeded.

@@ -2,12 +2,13 @@

describe "when microversion" do
before do
@microversion_tester = TestMicroVersion.new
@microversion_tester = Object.new
@microversion_tester = extend(Fog::OpenStack::Core)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/MixinUsage: extend is used at the top level. Use inside class or module.


# check that the transfer object is gone on both sides
[@service, other_service].each do |service|
assert_nil service.transfers.get(transfer.id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.

volume.tenant_id.wont_equal(source_tenant_id)

# check that the transfer object is gone on both sides
[@service, other_service].each do |service|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

# As noted above, both users seem to be able to see the volume at all times.
# Check change of ownership by looking at the tenant_id, instead.
volume.tenant_id.must_match(/^[0-9a-f-]+$/) # should look like a UUID
volume.tenant_id.wont_equal(source_tenant_id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.


# As noted above, both users seem to be able to see the volume at all times.
# Check change of ownership by looking at the tenant_id, instead.
volume.tenant_id.must_match(/^[0-9a-f-]+$/) # should look like a UUID

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

proc { other_service.transfers.accept(transfer_id, 'invalidauthkey') }.must_raise Excon::Errors::BadRequest

# accept transfer
puts 'Accepting transfer...' if ENV['DEBUG_VERBOSE']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

# check that accept_transfer fails without valid transfer ID and auth key
bogus_uuid = 'ec8ff7e8-81e2-4e12-b9fb-3e8890612c2d' # from Fog::UUID.uuid, but fixed to play nice with VCR
proc { other_service.transfers.accept(bogus_uuid, auth_key) }.must_raise Fog::Volume::OpenStack::NotFound
proc { other_service.transfers.accept(transfer_id, 'invalidauthkey') }.must_raise Excon::Errors::BadRequest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.


# check that accept_transfer fails without valid transfer ID and auth key
bogus_uuid = 'ec8ff7e8-81e2-4e12-b9fb-3e8890612c2d' # from Fog::UUID.uuid, but fixed to play nice with VCR
proc { other_service.transfers.accept(bogus_uuid, auth_key) }.must_raise Fog::Volume::OpenStack::NotFound

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

source_tenant_id = volume.tenant_id

# check that accept_transfer fails without valid transfer ID and auth key
bogus_uuid = 'ec8ff7e8-81e2-4e12-b9fb-3e8890612c2d' # from Fog::UUID.uuid, but fixed to play nice with VCR

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

# The recipient can inexplicably see the volume even before the
# transfer, so to confirm that the transfer happens, we record its tenant ID.
volume.tenant_id.must_match(/^[0-9a-f-]+$/) # should look like a UUID
source_tenant_id = volume.tenant_id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

@@ -2,12 +2,13 @@

describe "when microversion" do
before do
@microversion_tester = TestMicroVersion.new
@microversion_tester = Object.new
@microversion_tester = extend(Fog::OpenStack::Core)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/MixinUsage: extend is used at the top level. Use inside class or module.


# check that the transfer object is gone on both sides
[@service, other_service].each do |service|
assert_nil service.transfers.get(transfer.id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.

volume.tenant_id.wont_equal(source_tenant_id)

# check that the transfer object is gone on both sides
[@service, other_service].each do |service|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

# As noted above, both users seem to be able to see the volume at all times.
# Check change of ownership by looking at the tenant_id, instead.
volume.tenant_id.must_match(/^[0-9a-f-]+$/) # should look like a UUID
volume.tenant_id.wont_equal(source_tenant_id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.


# As noted above, both users seem to be able to see the volume at all times.
# Check change of ownership by looking at the tenant_id, instead.
volume.tenant_id.must_match(/^[0-9a-f-]+$/) # should look like a UUID

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

proc { other_service.transfers.accept(transfer_id, 'invalidauthkey') }.must_raise Excon::Errors::BadRequest

# accept transfer
puts 'Accepting transfer...' if ENV['DEBUG_VERBOSE']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

# check that accept_transfer fails without valid transfer ID and auth key
bogus_uuid = 'ec8ff7e8-81e2-4e12-b9fb-3e8890612c2d' # from Fog::UUID.uuid, but fixed to play nice with VCR
proc { other_service.transfers.accept(bogus_uuid, auth_key) }.must_raise Fog::Volume::OpenStack::NotFound
proc { other_service.transfers.accept(transfer_id, 'invalidauthkey') }.must_raise Excon::Errors::BadRequest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.


# check that accept_transfer fails without valid transfer ID and auth key
bogus_uuid = 'ec8ff7e8-81e2-4e12-b9fb-3e8890612c2d' # from Fog::UUID.uuid, but fixed to play nice with VCR
proc { other_service.transfers.accept(bogus_uuid, auth_key) }.must_raise Fog::Volume::OpenStack::NotFound

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

source_tenant_id = volume.tenant_id

# check that accept_transfer fails without valid transfer ID and auth key
bogus_uuid = 'ec8ff7e8-81e2-4e12-b9fb-3e8890612c2d' # from Fog::UUID.uuid, but fixed to play nice with VCR

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

# The recipient can inexplicably see the volume even before the
# transfer, so to confirm that the transfer happens, we record its tenant ID.
volume.tenant_id.must_match(/^[0-9a-f-]+$/) # should look like a UUID
source_tenant_id = volume.tenant_id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationConsistency: Inconsistent indentation detected.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 16, 2018

Build succeeded.

@@ -123,8 +119,7 @@ def credentials
{:provider => 'openstack',
:openstack_auth_url => @openstack_auth_uri.to_s,
:openstack_auth_token => @auth_token,
:openstack_management_url => @openstack_management_url,
:openstack_identity_endpoint => @openstack_identity_public_endpoint}
:openstack_management_url => @openstack_management_url}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

}
end

def set(response)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/AbcSize: Assignment Branch Condition size for set is too high. [17.49/15]

include Fog::OpenStack::Auth::Token
attr_reader :tenant

def credentials

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/AbcSize: Assignment Branch Condition size for credentials is too high. [16.31/15]
Metrics/PerceivedComplexity: Perceived complexity for credentials is too high. [8/7]

end
end

def build_credentials(auth)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/AbcSize: Assignment Branch Condition size for build_credentials is too high. [41.7/15]
Metrics/CyclomaticComplexity: Cyclomatic complexity for build_credentials is too high. [14/6]
Metrics/MethodLength: Method has too many lines. [44/25]
Metrics/PerceivedComplexity: Perceived complexity for build_credentials is too high. [18/7]

@persistent = options[:persistent] || false
end

def authenticate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/AbcSize: Assignment Branch Condition size for authenticate is too high. [22.23/15]
Metrics/CyclomaticComplexity: Cyclomatic complexity for authenticate is too high. [7/6]
Metrics/MethodLength: Method has too many lines. [26/25]
Metrics/PerceivedComplexity: Perceived complexity for authenticate is too high. [9/7]


it 'when token has expired' do
stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.to_return(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

describe '#get' do
it 'when token has not expired' do
stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.to_return(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.


stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantId\":\"tenant_id\"}}")
.to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

}

stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantId\":\"tenant_id\"}}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.


stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantName\":\"tenant\"}}")
.to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 16, 2018

Build succeeded.

}

stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantName\":\"tenant\"}}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\
\"tenantId\":\"tenant_id\"}}")
.to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

}

stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\
\"tenantName\":\"tenant\"}}")
.to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

}

stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

describe '#new' do
it 'fails when missing credentials' do
stub_request(:post, 'http://localhost/identity/v2.0/tokens')
.to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.


it '#get_endpoint_url' do
stub_request(:post, 'http://localhost/identity/v3/auth/tokens')
.to_return(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

service = Object.new
service.extend(Fog::OpenStack::Core)
service.send(:setup,
:openstack_auth_url => 'http://example',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignParameters: Align the parameters of a method call if they span more than one line.

:openstack_api_key => 'secret',
:openstack_username => 'user',
:openstack_service_type => 'object-store'
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/ClosingParenthesisIndentation: Align ) with (.
Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the same line as the last argument when opening brace is on the same line as the first argument.

service = Object.new
service.extend(Fog::OpenStack::Core)
service.send(:setup,
:openstack_auth_url => 'http://example',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignParameters: Align the parameters of a method call if they span more than one line.

:openstack_service_type => %w[network],
:openstack_api_key => 'secret',
:openstack_username => 'user'
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/ClosingParenthesisIndentation: Align ) with (.
Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the same line as the last argument when opening brace is on the same line as the first argument.

service = Object.new
service.extend(Fog::OpenStack::Core)
service.send(:setup,
:openstack_auth_url => 'http://example',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignParameters: Align the parameters of a method call if they span more than one line.

if image_id
begin
image_by_id = @service.images.find_by_id(image_id)
rescue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RescueStandardError: Avoid rescuing without specifying an error class.

end
end

def endpoint_url(endpoint, _)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.

@payload = payload
end

def get_endpoint_url(names, interfaces, region = nil)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/PerceivedComplexity: Perceived complexity for get_endpoint_url is too high. [8/7]

# Clear version suffix from path
# This is needed because when catalog endpoint is not top level
# or '/' to allow version discovery
path = uri.path.gsub(/\/v([1-9]+\d*)(\.[1-9]+\d*)*.*$/, '/')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RegexpLiteral: Use %r around regular expression.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 16, 2018

Build failed.

if image_id
begin
image_by_id = @service.images.find_by_id(image_id)
rescue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RescueStandardError: Avoid rescuing without specifying an error class.

@@ -566,27 +153,21 @@ def self.get_supported_microversion(supported_versions, uri, auth_token, connect

# CGI.escape, but without special treatment on spaces
def self.escape(str, extra_exclude_chars = '')
str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do
str.gsub(%r{([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)}) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RegexpLiteral: Use // around regular expression.

:openstack_tenant => 'admin',
:openstack_api_key => 'secret',
:openstack_username => 'user',
:openstack_service_type => 'compute')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

@@ -178,39 +178,21 @@

Excon.stub(
{:method => 'POST', :path => "/v2.0/tokens"},
{:status => 200, :body => Fog::JSON.encode(body_clone)}
)
{:status => 200, :body => Fog::JSON.encode(body_clone)})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/BracesAroundHashParameters: Redundant curly braces around a hash parameter.
Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

:openstack_tenant => 'admin',
:openstack_api_key => 'secret',
:openstack_username => 'user',
:openstack_service_type => 'object-store')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

:openstack_tenant => 'admin',
:openstack_service_type => %w[network],
:openstack_api_key => 'secret',
:openstack_username => 'user')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

{:status => 200, :body => Fog::JSON.encode(@body)}
)

{:status => 200, :body => Fog::JSON.encode(@body)})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/BracesAroundHashParameters: Redundant curly braces around a hash parameter.
Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

}

assert(expected) do
Fog::OpenStack.authenticate_v2(
:openstack_auth_uri => URI('http://example/v2.0/tokens'),
:openstack_tenant => 'admin',
:openstack_service_type => %w[compute]
)
:openstack_service_type => %w[compute])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 16, 2018

Build succeeded.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 17, 2018

Build succeeded.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 17, 2018

Build failed.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 17, 2018

Build succeeded.

@@ -94,7 +94,7 @@ def create_server(name, image_ref, flavor_ref, options = {})
response.status = 202

server_id = Fog::Mock.random_numbers(6).to_s
identity = Fog::Identity::OpenStack.new :openstack_auth_url => credentials[:openstack_auth_url]
identity = Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url], :openstack_api_version => 'v2.0')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [140/120]

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 21, 2018

Build succeeded.

Fog.credentials = {:openstack_auth_url => 'http://openstack:35357/v2.0/tokens'}
identity = Fog::Identity[:openstack]
creds = {
:openstack_auth_url => 'http://openstack:35357',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

Fog.credentials = {:openstack_auth_url => 'http://openstack:35357/v2.0/tokens'}
identity = Fog::Identity[:openstack]
creds = {
:openstack_auth_url => 'http://openstack:35357',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

:openstack_tenant => 'admin',
:openstack_service_type => %w[compute]
)
:openstack_service_type => %w[compute])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 21, 2018

Build succeeded.

Fog.credentials = {:openstack_auth_url => 'http://openstack:35357/v2.0/tokens'}
identity = Fog::Identity[:openstack]
creds = {
:openstack_auth_url => 'http://openstack:35357',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 22, 2018

Build succeeded.

@liusheng
Copy link

recheck

@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 23, 2018

Build succeeded.

Copy link
Contributor

@Ladas Ladas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 looks great, I like the idea but I haven't tested it

@aufi can you test it? We should probably bump a minor version releasing this

@aufi
Copy link
Member

aufi commented Aug 27, 2018

Tested manually on Queens Packstack installation with some of examples/ scripts and does not work for me.

Example for https://github.com/fog/fog-openstack/blob/master/examples/metric/basics.rb#L4

Works good if AUTH_URL contains endpoint without path. Fails if a path is present, see http://paste.openstack.org/show/728812/

If the I tested it in wrong way, please, let me know, thanks!

@gildub
Copy link
Collaborator Author

gildub commented Aug 27, 2018

@aufi,

Yes the path shouldn't contain 'v3' or 'v2.0' or any 'tokens/auth' or 'such `path.
The default endpoint provided by Openstack identity should work assuming it's version less.

@aufi
Copy link
Member

aufi commented Aug 28, 2018

Thanks Gilles for the PR, I think it is a big step forward, I'm going to merge it.

As discussed, error with path in AUTH_URL can be addressed in follow-up PR.

@aufi aufi merged commit d4ac99c into fog:master Aug 28, 2018
@gildub gildub deleted the new-bootstraping branch August 28, 2018 08:09
@gildub
Copy link
Collaborator Author

gildub commented Aug 28, 2018

Thanks @aufi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants