Skip to content

Commit

Permalink
Forbid de-registration for on-demand Public Cloud instances
Browse files Browse the repository at this point in the history
  • Loading branch information
ikapelyukhin committed Nov 5, 2019
1 parent babb4d0 commit 6f26802
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 19 deletions.
32 changes: 18 additions & 14 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-05-16 15:25:20 +0200 using RuboCop version 0.53.0.
# on 2019-11-05 11:24:43 +0100 using RuboCop version 0.53.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -46,6 +46,11 @@ Lint/UnneededSplatExpansion:
Exclude:
- 'spec/connect/yast_spec.rb'

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 163

# Offense count: 1
Naming/MemoizedInstanceVariableName:
Exclude:
Expand Down Expand Up @@ -85,7 +90,7 @@ RSpec/DescribeSymbol:
Exclude:
- 'spec/connect/api_spec.rb'

# Offense count: 33
# Offense count: 32
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Expand All @@ -106,7 +111,7 @@ RSpec/DescribedClass:
- 'spec/connect/zypper_spec.rb'
- 'spec/toolkit/system_calls_spec.rb'

# Offense count: 18
# Offense count: 19
RSpec/EmptyLineAfterFinalLet:
Exclude:
- 'spec/connect/cli_spec.rb'
Expand Down Expand Up @@ -143,7 +148,7 @@ RSpec/ExampleLength:
- 'spec/features/**/*'
- 'spec/connect/status_spec.rb'

# Offense count: 29
# Offense count: 27
# Configuration parameters: CustomTransform, IgnoredWords.
RSpec/ExampleWording:
Exclude:
Expand All @@ -158,18 +163,17 @@ RSpec/ExpectOutput:
Exclude:
- 'spec/connect/zypper_spec.rb'

# Offense count: 28
# Offense count: 29
# Configuration parameters: CustomTransform, IgnoreMethods.
RSpec/FilePath:
Enabled: false

# Offense count: 14
# Offense count: 12
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, each, example
RSpec/HookArgument:
Exclude:
- 'spec/connect/hwinfo/arm64_spec.rb'
- 'spec/connect/hwinfo/base_spec.rb'
- 'spec/connect/hwinfo/s390_spec.rb'
- 'spec/connect/hwinfo/x86_spec.rb'
- 'spec/connect/system_spec.rb'
Expand All @@ -193,7 +197,7 @@ RSpec/MessageChain:
- 'spec/connect/status_spec.rb'
- 'spec/connect/zypper/product_status_spec.rb'

# Offense count: 284
# Offense count: 322
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Expand All @@ -205,11 +209,11 @@ RSpec/MultipleDescribes:
- 'spec/connect/logger_spec.rb'
- 'spec/toolkit/cast_spec.rb'

# Offense count: 173
# Offense count: 186
RSpec/MultipleExpectations:
Max: 8
Max: 9

# Offense count: 485
# Offense count: 512
RSpec/NamedSubject:
Enabled: false

Expand Down Expand Up @@ -240,7 +244,7 @@ RSpec/SingleArgumentMessageChain:
Exclude:
- 'spec/connect/status_spec.rb'

# Offense count: 89
# Offense count: 94
RSpec/SubjectStub:
Exclude:
- 'spec/connect/client_spec.rb'
Expand All @@ -255,7 +259,7 @@ RSpec/SubjectStub:
- 'spec/toolkit/curlrc_dotfile_spec.rb'
- 'spec/toolkit/system_calls_spec.rb'

# Offense count: 28
# Offense count: 30
# Configuration parameters: IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
Expand Down Expand Up @@ -396,7 +400,7 @@ Style/RescueStandardError:
- 'lib/suse/connect/hwinfo/x86.rb'
- 'lib/suse/toolkit/utilities.rb'

# Offense count: 7
# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Expand Down
4 changes: 4 additions & 0 deletions lib/suse/connect/client.rb
Expand Up @@ -52,6 +52,10 @@ def register_product(product, install_release_package = true)
#
# @returns: Empty body and 204 status code
def deregister!
if File.exist?('/usr/sbin/registercloudguest')
raise UnsupportedOperation,
'De-registration is disabled for on-demand instances. Use `registercloudguest --clean` instead.'
end
raise SystemNotRegisteredError unless registered?
print_information :deregister
if @config.product
Expand Down
2 changes: 1 addition & 1 deletion lib/suse/connect/version.rb
@@ -1,5 +1,5 @@
module SUSE
module Connect
VERSION = '0.3.23'
VERSION = '0.3.24'
end
end
6 changes: 6 additions & 0 deletions package/SUSEConnect.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Nov 5 12:08:18 UTC 2019 - Ivan Kapelyukhin <ikapelyukhin@suse.com>

- Update to 0.3.24
- Forbid de-registration for on-demand Public Cloud instances (bsc#1155911)

-------------------------------------------------------------------
Mon Oct 14 13:16:03 UTC 2019 - Thomas Schmidt <tschmidt@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/SUSEConnect.spec
Expand Up @@ -17,7 +17,7 @@


Name: SUSEConnect
Version: 0.3.23
Version: 0.3.24
Release: 0
%define mod_name suse-connect
%define mod_full_name %{mod_name}-%{version}
Expand Down
13 changes: 10 additions & 3 deletions spec/connect/client_spec.rb
Expand Up @@ -656,8 +656,6 @@
end
subject
end

# rubocop:disable RSpec/MultipleExpectations
it 'reports about ongoing action' do
expect(string_logger).to receive(:info).with("\e[1mDeregistering system from SUSE Customer Center\e[22m")
expect(string_logger).to receive(:info).with("\nDeactivating 4-2-Extension 83 x86_64 ...")
Expand All @@ -670,7 +668,6 @@
expect(string_logger).to receive(:info).with("\e[1m\e[32mSuccessfully deregistered system\n\e[0m\e[22m")
subject
end
# rubocop:enable RSpec/MultipleExpectations
end

context 'for single product' do
Expand Down Expand Up @@ -716,6 +713,16 @@

it { expect { subject }.to raise_error(::SUSE::Connect::SystemNotRegisteredError) }
end


context 'when running on on-demand instance' do
before do
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with('/usr/sbin/registercloudguest').and_return(true)
end

it { expect { subject }.to raise_error(::SUSE::Connect::UnsupportedOperation) }
end
end

describe '#flatten_tree' do
Expand Down

0 comments on commit 6f26802

Please sign in to comment.