From b7c40f39144b955cfe7865b2ad56cdda96e497d4 Mon Sep 17 00:00:00 2001 From: Anjan Nath Date: Fri, 29 Jun 2018 14:48:59 +0530 Subject: [PATCH] Issue #2526 use subscription-manager list to check rhsm status --- pkg/minishift/registration/redhat.go | 4 ++-- pkg/minishift/registration/redhat_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/minishift/registration/redhat.go b/pkg/minishift/registration/redhat.go index 00c91786fe..5254777e30 100644 --- a/pkg/minishift/registration/redhat.go +++ b/pkg/minishift/registration/redhat.go @@ -144,10 +144,10 @@ func (registrator *RedHatRegistrator) Unregister(param *RegistrationParameters) // isRegistered returns registration state of RHSM or errors when undetermined func (registrator *RedHatRegistrator) isRegistered() (bool, error) { - if output, err := registrator.SSHCommand("sudo -E subscription-manager version"); err != nil { + if output, err := registrator.SSHCommand("sudo -E subscription-manager list"); err != nil { return false, err } else { - if !strings.Contains(output, "not registered") { + if !strings.Contains(output, "Unknown") { return true, nil } return false, nil diff --git a/pkg/minishift/registration/redhat_test.go b/pkg/minishift/registration/redhat_test.go index ba02c2ce56..f6ca3a7111 100644 --- a/pkg/minishift/registration/redhat_test.go +++ b/pkg/minishift/registration/redhat_test.go @@ -39,7 +39,7 @@ var ( func setup(t *testing.T) (registrator Registrator) { s, _ := tests.NewSSHServer() s.CommandToOutput = make(map[string]string) - s.CommandToOutput["sudo -E subscription-manager version"] = `server type: This system is currently not registered.` + s.CommandToOutput["sudo -E subscription-manager list"] = `Status: Unknown` port, err := s.Start() if err != nil { t.Fatalf("Error starting ssh server: %s", err) @@ -93,7 +93,7 @@ func TestRedHatRegistratorRegister(t *testing.T) { commander := provision.GenericSSHCommander{Driver: d} registrator := NewRedHatRegistrator(commander) - s.CommandToOutput["sudo -E subscription-manager version"] = `server type: This system is currently not registered.` + s.CommandToOutput["sudo -E subscription-manager list"] = `Status: Unknown` err = registrator.Register(param) assert.NoError(t, err, "Distribution should be able to register") _, ok := s.Commands[expectedCMDRegistration] @@ -116,7 +116,7 @@ func TestRedHatRegistratorUnregister(t *testing.T) { commander := provision.GenericSSHCommander{Driver: d} registrator := NewRedHatRegistrator(commander) - s.CommandToOutput["sudo -E subscription-manager version"] = `server type: RedHat Subscription Management` + s.CommandToOutput["sudo -E subscription-manager list"] = `Status: Registered` err = registrator.Unregister(param) assert.NoError(t, err, "Distribution should be able to unregister") _, ok := s.Commands[expectedCMDUnregistration]