-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(users): add shouldResetPassword flag to user create and update
- Loading branch information
1 parent
af1c9b7
commit 0036695
Showing
8 changed files
with
54 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,21 +146,21 @@ | |
"examples": { | ||
"powershell": [ | ||
{ | ||
"description": "Create a user", | ||
"description": "Create a user and force user to change their password when logging in", | ||
"beforeEach": [ | ||
"$Username = \"testuser_\" + [guid]::NewGuid().Guid.Substring(1,10)", | ||
"$NewPassword = New-RandomPassword" | ||
], | ||
"command": "New-user -Username \"$Username\" -Email \"[email protected]\" -Password \"$NewPassword\"", | ||
"command": "New-user -Username \"$Username\" -Email \"[email protected]\" -Password \"$NewPassword\" -ShouldResetPassword", | ||
"afterEach": [ | ||
"Get-UserByName -Name \"$Username\" | Remove-User" | ||
] | ||
} | ||
], | ||
"go": [ | ||
{ | ||
"description": "Create a user", | ||
"command": "c8y users create --userName \"testuser1\" --email \"[email protected]\" --password \"a0)8k2kld9lm!\"" | ||
"description": "Create a user and force user to change their password when logging in", | ||
"command": "c8y users create --userName \"testuser1\" --email \"[email protected]\" --password 'a0)8k2kld9lm' --shouldResetPassword" | ||
}, | ||
{ | ||
"description": "Create a user using a template", | ||
|
@@ -221,6 +221,12 @@ | |
"required": false, | ||
"description": "User password. Min: 6, max: 32 characters. Only Latin1 chars allowed" | ||
}, | ||
{ | ||
"name": "shouldResetPassword", | ||
"type": "boolean", | ||
"required": false, | ||
"description": "User must reset password on next login" | ||
}, | ||
{ | ||
"name": "sendPasswordResetEmail", | ||
"type": "boolean", | ||
|
@@ -472,6 +478,12 @@ | |
"required": false, | ||
"description": "User password. Min: 6, max: 32 characters. Only Latin1 chars allowed" | ||
}, | ||
{ | ||
"name": "shouldResetPassword", | ||
"type": "boolean", | ||
"required": false, | ||
"description": "User must reset password on next login" | ||
}, | ||
{ | ||
"name": "sendPasswordResetEmail", | ||
"type": "boolean", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,16 +110,16 @@ commands: | |
powershell: New-User | ||
examples: | ||
powershell: | ||
- description: Create a user | ||
- description: Create a user and force user to change their password when logging in | ||
beforeEach: | ||
- $Username = "testuser_" + [guid]::NewGuid().Guid.Substring(1,10) | ||
- $NewPassword = New-RandomPassword | ||
command: New-user -Username "$Username" -Email "[email protected]" -Password "$NewPassword" | ||
command: New-user -Username "$Username" -Email "[email protected]" -Password "$NewPassword" -ShouldResetPassword | ||
afterEach: | ||
- Get-UserByName -Name "$Username" | Remove-User | ||
go: | ||
- description: Create a user | ||
command: c8y users create --userName "testuser1" --email "[email protected]" --password "a0)8k2kld9lm!" | ||
- description: Create a user and force user to change their password when logging in | ||
command: c8y users create --userName "testuser1" --email "[email protected]" --password 'a0)8k2kld9lm' --shouldResetPassword | ||
|
||
- description: Create a user using a template | ||
command: | | ||
|
@@ -169,6 +169,11 @@ commands: | |
required: false | ||
description: 'User password. Min: 6, max: 32 characters. Only Latin1 chars allowed' | ||
|
||
- name: shouldResetPassword | ||
type: boolean | ||
required: false | ||
description: User must reset password on next login | ||
|
||
# TODO: Only set value if it has changed! | ||
- name: sendPasswordResetEmail | ||
type: boolean | ||
|
@@ -353,6 +358,11 @@ commands: | |
required: false | ||
description: 'User password. Min: 6, max: 32 characters. Only Latin1 chars allowed' | ||
|
||
- name: shouldResetPassword | ||
type: boolean | ||
required: false | ||
description: User must reset password on next login | ||
|
||
# TODO: Only set value if it has changed! | ||
- name: sendPasswordResetEmail | ||
type: boolean | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
tests: | ||
users_create_Create a user: | ||
command: c8y users create --userName "testuser1" --email "[email protected]" --password "a0)8k2kld9lm!" | ||
users_create_Create a user and force user to change their password when logging in: | ||
command: c8y users create --userName "testuser1" --email "[email protected]" --password 'a0)8k2kld9lm' --shouldResetPassword | ||
exit-code: 0 | ||
stdout: | ||
json: | ||
body.email: [email protected] | ||
body.password: a0)8k2kld9lm! | ||
body.password: a0)8k2kld9lm | ||
body.shouldResetPassword: "true" | ||
body.userName: testuser1 | ||
method: POST | ||
path: /user/$C8Y_TENANT/users | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,9 @@ Create a new user so that they can access the tenant | |
https://reubenmiller.github.io/go-c8y-cli/docs/cli/c8y/users_create | ||
.EXAMPLE | ||
PS> New-user -Username "$Username" -Email "[email protected]" -Password "$NewPassword" | ||
PS> New-user -Username "$Username" -Email "[email protected]" -Password "$NewPassword" -ShouldResetPassword | ||
Create a user | ||
Create a user and force user to change their password when logging in | ||
#> | ||
|
@@ -58,6 +58,11 @@ Create a user | |
[string] | ||
$Password, | ||
|
||
# User must reset password on next login | ||
[Parameter()] | ||
[switch] | ||
$ShouldResetPassword, | ||
|
||
# Send password reset email to the user instead of setting a password | ||
[Parameter()] | ||
[ValidateSet('true','false')] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ Describe -Name "New-User" { | |
|
||
} | ||
|
||
It "Create a user" { | ||
$Response = PSc8y\New-user -Username "$Username" -Email "[email protected]" -Password "$NewPassword" | ||
It "Create a user and force user to change their password when logging in" { | ||
$Response = PSc8y\New-user -Username "$Username" -Email "[email protected]" -Password "$NewPassword" -ShouldResetPassword | ||
$LASTEXITCODE | Should -Be 0 | ||
$Response | Should -Not -BeNullOrEmpty | ||
} | ||
|