Skip to content

Commit

Permalink
Merge pull request #201 from open-amt-cloud-toolkit/localPasswordPrompt
Browse files Browse the repository at this point in the history
fix: ensure warning for CCM deactivation password flag
  • Loading branch information
madhavilosetty-intel authored Sep 8, 2023
2 parents 8c703aa + b1bef2a commit 35b3bce
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a name="v2.14.2"></a>
## [v2.14.2] - 2023-09-08
### Fix
- ensure warning for CCM deactivation password flag

<a name="v2.14.1"></a>
## [v2.14.1] - 2023-09-06
### Fix
Expand Down
9 changes: 8 additions & 1 deletion internal/flags/deactivate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ func TestHandleDeactivateCommandWithForce(t *testing.T) {
assert.Equal(t, expected, flags.Command)
}

func TestHandleLocalDeactivation(t *testing.T) {
func TestHandleLocalDeactivationWithPassword(t *testing.T) {
args := []string{"./rpc", "deactivate", "-local", "--password", "p@ssword"}
flags := NewFlags(args)
errCode := flags.ParseFlags()
assert.Equal(t, errCode, utils.Success)
}

func TestHandleLocalDeactivationWithoutPassword(t *testing.T) {
args := []string{"./rpc", "deactivate", "-local"}
flags := NewFlags(args)
errCode := flags.ParseFlags()
Expand Down
3 changes: 3 additions & 0 deletions internal/local/deactivate.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func (service *ProvisioningService) DeactivateACM() int {
}

func (service *ProvisioningService) DeactivateCCM() int {
if service.flags.Password != "" {
log.Warn("Password not required for CCM deactivation")
}
status, err := service.amtCommand.Unprovision()
if err != nil || status != 0 {
log.Error("Status: Failed to deactivate ", err)
Expand Down
9 changes: 8 additions & 1 deletion internal/local/deactivate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ func TestDeactivateCCM(t *testing.T) {
f.LocalConfig.Password = "P@ssw0rd"
mockControlMode = 1

t.Run("returns Success for happy path", func(t *testing.T) {
t.Run("returns Success without password", func(t *testing.T) {
f.Password = ""
lps := setupService(f)
resultCode := lps.Deactivate()
assert.Equal(t, utils.Success, resultCode)
})
t.Run("returns Success with warning, given the password", func(t *testing.T) {
f.Password = "P@ssw0rd"
lps := setupService(f)
resultCode := lps.Deactivate()
assert.Equal(t, utils.Success, resultCode)
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const (
// ProjectName is the name of the executable
ProjectName = "rpc"
// ProjectVersion is the full version of this executable
ProjectVersion = "2.14.1"
ProjectVersion = "2.14.2"
ProtocolVersion = "4.0.0"
// ClientName is the name of the exectable
ClientName = "RPC"
Expand Down

0 comments on commit 35b3bce

Please sign in to comment.