Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
cliSettings: You need to change on the sametime userName and Password...
Browse files Browse the repository at this point in the history
Bug or feature ?
  • Loading branch information
alagoutte committed Feb 5, 2018
1 parent 7aac57a commit bc346a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 7 additions & 3 deletions module/PowerNSX.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -13841,10 +13841,14 @@ function Set-NsxEdge {

#cliSettings
if ( $PsBoundParameters.ContainsKey('userName') ) {
if ( invoke-xpathquery -node $_Edge -querymethod SelectSingleNode -Query "child::cliSettings/userName" ) {
$_Edge.cliSettings.username = $userName
if ( $PsBoundParameters.ContainsKey('password') ) {
if ( invoke-xpathquery -node $_Edge -querymethod SelectSingleNode -Query "child::cliSettings/userName" ) {
$_Edge.cliSettings.username = $userName
} else {
Add-XmlElement -xmlroot $_Edge.cliSettings -xmlElementName "userName" -xmlElementText $userName
}
} else {
Add-XmlElement -xmlroot $_Edge.cliSettings -xmlElementName "userName" -xmlElementText $userName
throw "You need to specify a password for change username..."
}
}

Expand Down
11 changes: 4 additions & 7 deletions tests/integration/04.Edge.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,12 @@ Describe "Edge" {
$edge.cliSettings.remoteAccess | should be "true"
}

it "Change (SSH) username via Set-NsxEdge" {
Get-NsxEdge $name | Set-NsxEdge -userName powernsxviasetnsxedge -confirm:$false
it "Change (SSH) username (and Password) via Set-NsxEdge" {
#it is mandatory to change username (and Password) on the same time (bug or feature ?)
Get-NsxEdge $name | Set-NsxEdge -userName powernsxviasetnsxedge -Password "Vmware1!Vmware1!" -confirm:$false
$edge = Get-NsxEdge $name
$edge.cliSettings.userName | should be "powernsxviasetnsxedge"
#It is impossible to check if the password is modified...
}

it "Change Password Expiry via Set-NsxEdge" {
Expand All @@ -751,11 +753,6 @@ Describe "Edge" {
$edge = Get-NsxEdge $name
$edge.cliSettings.sshLoginBannerText | should be "Secured by Set-NsxEdge"
}

it "Change Password via Set-NsxEdge" {
Get-NsxEdge $name | Set-NsxEdge -Password "Vmware1!Vmware1!" -confirm:$false
#There is no really check if the value is changed...
}
}

Context "Misc" {
Expand Down

0 comments on commit bc346a6

Please sign in to comment.