-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from Tinyblargon/CLI-Overhaul
Cli overhaul: user password change
- Loading branch information
Showing
3 changed files
with
114 additions
and
59 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
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 |
---|---|---|
|
@@ -2,29 +2,30 @@ package cli_user_test | |
|
||
import ( | ||
"testing" | ||
|
||
_ "github.com/Telmate/proxmox-api-go/cli/command/commands" | ||
cliTest "github.com/Telmate/proxmox-api-go/test/cli" | ||
) | ||
|
||
func Test_User_0_Cleanup(t *testing.T){ | ||
func Test_User_0_Cleanup(t *testing.T) { | ||
Test := cliTest.Test{ | ||
ReqErr: true, | ||
ReqErr: true, | ||
ErrContains: "test-user0@pve", | ||
Args: []string{"-i","delete","user","test-user0@pve"}, | ||
Args: []string{"-i", "delete", "user", "test-user0@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
// Set groups | ||
|
||
func Test_User_0_Set_Full_With_Password_Set(t *testing.T){ | ||
func Test_User_0_Set_Full_With_Password_Set(t *testing.T) { | ||
Test := cliTest.Test{ | ||
InputJson: ` | ||
{ | ||
"comment": "this is a comment", | ||
"email": "[email protected]", | ||
"enable": true, | ||
"expire": 99999999, | ||
"expire": 253370811600, | ||
"firstname": "Bruce", | ||
"lastname": "Wayne", | ||
"groups": [ | ||
|
@@ -33,17 +34,36 @@ func Test_User_0_Set_Full_With_Password_Set(t *testing.T){ | |
}`, | ||
Expected: "(test-user0@pve)", | ||
Contains: true, | ||
Args: []string{"-i","set","user","test-user0@pve","Enter123!"}, | ||
Args: []string{"-i", "set", "user", "test-user0@pve", "Enter123!"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_User_0_Login_Password_Set(t *testing.T) { | ||
cliTest.SetEnvironmentVariables() | ||
Test := cliTest.LoginTest{ | ||
UserID: "test-user0@pve", | ||
UserID: "test-user0@pve", | ||
Password: "Enter123!", | ||
ReqErr: false, | ||
ReqErr: false, | ||
} | ||
Test.Login(t) | ||
} | ||
|
||
func Test_User_0_Change_Password(t *testing.T) { | ||
Test := cliTest.Test{ | ||
Expected: "(test-user0@pve)", | ||
Contains: true, | ||
Args: []string{"-i", "set", "user", "test-user0@pve", "aBc123!"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_User_0_Login_Password_Changed(t *testing.T) { | ||
cliTest.SetEnvironmentVariables() | ||
Test := cliTest.LoginTest{ | ||
UserID: "test-user0@pve", | ||
Password: "aBc123!", | ||
ReqErr: false, | ||
} | ||
Test.Login(t) | ||
} | ||
|
@@ -57,17 +77,17 @@ func Test_User_0_Get_Full(t *testing.T) { | |
"userid": "test-user0@pve", | ||
"email": "[email protected]", | ||
"enable": true, | ||
"expire": 99999999, | ||
"expire": 253370811600, | ||
"firstname": "Bruce", | ||
"keys": "2fa key", | ||
"lastname": "Wayne" | ||
}`, | ||
Args: []string{"-i","get","user","test-user0@pve"}, | ||
Args: []string{"-i", "get", "user", "test-user0@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_User_0_Set_Empty(t *testing.T){ | ||
func Test_User_0_Set_Empty(t *testing.T) { | ||
Test := cliTest.Test{ | ||
InputJson: ` | ||
{ | ||
|
@@ -83,7 +103,7 @@ func Test_User_0_Set_Empty(t *testing.T){ | |
}`, | ||
Expected: "(test-user0@pve)", | ||
Contains: true, | ||
Args: []string{"-i","set","user","test-user0@pve"}, | ||
Args: []string{"-i", "set", "user", "test-user0@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
@@ -97,16 +117,16 @@ func Test_User_0_Get_Empty(t *testing.T) { | |
"enable": false, | ||
"expire": 0 | ||
}`, | ||
Args: []string{"-i","get","user","test-user0@pve"}, | ||
Args: []string{"-i", "get", "user", "test-user0@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_User_0_Delete(t *testing.T){ | ||
func Test_User_0_Delete(t *testing.T) { | ||
Test := cliTest.Test{ | ||
Expected: "", | ||
ReqErr: false, | ||
Args: []string{"-i","delete","user","test-user0@pve"}, | ||
ReqErr: false, | ||
Args: []string{"-i", "delete", "user", "test-user0@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} |
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 |
---|---|---|
|
@@ -2,20 +2,21 @@ package cli_user_test | |
|
||
import ( | ||
"testing" | ||
|
||
_ "github.com/Telmate/proxmox-api-go/cli/command/commands" | ||
cliTest "github.com/Telmate/proxmox-api-go/test/cli" | ||
) | ||
|
||
func Test_User_1_Cleanup(t *testing.T){ | ||
func Test_User_1_Cleanup(t *testing.T) { | ||
Test := cliTest.Test{ | ||
ReqErr: true, | ||
ReqErr: true, | ||
ErrContains: "test-user1@pve", | ||
Args: []string{"-i","delete","user","test-user1@pve"}, | ||
Args: []string{"-i", "delete", "user", "test-user1@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_User_1_Set_Empty_Without_Password(t *testing.T){ | ||
func Test_User_1_Set_Empty_Without_Password(t *testing.T) { | ||
Test := cliTest.Test{ | ||
InputJson: ` | ||
{ | ||
|
@@ -24,17 +25,17 @@ func Test_User_1_Set_Empty_Without_Password(t *testing.T){ | |
}`, | ||
Expected: "(test-user1@pve)", | ||
Contains: true, | ||
Args: []string{"-i","set","user","test-user1@pve"}, | ||
Args: []string{"-i", "set", "user", "test-user1@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_User_1_Login_Password_Not_Set(t *testing.T) { | ||
cliTest.SetEnvironmentVariables() | ||
Test := cliTest.LoginTest{ | ||
UserID: "test-user1@pve", | ||
UserID: "test-user1@pve", | ||
Password: "Enter123!", | ||
ReqErr: true, | ||
ReqErr: true, | ||
} | ||
Test.Login(t) | ||
} | ||
|
@@ -48,19 +49,19 @@ func Test_User_1_Get_Empty(t *testing.T) { | |
"enable": false, | ||
"expire": 0 | ||
}`, | ||
Args: []string{"-i","get","user","test-user1@pve"}, | ||
Args: []string{"-i", "get", "user", "test-user1@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_User_1_Set_Full_With_Password(t *testing.T){ | ||
func Test_User_1_Set_Full_With_Password(t *testing.T) { | ||
Test := cliTest.Test{ | ||
InputJson: ` | ||
{ | ||
"comment": "this is a comment", | ||
"email": "[email protected]", | ||
"enable": true, | ||
"expire": 99999999, | ||
"expire": 253370811600, | ||
"firstname": "Bruce", | ||
"lastname": "Wayne", | ||
"groups": [ | ||
|
@@ -69,17 +70,17 @@ func Test_User_1_Set_Full_With_Password(t *testing.T){ | |
}`, | ||
Expected: "(test-user1@pve)", | ||
Contains: true, | ||
Args: []string{"-i","set","user","test-user1@pve","Enter123!"}, | ||
Args: []string{"-i", "set", "user", "test-user1@pve", "Enter123!"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_User_1_Login_Password_Set(t *testing.T) { | ||
cliTest.SetEnvironmentVariables() | ||
Test := cliTest.LoginTest{ | ||
UserID: "test-user1@pve", | ||
UserID: "test-user1@pve", | ||
Password: "Enter123!", | ||
ReqErr: false, | ||
ReqErr: false, | ||
} | ||
Test.Login(t) | ||
} | ||
|
@@ -93,21 +94,21 @@ func Test_User_1_Get_Full(t *testing.T) { | |
"userid": "test-user1@pve", | ||
"email": "[email protected]", | ||
"enable": true, | ||
"expire": 99999999, | ||
"expire": 253370811600, | ||
"firstname": "Bruce", | ||
"lastname": "Wayne", | ||
"keys": "2fa key" | ||
}`, | ||
Args: []string{"-i","get","user","test-user1@pve"}, | ||
Args: []string{"-i", "get", "user", "test-user1@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
|
||
func Test_User_1_Delete(t *testing.T){ | ||
func Test_User_1_Delete(t *testing.T) { | ||
Test := cliTest.Test{ | ||
Expected: "", | ||
ReqErr: false, | ||
Args: []string{"-i","delete","user","test-user1@pve"}, | ||
ReqErr: false, | ||
Args: []string{"-i", "delete", "user", "test-user1@pve"}, | ||
} | ||
Test.StandardTest(t) | ||
} | ||
} |