-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
New bootstraping #413
Conversation
unit/auth_helper.rb
Outdated
'type' => type, | ||
'name' => name }], | ||
'user' => { 'username' => 'admin', 'roles_links' => [], 'id' => 'user_id', 'roles' => [{ 'name' => 'admin' }], 'name' => 'admin' }, | ||
'metadata' => { 'is_admin' => 0, 'roles' => ['role_id'] } } } |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'endpoints_links' => [], | ||
'type' => type, | ||
'name' => name }], | ||
'user' => { 'username' => 'admin', 'roles_links' => [], 'id' => 'user_id', 'roles' => [{ 'name' => 'admin' }], 'name' => 'admin' }, |
There was a problem hiding this comment.
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]
unit/auth_helper.rb
Outdated
'publicURL' => 'http://localhost' }], | ||
'endpoints_links' => [], | ||
'type' => type, | ||
'name' => name }], |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'id' => 'id_endpoints', | ||
'publicURL' => 'http://localhost' }], | ||
'endpoints_links' => [], | ||
'type' => type, |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'region' => 'regionOne', | ||
'internalURL' => 'http://localhost', | ||
'id' => 'id_endpoints', | ||
'publicURL' => 'http://localhost' }], |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
{ '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' }, |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
{ 'token' => | ||
{ 'issued_at' => '2017-12-05T10:44:31.454741Z', | ||
'expires' => '2017-12-05T11:44:31Z', | ||
'id' => '4ae647d3a5294690a3c29bc658e17e26', |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
{ 'access' => | ||
{ 'token' => | ||
{ 'issued_at' => '2017-12-05T10:44:31.454741Z', | ||
'expires' => '2017-12-05T11:44:31Z', |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
def auth_response_v2(type, name) | ||
{ 'access' => | ||
{ 'token' => | ||
{ 'issued_at' => '2017-12-05T10:44:31.454741Z', |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
|
||
def auth_response_v2(type, name) | ||
{ 'access' => | ||
{ 'token' => |
There was a problem hiding this comment.
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.
Build succeeded.
|
unit/auth_helper.rb
Outdated
'name' => 'admin' | ||
}], 'name' => 'admin' | ||
}, | ||
'metadata' => { |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'type' => type, | ||
'name' => name | ||
}], | ||
'user' => { |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
}], | ||
'endpoints_links' => [], | ||
'type' => type, | ||
'name' => name |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'publicURL' => 'http://localhost' | ||
}], | ||
'endpoints_links' => [], | ||
'type' => type, |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'region' => 'regionOne', | ||
'internalURL' => 'http://localhost', | ||
'id' => 'id_endpoints', | ||
'publicURL' => 'http://localhost' |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'id' => '4ae647d3a5294690a3c29bc658e17e26', | ||
'tenant' => { | ||
'description' => 'admin tenant', | ||
'enabled' => true, |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'issued_at' => '2017-12-05T10:44:31.454741Z', | ||
'expires' => '2017-12-05T11:44:31Z', | ||
'id' => '4ae647d3a5294690a3c29bc658e17e26', | ||
'tenant' => { |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'token' => { | ||
'issued_at' => '2017-12-05T10:44:31.454741Z', | ||
'expires' => '2017-12-05T11:44:31Z', | ||
'id' => '4ae647d3a5294690a3c29bc658e17e26', |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
'access' => { | ||
'token' => { | ||
'issued_at' => '2017-12-05T10:44:31.454741Z', | ||
'expires' => '2017-12-05T11:44:31Z', |
There was a problem hiding this comment.
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.
unit/auth_helper.rb
Outdated
def auth_response_v2(type, name) | ||
{ | ||
'access' => { | ||
'token' => { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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' | ||
} | ||
], |
There was a problem hiding this comment.
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' | ||
}, | ||
{ |
There was a problem hiding this comment.
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' | ||
}, | ||
{ |
There was a problem hiding this comment.
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' | ||
}, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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]
unit/auth/token_test.rb
Outdated
|
||
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'}) |
There was a problem hiding this comment.
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]
unit/auth/token_test.rb
Outdated
|
||
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 => {}) |
There was a problem hiding this comment.
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]
unit/auth/token_test.rb
Outdated
|
||
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 => {}) |
There was a problem hiding this comment.
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]
unit/auth/token_test.rb
Outdated
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 => {}) |
There was a problem hiding this comment.
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]
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) |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
|
||
# check that the transfer object is gone on both sides | ||
[@service, other_service].each do |service| | ||
assert_nil service.transfers.get(transfer.id) |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
volume.tenant_id.wont_equal(source_tenant_id) | ||
|
||
# check that the transfer object is gone on both sides | ||
[@service, other_service].each do |service| |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
# 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) |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
|
||
# 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 |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
proc { other_service.transfers.accept(transfer_id, 'invalidauthkey') }.must_raise Excon::Errors::BadRequest | ||
|
||
# accept transfer | ||
puts 'Accepting transfer...' if ENV['DEBUG_VERBOSE'] |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
# 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 |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
|
||
# 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 |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
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 |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
# 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
|
||
# check that the transfer object is gone on both sides | ||
[@service, other_service].each do |service| | ||
assert_nil service.transfers.get(transfer.id) |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
volume.tenant_id.wont_equal(source_tenant_id) | ||
|
||
# check that the transfer object is gone on both sides | ||
[@service, other_service].each do |service| |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
# 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) |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
|
||
# 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 |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
proc { other_service.transfers.accept(transfer_id, 'invalidauthkey') }.must_raise Excon::Errors::BadRequest | ||
|
||
# accept transfer | ||
puts 'Accepting transfer...' if ENV['DEBUG_VERBOSE'] |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
# 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 |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
|
||
# 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 |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
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 |
There was a problem hiding this comment.
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.
spec/volume_spec.rb
Outdated
# 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 |
There was a problem hiding this comment.
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.
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} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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]
unit/auth/token_test.rb
Outdated
|
||
it 'when token has expired' do | ||
stub_request(:post, 'http://localhost/identity/v2.0/tokens') | ||
.to_return( |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
describe '#get' do | ||
it 'when token has not expired' do | ||
stub_request(:post, 'http://localhost/identity/v2.0/tokens') | ||
.to_return( |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
|
||
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 => {}) |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
} | ||
|
||
stub_request(:post, 'http://localhost/identity/v2.0/tokens') | ||
.with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantId\":\"tenant_id\"}}") |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
|
||
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 => {}) |
There was a problem hiding this comment.
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.
Build succeeded.
|
unit/auth/token_test.rb
Outdated
} | ||
|
||
stub_request(:post, 'http://localhost/identity/v2.0/tokens') | ||
.with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantName\":\"tenant\"}}") |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
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 => {}) |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
} | ||
|
||
stub_request(:post, 'http://localhost/identity/v2.0/tokens') | ||
.with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\ |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
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 => {}) |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
} | ||
|
||
stub_request(:post, 'http://localhost/identity/v2.0/tokens') | ||
.with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\ |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
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 => {}) |
There was a problem hiding this comment.
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.
unit/auth/token_test.rb
Outdated
|
||
it '#get_endpoint_url' do | ||
stub_request(:post, 'http://localhost/identity/v3/auth/tokens') | ||
.to_return( |
There was a problem hiding this comment.
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.
test/authenticate_tests.rb
Outdated
service = Object.new | ||
service.extend(Fog::OpenStack::Core) | ||
service.send(:setup, | ||
:openstack_auth_url => 'http://example', |
There was a problem hiding this comment.
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.
test/authenticate_tests.rb
Outdated
:openstack_api_key => 'secret', | ||
:openstack_username => 'user', | ||
:openstack_service_type => 'object-store' | ||
) |
There was a problem hiding this comment.
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.
test/authenticate_tests.rb
Outdated
service = Object.new | ||
service.extend(Fog::OpenStack::Core) | ||
service.send(:setup, | ||
:openstack_auth_url => 'http://example', |
There was a problem hiding this comment.
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.
test/authenticate_tests.rb
Outdated
:openstack_service_type => %w[network], | ||
:openstack_api_key => 'secret', | ||
:openstack_username => 'user' | ||
) |
There was a problem hiding this comment.
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.
test/authenticate_tests.rb
Outdated
service = Object.new | ||
service.extend(Fog::OpenStack::Core) | ||
service.send(:setup, | ||
:openstack_auth_url => 'http://example', |
There was a problem hiding this comment.
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.
spec/image_v2_spec.rb
Outdated
if image_id | ||
begin | ||
image_by_id = @service.images.find_by_id(image_id) | ||
rescue |
There was a problem hiding this comment.
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, _) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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]
lib/fog/openstack.rb
Outdated
# 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*)*.*$/, '/') |
There was a problem hiding this comment.
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.
Build failed.
|
if image_id | ||
begin | ||
image_by_id = @service.images.find_by_id(image_id) | ||
rescue |
There was a problem hiding this comment.
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.
lib/fog/openstack.rb
Outdated
@@ -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 |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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)}) |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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)}) |
There was a problem hiding this comment.
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.
test/authenticate_tests.rb
Outdated
} | ||
|
||
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]) |
There was a problem hiding this comment.
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.
Build succeeded.
|
Build succeeded.
|
Build failed.
|
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') |
There was a problem hiding this comment.
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]
Build succeeded.
|
Fog.credentials = {:openstack_auth_url => 'http://openstack:35357/v2.0/tokens'} | ||
identity = Fog::Identity[:openstack] | ||
creds = { | ||
:openstack_auth_url => 'http://openstack:35357', |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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.
Build succeeded.
|
Fog.credentials = {:openstack_auth_url => 'http://openstack:35357/v2.0/tokens'} | ||
identity = Fog::Identity[:openstack] | ||
creds = { | ||
:openstack_auth_url => 'http://openstack:35357', |
There was a problem hiding this comment.
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.
Build succeeded.
|
recheck |
Build succeeded.
|
There was a problem hiding this 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
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! |
Yes the path shouldn't contain 'v3' or 'v2.0' or any 'tokens/auth' or 'such `path. |
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. |
Thanks @aufi |
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:
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 underunit/auth
are about 845 lines. So altogether we're saving about 200 lines.